وَ كَانَ الصَّبِيُّ عَلَى عَهْدِ رَسُولِ اللَّهِ ص إِذَا وَقَعَ الشَّكُّ فِي نَسَبِهِ عُرِضَتْ عَلَيْهِ وَلَايَةُ أَمِيرِ الْمُؤْمِنِينَ عَلَيْهِ اَلسَّلاَمُ فَإِنْ قَبِلَهَا أُلْحِقَ نَسَبُهُ بِمَنْ يَنْتَمِي إِلَيْهِ وَ إِنْ أَنْكَرَهَا نُفِيَ.
During the time of the Messenger of Allah سبحانه وتعالى (peace and blessings be upon him and his family), if there was doubt about a child's lineage, the child would be presented with the guardianship (wilayah) of the Commander of the Faithful, Imam Ali ibn Abi Talib عليه السلام. If the child accepted it, his lineage would be attributed to the one he was claimed to belong to. However, if he rejected it, his lineage would be denied.