Chitosan grafted with gallic acid (CS-GA), along with CS-GA doped with CeO 2 nanoparticles (CS-GA-CeO 2 ) were synthesized as novel environmentally friendly mild steel corrosion inhibitors. The formation of these derivatives was confirmed by Fourier transform infrared spectroscopy (FTIR), X-ray diffraction (XRD), hydrogen nuclear magnetic resonance spectroscopy ( 1 H NMR), and thermal analysis (TGA). Based on potentiodynamic polarization curves (PDP) measurements, the inhibitors acted primarily as hybrid inhibitors, while following the Langmuir adsorption theory model. Scanning electron microscopy (SEM), X-ray photoelectron spectroscopy(XPS) and 3D surface profiles, confirmed that CS-GA-CeO 2 adsorbed on the mild steel forming a protective layer thus preventing the invasion of corrosive media. The corrosion protection mechanism of chitosan derivatives was investigated by molecular dynamics simulations. Electrochemical measurements were used to investigate the corrosion inhibition by CS-GA and CS-GA-CeO 2 on mild steel in a 3.5 % NaCl solution. At room temperature, the highest inhibition efficiency (93.58 %) was achieved at 200 ppm CS-GA-CeO 2 . Modified chitosan nanocomposites were confirmed as promising corrosion inhibitors.