Leakage radiation from X-ray security inspection machines is important, and measurement based on ionization chamber or scintillator detector is widely used. The leakage radiation is closely related to the size and the passing time of the luggage, the lead equivalent, the opening angle of the lead curtain, and the response time of the measuring instrument. To characterize the distribution of leakage radiation from the X-ray security inspection machine accurately, a small-volume CZT(CdZnTe) spectrometer was used to measure the energy spectra at a distance of 5 cm from the surface of the inspection machine. By designing and controlling the opening angle of the lead curtain according to the size of the luggage passing through the entrance and exit, the radiation dose was determined based on the measured energy spectra combined with the G(E)-function method. The results show that the maximum relative deviation between the air kerma rate and the ambient dose equivalent rate calculated by the G(E) function method with the standard dose rate does not exceed ±5%. The maximum relative deviation of the dose rate linear verification in the 137Cs radiation field is less than 2.5%. A calibrated CZT detector was utilized to measure the radiation leakage on the surface of the X-ray security inspection machine. It was discovered that the presence of the luggage items and the opening angle of the lead curtain will increase the leakage radiation dose on the surface of the security inspection machine system. This study provides a new approach for measuring scattered radiation of X-ray security inspection machines.