The Rules of Forgetfulness (Sahw) in Prayer
Man Lā Yaḥḍuruh al-Faqīh|Volume 1|Book 1|Chapter 50
وَ رَوَى اِبْنُ مُسْكَانَ عَنْ أَبِي بَصِيرٍ قَالَ: سَأَلْتُ أَبَا عَبْدِ اَللَّهِ عَلَيْهِ اَلسَّلاَمُ عَمَّنْ نَسِيَ أَنْ يَسْجُدَ وَاحِدَةً فَذَكَرَهَا وَ هُوَ قَائِمٌ قَالَ «يَسْجُدُهَا إِذَا ذَكَرَهَا وَ لَمْ يَرْكَعْ فَإِنْ كَانَ قَدْ رَكَعَ فَلْيَمْضِ عَلَى صَلاَتِهِ فَإِذَا اِنْصَرَفَ قَضَاهَا وَحْدَهَا وَ لَيْسَ عَلَيْهِ سَهْوٌ.
Ibn Muskan narrated from Abu Basir who said: "I asked Imam Jafar ibn Muhammad Al-Sadiq عليه السلام about someone who forgot to perform one prostration and remembered it while standing. Imam عليه السلام said: 'He should perform it when he remembers, as long as he hasn't yet bowed. If he has already bowed, he should continue his prayer and, when he finishes, he should perform the missed prostration separately. There is no Sahw (forgetfulness) on him.'".
- Ṣaḥīḥ al-Faqīh, p. 46