The Messenger of Allah ﷺ said, "If you are praying and you become uncertain whether you have prayed three or four units, but your stronger assumption is that you have prayed four, then recite the tashahhud, then perform two prostrations while seated before you give the salam, then recite the tashahhud again, then give the salam."
حدثنا النفيلي حدثنا محمد بن سلمة عن خصيف
عن رسول الله ﷺ قال إذا كنت في صلاة فشككت في ثلاث أو أربع وأكبر ظنك على أربع تشهدت ثم سجدت سجدتين وأنت جالس قبل أن تسلم ثم تشهدت أيضا ثم تسلم
Its isnad is daif. Ahmad: 1/428 and Nasai in Kubra, no. 605, reported it through Muhammad bin Salama, but the chain is disconnected. See no. 995. Khaseef is well known to be daif.