The tolerance/resistance of the electronic devices to extremely harsh environments is of supreme interest. Surface effects and chemical corrosion adversely affect stability and operation uniformity of metal oxide resistive memories. To achieve the surrounding-independent behavior, the surface modification is introduced into the ZnO memristors via incorporating fluorine to replace the oxygen sites. F-Zn bonds is formed to prevent oxygen chemisorption and ZnO dissolution upon corrosive atmospheric exposure, which effectively improves switching characteristics against harmful surroundings. In addition, the fluorine doping stabilizes the cycling endurance and narrows the distribution of switching parameters. The outcomes provide valuable insights for future nonvolatile memory developments in harsh electronics.