Integrity of the near-well area is crucial for preventing leakage between geological horizons and towards the surface during CO2 storage, hydrocarbon production and well stimulation. The paper consists of two parts. In the first part, a finite-element model of earlier laboratory tests on thermal cycling of a casing/cement/rock assemblage is set up. It is demonstrated that radial tensile stresses contributing to annular cement debonding are likely to develop during cooling of such an assemblage. The results of the modeling are in agreement with the results of the earlier laboratory experiments, with regard to the temperature histories, CT data, and location of acoustic emission sources. In the second part of the paper, a computational procedure is developed for upscaling of data about rock damage obtained from CT, to a finite-element model of flow in porous media around a well. The damaged zone is shown to dominate the flow along the axis of a compound specimen (a hollow cylinder of sandstone filled with cement). Implications for leakage along an interface between cement and rock in-situ are discussed.