Aliphatics prevail in asteroids, comets, meteorites and other bodies in our solar system. They are also found in the interstellar and circumstellar media both in gas-phase and in dust grains. Among aliphatics, linear alkanes (n-CnH2n+2) are known to survive in carbonaceous chondrites in hundreds to thousands of parts per billion, encompassing sequences from CH4 to n-C31H64. Despite being systematically detected, the mechanism responsible for their formation in meteorites has yet to be identified. Based on advanced laboratory astrochemistry simulations, we propose a gas-phase synthesis mechanism for n-alkanes starting from carbon and hydrogen under conditions of temperature and pressure that mimic those found in carbon-rich circumstellar envelopes. We characterize the analogs generated in a customized sputter gas aggregation source using a combination of atomically precise scanning tunneling microscopy, non-contact atomic force microscopy and ex-situ gas chromatography-mass spectrometry. Within the formed carbon nanostructures, we identify the presence of n-alkanes with sizes ranging from n-C8H18 to n-C32H66. Ab-initio calculations of formation free energies, kinetic barriers, and kinetic chemical network modelling lead us to propose a gas-phase growth mechanism for the formation of large n-alkanes based on methyl-methylene addition (MMA). In this process, methylene serves as both a reagent and a catalyst for carbon chain growth. Our study provides evidence of an aliphatic gas-phase synthesis mechanism around evolved stars and provides a potential explanation for its presence in interstellar dust and meteorites.