Abdullah bin Masud reported,

The Messenger of Allah ﷺ said, "When any of you is uncertain during his prayer, let him seek out what is correct, then perform two prostrations."Tanafisi said, "This is the foundational principle, and no one is able to refute it."

Ibn Majah 1212

Sahih

حدثنا علي بن محمد حدثنا وكيع عن مسعر عن منصور عن إبراهيم عن علقمة

عن عبد الله قال

قال رسول الله ﷺ إذا شك أحدكم في الصلاة فليتحر الصواب ثم يسجد سجدتين قال الطنافسي هذا الأصل ولا يقدر أحد يرده

ابن ماجه 1212صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
One who doubts in his prayer and seeks what is correct
Numbering
Darussalam 1212
Ibn Majah 1212