Corrosion is a prevalent issue in buried pipelines during long-term service, often exacerbated by environmental factors. This corrosion not only undermines the structural integrity of the pipelines but also significantly increases the probability of failure during seismic hazards. Axial tensile tests on cast iron pipelines with cement-caulked joints are conducted in this study. A simplified mechanical model is developed based on test results. The Karhunen-Loève (K-L) expansion method is then employed to generate a two-dimensional random field representing the corroded pipeline surface. This field is subsequently reduced to a one-dimensional random field of corrosion depth, which is mapped onto the mesh elements of each pipe segment to capture the variability in corrosion depth. A numerical model of the buried pipeline is established, incorporating nonlinear spring elements to represent the joints and beam elements for the pipe segments. Nonlinear dynamic analyses are then performed under three representative seismic scenarios to examine the dynamic response of the pipeline joints and the stress distribution within the pipe segments. The results indicate that uncertainty in joint tensile capacity has a significant impact on the seismic performance of the pipeline. The joints with lower stiffness often absorb more than 60% of the pipeline's deformation during seismic effects. Additionally, the variability in corrosion depth leads to a non-uniform stress distribution within the pipe segments, resulting in localized stress concentrations that increase the maximum stress by approximately 120%, thereby posing a considerable threat to pipeline safety. Compared to homogeneous deterministic pipeline models, those that account for both corrosion and joint capacity uncertainties provide a more accurate representation of the structural dynamic response under seismic effect. This study offers critical theoretical insights and practical guidance for the seismic design and assessment of underground pipelines.