Flame stabilization in scramjet combustors used in hypersonic flight is a challenge. At the relevant flight conditions that result in short residence times of the order of 0.1 ms, flame stabilization is often achieved using a cavity flame holder that recirculates hot products of combustion including radicals. In this study, we use massively parallel direct numerical simulations (DNS) to understand the stabilization of a lean ethylene-air premixed flame in the shear layer above a rectangular cavity and the interactions between the flame and the shear layer vorticity. We found that the flame stabilization is significantly affected by the shear flow dynamics between the main flow and the cavity flow, while the recirculation flow pattern within the cavity is dictated by its aspect ratio. Results also show that the recirculation zone transports necessary hot radicals such as OH from the downstream region to the stabilization point. The vorticity which is present mainly on the reactant side of the flame near the stabilization point, gets advected into the products downstream. This leads to an enhanced heat transfer from the flame to the wall, and affects the CO and OH oxidation. The finding suggests that a better cooling system needs to be provided in the design of a scramjet combustor to prevent thermal damages. The data from these simulations will be used to develop reduced order models necessary for engineering simulations.