Rabbi Tarfon says: Those of forbidden birth can be purified. How? One of forbidden birth who married a maidservant - the child is a slave, as it is written, "the woman and her children shall belong to her master" (Exodus 21:4). If the master freed him, he turns out to be a free man. That a maidservant cannot be betrothed - from where do we learn it? For the verse says, "Stay here with the donkey" (Genesis 22:5) [a people likened to a donkey, who cannot contract betrothal]. That her child is like her - from where do we learn it? For the verse says, "the woman and her children," etc. That a gentile woman cannot be betrothed - from where do we learn it? The verse says, "You shall not intermarry with them" (Deuteronomy 7:3). That her child is like her - from where do we learn it? For the verse says, "for he will turn away," etc. (Deuteronomy 7:4).
How Rabbi Tarfon Says a Tainted Line Can Be Purified
Yalkut Shimoni on Torah 314:1
רַבִּי טַרְפוֹן אוֹמֵר, יְכוֹלִין מַמְזֵרִין לִטָּהֵר כֵּיצַד, מַמְזֵר שֶׁנָּשָׂא שִׁפְחָה, הַוָּלָד עֶבֶד, דִּכְתִיב הָאִשָּׁה וִילָדֶיהָ תִּהְיֶה לַאדֹנֶיהָ, שִׁחְרְרוֹ, נִמְצָא בֶּן חוֹרִין. שִׁפְחָה, דְּלָא תָפְסֵי בָּהּ קִדּוּשִׁין מִנָּלָן, דַּאֲמַר קְרָא, (בראשית כב, ה) "שְׁבוּ לָכֶם פֹּה עִם הַחֲמוֹר". וְלָדָהּ כָּמוֹהָ, מִנָּלָן, דַּאֲמַר קְרָא, "הָאִשָּׁה וִילָדֶיהָ" וְגוֹ'. נָכְרִית דְּלָא תָפְסֵי בָּהּ קִדּוּשִׁין, מִנָּלָן, אֲמַר קְרָא, "לֹא תִתְחַתֵּן בָּם". וְלָדָהּ כָּמוֹהָ, מִנָּלָן, דַּאֲמַר קְרָא, "כִּי יָסִיר אֶת" וְגוֹ'.