The Rules of Forgetfulness (Sahw) in Prayer
Man Lā Yaḥḍuruh al-Faqīh|Volume 1|Book 1|Chapter 50
وَ رَوَى عَبْدُ اَلرَّحْمَنِ بْنُ اَلْحَجَّاجِ عَنْ أَبِي إِبْرَاهِيمَ عَلَيْهِ اَلسَّلاَمُ قَالَ: قُلْتُ لِأَبِي عَبْدِ اَللَّهِ عَلَيْهِ اَلسَّلاَمُ، رَجُلٌ لاَ يَدْرِي أَ ثِنْتَيْنِ صَلَّى أَمْ ثَلاَثاً أَمْ أَرْبَعاً فَقَالَ «يُصَلِّي رَكْعَتَيْنِ مِنْ قِيَامٍ ثُمَّ يُسَلِّمُ ثُمَّ يُصَلِّي رَكْعَتَيْنِ وَ هُوَ جَالِسٌ.
Abdurrahman ibn Al-Hajjaj narrated from Abu Ibrahim who said: "I asked Imam Jafar ibn Muhammad Al-Sadiq عليه السلام about a man who does not know whether he prayed two, three, or four rak'ahs. Imam عليه السلام said: 'He should pray two rak'ahs standing, then make salaam (salutation), then pray two more rak'ahs while sitting.'
- Ṣaḥīḥ al-Faqīh, p. 47