Sunan Abi Dawud 1028
Grading supplied with this record: Da'if (Al-Albani)
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
إِذَا كُنْتَ فِي صَلاَةٍ فَشَكَكْتَ فِي ثَلاَثٍ أَوْ أَرْبَعٍ وَأَكْبَرُ ظَنِّكَ عَلَى أَرْبَعٍ تَشَهَّدْتَ ثُمَّ سَجَدْتَ سَجْدَتَيْنِ وَأَنْتَ جَالِسٌ قَبْلَ أَنْ تُسَلِّمَ ثُمَّ تَشَهَّدْتَ أَيْضًا ثُمَّ تُسَلِّمُ "
Abu Ubaydah reported, on the authority of his father Abdullah (ibn Mas'ud), the Messenger of Allah (ﷺ) as saying:
When you offer the prayer, and you are in doubt about the number of rak'ahs whether offered three or four, and you have prayed four rak'ahs in all probability in your opinion, you should recite tashahhud and make two prostrations while you are sitting before giving the salutation. afterwards you should recite the tashahhud and give the salutation again. Abu Dawud said: This tradition has been narrated by 'Abd al-Wahid from Khusaif, but he did not report it as a statement of the Prophet (ﷺ). The version of 'Abd al-Wahid has been corroborated by Sufyan, Sharik, and Isra'il. They differed amongst themselves about the text of the tradition and they did not narrate it with the continuous chain up to the Prophet (ﷺ).
Full reference and source
Sunan Abi Dawud 1028 In-book : Book 2, Hadith 639 English translation : Book 3, Hadith 1023
View source on Sunnah.com (opens in a new tab)