Gamma Ray Bursts (GRBs) can be used as a powerful tool to study galactic environments at different epochs of the Universe's evolution, thanks to their bright afterglow emission ranging from X-rays to optical and radio wavebands. Important aspect of the environment is dust, which plays a central role in the astrophysical processes of interstellar medium and in the formation of stars. GRBs can be a unique probe of dust at cosmological distances, where its origin and properties are still poorly known. By using a sample of GRB afterglow spectra observed with the VLT/X-shooter spectrograph we studied the rest-frame extinction in GRB lines-of-sight by modelling the broadband near-infrared to X-ray afterglow spectral energy distributions. We present our results on the rest-frame extinction of our sample, and illustrate that the spectroscopic data, thanks to a combination of excellent resolution and coverage of the blue part of the spectral energy distributions, are more successful than photometric measurements in constraining the extinction curves and therefore the dust properties in GRB hosts.