Cavity flows driven by an applied horizontal temperature gradient are considered in the high Rayleigh number limit for a fluid-saturated porous medium. The analysis is concerned with the behaviour of the vertical boundary layer equations near the corners of the cavity. Implications for the structure of the core flow are discussed. The present results, which are new, compare well with a recent numerical solution. Although the results are consistent with the standard hypothesis that the vertical boundary layers empty into the core, they are not in agreement with the corner behaviour previously suggested in the literature. The analysis of the vertical boundary layer structure is also applicable to cavity flows in electrically conducting fluids in the limit when magnetic drag is the dominant force.