Oxygen fugacity is a measure of rock oxidation that influences planetary structure and evolution. Most rocky bodies in the Solar System formed at oxygen fugacities approximately five orders of magnitude higher than a hydrogen-rich gas of solar composition. It is unclear whether this oxidation of rocks in the Solar System is typical among other planetary systems. We exploit the elemental abundances observed in six white dwarfs polluted by the accretion of rocky bodies to determine the fraction of oxidized iron in those extrasolar rocky bodies and therefore their oxygen fugacities. The results are consistent with the oxygen fugacities of Earth, Mars, and typical asteroids in the Solar System, suggesting that at least some rocky exoplanets are geophysically and geochemically similar to Earth.