The diffuse $gamma$-ray spectrum at sub-PeV energy region has been measured for the first time by the Tibet-AS$gamma$ experiment. It will shed new light on the understanding of origin and propagation of Galactic cosmic rays at very high energies. It has been pointed out that the traditional cosmic ray propagation model based on low energy measurements undershoot the new data, and modifications of the model with new ingredients or alternative propagation framework is required. In this work, we propose that the hadronic interactions between freshly accelerated cosmic rays and the medium surrounding the sources, which was neglected in the traditional model, can naturally account for the Tibet-AS$gamma$ diffuse emission. We show that this scenario gives a consistent description of other secondary species such as the positron spectrum, the Boron-to-Carbon ratio, and the antiproton-to-proton ratio. As a result, the electron spectrum above 10 TeV will have a hardening due to this secondary component, which may be tested by future measurements.