Urban underground construction projects are intertwined vertically and horizontally, and adjacent confined spaces such as water supply and drainage pipelines, side ditches and underground canals may exist near buried gas pipelines. Once the buried gas pipeline leaks, the gas will diffuse into the confined space through the soil and even enter the residential room by the confined space, which brings serious potential safety hazards. In this paper, the underground adjacent confined space hazardous boundary (HB) of underground gas pipeline leakage was defined, the distribution properties of gas leakage diffusion flow field were analyzed by numerical simulation and the distribution law of gas entering the confined space was studied. Using the least-squares method and multiple regression theory, the gas concentration prediction model in the adjacent confined space of buried gas pipeline leakage was established, the HB calculation model was further deduced, and the HB drawing board was drawn. The results showed that in the initial stages, the internal and external pressure and velocity distribution of the pipeline near the leakage hole were unstable, reaching a stable state after 60 s, and then the reverse flow occurred in the pipeline downstream of the leak hole. Reducing the minimum construction distance between the buried gas pipeline and the confined space improved the gas distribution concentration in the confined space. When the minimum construction distance increased from 3 m to 9 m, the gas concentration distribution decreased from 90.21% to 0.88%. Meanwhile, increasing the pipeline pressure and leakage diameter enhanced the gas concentration distribution in the confined space. The HB calculation model and HB drawing board realize the rapid determination of the HB between buried gas pipeline and confined space and offer a more reasonable basis for the design of gas pipeline safe distance in urban underground engineering construction.