Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:24:06+00:00 2026-06-12T01:24:06+00:00

One of the guarantees that strict mode provides is that in strict function code,

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:24:07+00:00Added an answer on June 12, 2026 at 1:24 am

    Theoretically it should not be possible to reassign the eval identifier to something other than the eval property of the global object, or mask it with a local variable, according to annex C:

    The identifier eval or arguments may not appear as the LeftHandSideExpression of an Assignment operator (11.13) or of a PostfixExpression (11.3) or as the UnaryExpression operated upon by a Prefix Increment (11.4.4) or a Prefix Decrement (11.4.5) operator.

    …

    It is a SyntaxError if the Identifier “eval” or the Identifier “arguments” occurs as the Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code or if its FunctionBody is strict code (11.1.5).

    …

    It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)

    …and so on.


    As discussed below, it’s possible to change the global eval function by assigning a new value to that property of the global object. A reference to the global object can be obtained by an indirect call to eval in strict mode:

    var glob = (0,eval)('this');
    

    You could extend that to something that will work reliably in non-strict mode as well:

    var glob = (function(){ return this || (0,eval)('this') }());
    

    …and then assign its eval property to something else.

    While eval will still be identical to the eval property of the global object, it won’t be the built-in eval anymore, which should meet your conditions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a fair semaphore in python, one that guarantees that
Is there a reliable way to JSON.stringify a JavaScript object that guarantees that the
If I have two models that are guaranteed to have a one-to-one correspondence, i.e.
One of the neat characteristics of UTF-8 is that if you compare two strings
Is it possible one and the same object, particularly a string or any primitive
I have created a system that automatically registers function objects (functors) into a map
The C standard guarantees that size_t is a type that can hold any array
The C standard guarantees that an int is able to store every possible array
One of the main reasons given for using auto-increment PK in MySQL is that
I have a function that takes a lazy ByteString , that I wish to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.