Anyone can baptize, even heathens. This is true, especially in cases when there is a danger of death. One cannot baptize oneself, though.
From the Council of Florence, Exaltate Deo:
In case of necessity not only a priest or a deacon, but also a layman, or a woman, yes even a pagan and a heretic can baptize, so long as he preserves the form of the Church.
From the Council of Trent, Canons on Baptism (Canon 4):
If anyone says that baptism, even that given by heretics in the name of the Father and of the Son and of the Holy Spirit, with the intention of doing what the Church does, is not true baptism, let him be anathema.