Background Incorporating nanoparticles into resin infiltrant (RI) can alter its physical properties, including microleakage. This study aimed to examine the microleakage properties of RI modified with 2.5% and 5% zinc oxide (ZnO) and magnesium oxide (MgO) nanoparticles on artificially induced carious lesions (ACLs) in bovine teeth. Materials and methods Modified RIs were applied to five sound and 30 ACLs on bovine incisors. They were divided into seven groups based on the procedure (Group 1: sound enamel (SE), Group 2: artificial caries lesion only (ACL), Group 3: RI, Group 4: RI+ 2.5% ZnO, Group 5: RI + 5% ZnO, Group 6: RI + 2.5% MgO, Group 7: RI + 5% MgO). The samples were subjected to 5000 thermal cycles and then exposed to methylene blue solution for 24 hours in an incubator. The teeth were sectioned and examined with a stereomicroscope to assess the depth of methylene blue penetration (MBP), quantifying microleakage according to the following scoring: 0 = no penetration, 1 = outer half of enamel, 2 = inner half of enamel, 3 = outer half of dentin, and 4 = inner half of dentin. An ANOVA test was conducted to assess the significance of differences among the groups. Post-hoc tests, including Tukey's HSD (honestly significant difference) test, were performed to identify specific group differences and determine which differences were statistically significant. Results SE samples (Group 1) showed minimal penetration, with 100% scoring 1, indicating high resistance to MBP. The ACL group had significant penetration, with 77.78% scoring 3 and 22.22% scoring 2. The RI group completely prevented MBP, with all samples scoring 0. Both RI+2.5% ZnO (Group 4) and RI+2.5% MgO (Group 6) were highly effective, with 88.89% scoring 0 and 11.11% scoring 1. RI+5% ZnO (Group 5) and RI+5% MgO (Group 7) also prevented MBP but had slightly higher minimal penetration, with 77.78% scoring 0 and 22.22% scoring 1. Significant differences were observed between the ACL group and all other groups, underscoring the effectiveness of RI treatments. No significant differences were found between RI+ZnO and RI+MgO at both concentrations, indicating similar effectiveness. Conclusions The study demonstrated that RI modified with 2.5% and 5% ZnO and MgO nanoparticles effectively reduced microleakage in ACLs on bovine teeth compared to untreated lesions. These modifications significantly inhibited MBP, particularly in enamel and dentin, indicating their potential to enhance the durability and effectiveness in clinical applications. This research emphasizes the promising role of nanoparticle-modified RI in minimizing microleakage and optimizing treatment outcomes. Further research is needed to confirm these findings and refine protocols.