The Prophet ﷺ said, "The child belongs to the bed, and for the fornicator is the stone."
حدثنا بهز حدثنا حماد يعني ابن سلمة عن محمد بن زياد
عن النبي ﷺ قال الولد للفراش وللعاهر الحجر
Its isnad is sahih. It was mentioned previously at 7577. It was also related by Bukhari 5/192 in "Al-Maghazi," the chapter "Layth said," Muslim 3/1080 no. 1457 in "Al-Rida," "The child belongs to the marital bed," Abu Dawud 2/282 no. 2273 in "Al-Talaq," "The child belongs to the marital bed," Tirmidhi 4/430 no. 2121 in "Al-Wasaya," the chapter "What has been said about there being no bequest for an heir," Nasai 6/181 no. 3487 in "Al-Talaq," "The marital bed of the female slave," and Ibn Majah 1/646 no. 2004 in "Al-Nikah," "The child belongs to the marital bed."