Context. The determination of the stellar initial mass function (IMF) of massive galaxies is one of the open problems in cosmology. Strong gravitational lensing is one of the few methods that allow us to constrain the IMF outside of the Local Group. Aims. The goal of this study is to statistically constrain the distribution in the IMF mismatch parameter, defined as the ratio between the true stellar mass of a galaxy and that inferred assuming a reference IMF, of massive galaxies from the Baryon Oscillation Spectroscopic Survey (BOSS) constant mass (CMASS) sample. Methods. We took 23 strong lenses drawn from the CMASS sample, measured their Einstein radii and stellar masses using multi-band photometry from the Hyper Suprime-Cam survey, then fitted a model distribution for the IMF mismatch parameter and dark matter halo mass to the whole sample. We used a prior on halo mass from weak lensing measurements and accounted for strong lensing selection effects in our model. Results. Assuming a Navarro Frenk and White density profile for the dark matter distribution, we infer a value mu(IMF) = -0.04 +/- 0.11 for the average base-10 logarithm of the IMF mismatch parameter, defined with respect to a Chabrier IMF. A Salpeter IMF is in tension with our measurements. Conclusions. Our results are consistent with a scenario in which the region of massive galaxies where the IMF normalisation is significantly heavier than that of the Milky Way is much smaller than the scales 5-10 kpc probed by the Einstein radius of the lenses in our sample, as recent spatially-resolved studies of the IMF in massive galaxies suggest.