Designing glass with excellent acid resistance is a prerequisite for developing high-performance terminal electrode pastes. Herein, we fabricated Y2O3 doped BaO–B2O3–SiO2 glass with excellent anti-sulfuric acid corrosion properties. The anti-corrosion mechanism of glass in acid environment was investigated by spectra and microstructure analysis. The passivating gel layer with a porous structure was formed on the glass surface during the corrosion process. The average pore diameter of the porous gel could be reduced by increasing the content of Y2O3. The smaller pore size of the porous gel would considerably increase the collision frequency between solvent molecules and the pore wall, which could effectively inhibit the ion migration in the gel layer, reduce the corrosion rate, and improve the acid resistance of the glass. This study contributes to the understanding of the corrosion mechanism of the glass and provides theoretical guidance for rationally designing anti-acid corrosion glass for terminal electrode pastes.