Kidushin3: 12
כָּל מָקוֹם שֶׁיֵּשׁ קִדּוּשִׁין וְאֵין עֲבֵרָה — הַוָּלָד הוֹלֵךְ אַחַר הַזָּכָר. וְאֵיזֶה זוֹ? כֹהֶנֶת, לְוִיָּה, וְיִשְׂרְאֵלִית שֶׁנִּשְּׂאוּ לְכֹהֵן, וּלְלֵוִי, וּלְיִשְׂרָאֵל. וְכָל מָקוֹם שֶׁיֵּשׁ קִדּוּשִׁין וְיֵשׁ עֲבֵרָה, הַוָּלָד הוֹלֵךְ אַחַר הַפָּגוּם. וְאֵיזוֹ זוֹ? אַלְמָנָה לְכֹהֵן גָּדוֹל, גְּרוּשָׁה וַחֲלוּצָה לְכֹהֵן הֶדְיוֹט, מַמְזֶרֶת וּנְתִינָה לְיִשְׂרָאֵל, בַּת יִשְׂרָאֵל לְמַמְזֵר וּלְנָתִין. וְכָל מִי שֶׁאֵין לָהּ עָלָיו קִדּוּשִׁין, אֲבָל יֶשׁ לָהּ עַל אֲחֵרִים קִדּוּשִׁין — הַוָּלָד מַמְזֵר. וְאֵיזֶה זֶה? הַבָּא עַל אַחַת מִכָּל הָעֲרָיוֹת שֶׁבַּתּוֹרָה.  וְכָל מִי שֶׁאֵין לָהּ לֹא עָלָיו וְלֹא עַל אֲחֵרִים קִדּוּשִׁין — הַוָּלָד כְּמוֹתָהּ. וְאֵיזֶה זֶה? וְלַד שִׁפְחָה וְנָכְרִית.
In every case in which there is kiddushin and there is no transgression, the offspring follows the male. Which is this? [This is] the daughter of a Kohen, a Levi, or a Yisrael who was married to a Kohen, a Levi, or a Yisrael.  In every case in which there is kiddushin and there is transgression, the offspring follows the defective one. Which is this? [This is] a widow to a Kohen Gadol, a divorcee or a chalutzah to an ordinary Kohen, a mamzeres or a Nesinite to a regular Jew, [or] the daughter of a regular Jew to a mamzer or a Nesinite.  [In a case of] anyone who cannot have kiddushin with him but can have kiddushin with others, the offspring is a mamzer. Which is this? [This is] one who has relations with any of the arayos which are in the Torah.  [In a case of] anyone who cannot have kiddushin with him or with others, the offspring is like her. Which is this? [This is] the offspring of a slave and a gentile woman.