It's complicated, but as always, Wikipedia has it covered.
The short version is that in the vast majority of cases, the baby will inherit one or more citizenships from its parents through jus sanguinis, and nothing more.
If the baby is born within the territorial limits of a country that applies jus soli, including flying overheard and within nautical limits, the baby may be eligible for citizenship of that country as well.
If the baby's parents are of unknown citizenship, stateless or citizens of countries that don't do jus sanguinis at all (not sure any exist?), and they can't get any citizenships via jus soli (eg. birth occurred in international waters), the 1961 Convention on the Reduction of Statelessness will kick in:
For the purpose of determining the obligations of contracting states under this convention, birth on a ship or aircraft shall amount to birth in the territory of the State that gives its flag to that ship or aircraft.
So the birth will be treated as if it occurred in the country that registered the plane or ship. This doesn't mean the baby automatically gets that country's citizenship, but the Convention aims to ensure that if they can't get anything else, they'll get this as a fallback.
Since not all countries have signed the Convention, and not all countries that signed it have enacted it in law or in practice, it's still possible to fall through the gaps. Post any interesting cases in the comments ;)