The role played by the intergalactic medium (IGM) in the X-ray absorption towards high-redshift sources has recently drawn more attention in spectral analysis studies. Here, we study the X-ray absorption towards 15 flat-spectrum radio quasars at $z>2$, relying on high counting statistic ($gtrsim10,000$ photons) provided by XMM-Newton, with additional NuSTAR (and simultaneous Swift-XRT) observations when available. Blazars can be confidently considered to have negligible X-ray absorption along the line of sight within the host galaxy, likely swept by the kpc-scale relativistic jet. This makes our sources ideal for testing the absorption component along the IGM. Our new approach is to revisit the origin of the soft X-ray spectral hardening observed in high-z blazars in terms of X-ray absorption occurring along the IGM, with the help of a low-z sample used as comparison. We verify that the presence of absorption in excess of the Galactic value is the preferred explanation to explain the observed hardening, while intrinsic energy breaks, predicted by blazars emission models, can easily occur out of the observing energy band in most sources. First, we perform an indirect analysis comparing the inferred amount of absorption in excess of the Galactic value with a simulated IGM absorption contribution, that increases with redshift and includes both a minimum component from diffuse IGM metals, and the additional contribution of discrete denser intervening regions. Then, we directly investigate the warm-hot IGM with a spectral model on the best candidates of our sample, obtaining an average IGM density of $n_0=1.01^{+0.53}_{-0.72}times10^{-7}$ cm$^{-3}$ and temperature of $log(T/text{K})=6.45^{+0.51}_{-2.12}$. A more dedicated study is currently beyond reach, but our results can be used as a stepping stone for future more accurate analysis, involving Athena.