In the Catholic Church, there are indeed a very few cases in which priests are required to delay, not withhold, the Sacrament of Baptism; illegitimacy is not one of them.
Catholicism considers baptism necessary for salvation:
The Lord himself affirms that Baptism is necessary for salvation. [citing John 3:5] He also commands his disciples to proclaim the Gospel to all nations and to baptize them. [citing Matthew 28:19–20] Baptism is necessary for salvation for those to whom the Gospel has been proclaimed and who have had the possibility of asking for this sacrament. [citing Mark 16:16] The Church does not know of any means other than Baptism that assures entry into eternal beatitude; this is why she takes care not to neglect the mission she has received from the Lord to see that all who can be baptized are "reborn of water and the Spirit."
(Catechism of the Catholic Church, paragraph 1257)
It is therefore most important to Catholicism that all people be baptized—so important that the Church even recognizes extreme situations in which a lay person can baptize:
In case of necessity, anyone, even a non-baptized person, with the required intention, can baptize, by using the Trinitarian baptismal formula. The intention required is to will to do what the Church does when she baptizes. The Church finds the reason for this possibility in the universal saving will of God and the necessity of Baptism for salvation.
(Catechism, paragraph 1256)
When an ordinary minister is absent or impeded, a catechist or another person designated for this function by the local ordinary, or in a case of necessity any person with the right intention, confers baptism licitly.
(Code of Canon Law, canon 861, section 2)
Baptism, however, does not ensure salvation, but only the outpouring of God's justifying grace on the baptizand. It is up to the individual, or in the case of a minor up to their parents or sponsors in baptism, to work so as to gain grace and merit before God; this is ultimately what allows them to gain salvation.
It is important, then, for the Church to make sure that a child who is offered for baptism has a reasonable chance of being raised Catholic. Thus, canon law requires the priest to delay baptism if he is sincerely doubtful on this point, while he discusses the issue with the parents:
For an infant to be baptized licitly ... there must be a founded hope that the infant will be brought up in the Catholic religion; if such hope is altogether lacking, the baptism is to be delayed according to the prescripts of particular law after the parents have been advised about the reason.
(Code of Canon Law, canon 868, section 1, paragraph 2)
The use of the word licitly in this instance indicates that if a priest violated this canon and baptized an infant in this case, the baptism would still be valid; the Church would still treat the infant as baptized and would believe that justifying grace had indeed been granted to them; but the priest might be in trouble for doing something that he really shouldn't have, and the infant's prospects of growth in faith and grace might be impaired.
All this is to point out that there may be times when the Church might not baptize an infant for whom baptism is requested, and to discuss pretty much the only time when this might be the case. (The only other possible occasions when baptism might not be conferred are when the parents don't assent to the baptism, or when the child has already been baptized in another Christian denomination.) Illegitimacy is not one of those times. That is, illegitimacy is not, and to the best of my understanding never has been, a bar to baptism in the Catholic Church.