Mozilla has made some efforts recently to harden the Firefox browser against code injection attacks. This was made possible by removing “potentially dangerous artifacts” in the Firefox codebase that includes inline scripts and eval()-like functions.
The inline scripts are removed to improve protection for Firefox’s ‘about’ protocol which are more commonly known as about: pages. There are several of these about: pages, that permits users to do things like display networking information, see how the browser is configured, and view installed plug-ins.
Mozilla’s content security lead Christoph Kerschbaumer explians that they had some concerns that attackers could use code injection attacks to abuse the about:config page, which “exposes an API to inspect and update preferences and settings, which allows Firefox users to tailor their Firefox instance to their specific needs.
By not allowing any inline script in any of the about: pages limits the attack surface of arbitrary code execution and hence provides a strong first line of defense against code injection attacks.
When you run eval() with a string that could be affected by a malicious party, it may result in running malicious code on the user’s machine with the permissions of your webpage / extension. Also, a third-party code can see the scope in which eval() was invoked, which can lead to possible attacks in ways to which the similar Function is not susceptible.”
This function is considered as a “powerful yet dangerous tool” that introduces significant attack surface for code injection, and it is always discouraged to use in favor of safer alternatives.
All use of ‘eval()’-like functions has been rewritten from system privileged contexts and from the parent process in the Firefox codebase.
The main aim of this measure is to reduce the attack surface in Firefox and further discourage the function’s use.