Context. A 3.4 μm absorption band (around 2900 cm −1 ), assigned to aliphatic C-H stretching modes of hydrogenated amorphous carbons (a-C:H), is widely observed in the diffuse interstellar medium, but disappears or is modified in dense clouds. This spectral difference between different phases of the interstellar medium reflects the processing of dust in different environments. Cosmic ray bombardment is one of the interstellar processes that make carbonaceous dust evolve. Aims. We investigate the effects of cosmic rays on the interstellar 3.4 μm absorption band carriers. Methods. Samples of carbonaceous interstellar analogues (a-C:H and soot) were irradiated at room temperature by swift ions with energy in the MeV range (from 0.2 to 160 MeV). The dehydrogenation and chemical bonding modifications that occurred during irradiation were studied with IR spectroscopy. Results. For all samples and all ions/energies used, we observed a decrease of the aliphatic C-H absorption bands intensity with the ion fluence. This evolution agrees with a model that describes the hydrogen loss as caused by the molecular recombination of two free H atoms created by the breaking of C-H bonds by the impinging ions. The corresponding destruction cross section and asymptotic hydrogen content are obtained for each experiment and their behaviour over a large range of ion stopping powers are inferred. Using elemental abundances and energy distributions of galactic cosmic rays, we investigated the implications of these results in different astrophysical environments. The results are compared to the processing by UV photons and H atoms in different regions of the interstellar medium. Conclusions. The destruction of aliphatic C-H bonds by cosmic rays occurs in characteristic times of a few 10 8 years, and it appears that even at longer time scales, cosmic rays alone cannot explain the observed disappearance of this spectral signature in dense regions. In diffuse interstellar medium, the formation by atomic hydrogen prevails over the destruction by UV photons (destruction by cosmic rays is negligible in these regions). Only the cosmic rays can penetrate into dense clouds and process the corresponding dust. However, they are not efficient enough to completely dehydrogenate the 3.4 μm carriers during the cloud lifetime. This interstellar component should be destroyed in interfaces between diffuse and dense interstellar regions where photons still penetrate but hydrogen is in molecular form.