Molecular oxygen has been confirmed as the fourth most abundant molecule in cometary material ( \ce O2/ \ce H2O \sim 4 % ) and is thought to have a primordial nature , i.e. , coming from the interstellar cloud from which our solar system was formed . However , interstellar \ce O2 gas is notoriously difficult to detect and has only been observed in one potential precursor of a solar-like system . Here , the chemical and physical origin of \ce O2 in comets is investigated using sophisticated astrochemical models . Three origins are considered : i ) in dark clouds , ii ) during forming protostellar disks , and iii ) during luminosity outbursts in disks . The dark cloud models show that reproduction of the observed abundance of \ce O2 and related species in comet 67P/C-G requires a low H/O ratio facilitated by a high total density ( \geq 10 ^ { 5 } cm ^ { -3 } ) , and a moderate cosmic ray ionisation rate ( \leq 10 ^ { -16 } s ^ { -1 } ) while a temperature of 20 K , slightly higher than the typical temperatures found in dark clouds , also enhances the production of \ce O2 . Disk models show that \ce O2 can only be formed in the gas phase in intermediate disk layers , and can not explain the strong correlation between \ce O2 and \ce H2O in comet 67P/C-G together with the weak correlation between other volatiles and \ce H2O . However , primordial \ce O2 ice can survive transport into the comet-forming regions of disks . Taken together , these models favour a dark cloud ( or `` primordial ’ ’ ) origin for \ce O2 in comets , albeit for dark clouds which are warmer and denser than those usually considered as solar system progenitors .