How do CMB photons 'gain energy when they pass through normal regions of space with matter' and 'lose energy when they pass through voids'? The Space.com article Huge Hole Found in the Universe says:

The gargantuan hole was found by examining observations made using the Very Large Array (VLA) radio telescope, funded by the National Science Foundation.
There is a &quot;remarkable drop in the number of galaxies&quot; in a region of sky in the constellation Eridanus, Rudnick said.
The region had been previously been dubbed the &quot;WMAP Cold Spot,&quot; because it stood out in a map of the Cosmic Microwave Background (CMB) radiation made by NASA's Wilkinson Microwave Anisotopy Probe (WMAP) satellite. The CMB is an imprint of radiation left from the Big Bang, the theoretical beginning of the universe.
&quot;Although our surprising results need independent confirmation, the slightly colder temperature of the CMB in this region appears to be caused by a huge hole devoid of nearly all matter roughly 6 to 10 billion light-years from Earth,&quot; Rudnick said.
Photons of the CMB gain a small amount of energy when they pass through normal regions of space with matter, the researchers explained. But when the CMB passes through a void, the photons lose energy, making the CMB from that part of the sky appear cooler. (emphasis added)


Question: How do CMB photons gain energy when they pass through &quot;normal regions of space with matter&quot; and lose energy when they pass through voids?
It is the late time integrated Sachs Wolfe effect.

As they travel towards us, apart from the general expansion, photons from the CMB gain energy when they fall into potential wells (where matter is). Of course, they lose it again as they emerge on the other side of the well, but the cosmic expansion means that the well isn't quite as deep by the time that happens. As a result, photons gain a little energy compared to the average CMB sightline.

The opposite happens for voids. Energy is required to enter a void (the potential is higher than average), but all this energy is not retrieved because the potential flattens due to expansion as the photon traverses it. Hence the directions of voids would be a bit cooler.