Abu Ubaydah bin Abdullah (may Allah have mercy on him) narrates from his father (Sayyiduna Abdullah bin Mas'ud, may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When you are praying and you are in doubt whether you have prayed three rak'ahs or four, and your stronger assumption is four, then sit for the tashahhud, then perform two prostrations while sitting before giving the salam, then recite the tashahhud again in the same way and give the salam."
Abu Dawud said: Abd al-Wahid narrated it likewise from Khusayf but did not attribute it to the Prophet (peace and blessings be upon him), and Sufyan, Sharik and Isra'il also agreed with Abd al-Wahid. They differed over the wording of the text of the hadith, and they did not narrate it with a chain reaching the Prophet (peace and blessings be upon him).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3820