Fundamental properties of the extinction curve, like the slope in the rest-frame ultraviolet (UV) and the presence/absence of a broad absorption excess centred at 2175 A (the UV bump), are investigated for a sample of 108 massive, star-forming galaxies at 1 < z < 2.5, selected from the FDF Spectroscopic Survey, the K20 survey, and the GDDS. These characteristics are constrained from a parametric description of the UV spectral energy distribution (SED) of a galaxy, as enforced by combined stellar population and radiative transfer models for different geometries, dust/stars configurations and dust properties. In at least one third of the sample, there is a robust evidence for extinction curves with at least a moderate UV bump. The presence of the carriers of the UV bump is more evident in galaxies with UV SEDs suffering from heavy reddening. We interpret these results as follows. The sample objects possess different mixtures of dust grains and molecules producing extinction curves in between the average ones of the Small and Large Magellanic Cloud, where the UV bump is absent or modest, respectively. Most of the dust embeds the UV-emitting stellar populations or is distributed out of the galaxy mid-plane. Alternatively, even dust with a pronounced UV bump, as for the average Milky-Way extinction curve, can be present and distributed in the galaxy mid-plane. In this case, variations of the continuum scattering albedo with wavelength or an age-dependent extinction are not sufficient to explain the previous trend with reddening. Hence, additional extraplanar dust has to be invoked. The data suggest that the carriers of the UV bump are associated with intermediate-age stellar populations, while they survive in the harshest UV-radiation fields owing to dust self-shielding. [abridged]