One of the guarantees that strict mode provides is that in strict function code, the identifier arguments always refers to that function's Arguments object.
function fn () { 'use strict'; // malicious code arguments // still refers to the function's Arguments object } So, no matter what code is injected at // malicious code, the arguments identifier is immutably bound to the function's Arguments object during the entire function invocation.
I was wondering if the same guarantees are provided for the eval identifier, i.e. does the eval identifier with guarantee refer to the built-in global eval function at all times?
I'd like to point out that the above mentioned guarantee is not provided if our strict code is nested within non-strict code. Non-strict code is allowed to create local "eval" bindings, or to mutate the global "eval" binding. (Also, if another non-strict program uses the same global object (as in a web-page containing multiple scripts), the above mentioned guarantee is also not provided.)
So, for the sake of this question, I'd like to define the following scenario:
- our program is stand-alone, i.e. it doesn't share its global object with any other program,
our program consists of a single strict IIFE, like so:
(function () { 'use strict'; // malicious code eval // does it still refer to the built-in global eval function? }());
Given these conditions, is it possible to inject code at \\ malicious code, that will change the value of the eval identifier?