Low-energy cosmic rays are the dominant source of ionization for molecular cloud cores. The ionization fraction, in turn, controls the coupling of the magnetic field to the gas and hence the dynamical evolution of the cores. The purpose of this work is to compute the attenuation of the cosmic-ray flux rate in a cloud core taking into account magnetic focusing, magnetic mirroring, and all relevant energy loss processes. We adopt a standard cloud model characterized by a mass-to-flux ratio supercritical by a factor of about 2 to describe the density and magnetic field distribution of a low-mass starless core, and we follow the propagation of cosmic rays through the core along flux tubes enclosing different amount of mass. We then extend our analysis to cores with different mass-to-flux ratios. We find that mirroring always dominates over focusing, implying a reduction of the cosmic-ray ionization rate by a factor of about 2-3 over most of a solar-mass core with respect to the value in the intercloud medium outside the core. For flux tubes enclosing larger masses the reduction factor is smaller, since the field becomes increasingly uniform at larger radii and lower densities. We also find that the cosmic-ray ionization rate is further reduced in clouds with stronger magnetic field, e.g. by a factor of about 4 for a marginally critical cloud. The magnetic field threading molecular cloud cores affects the penetration of low-energy cosmic rays and reduces the ionization rate by a factor 3-4 depending on the position inside the core and the magnetization of the core.