Skip to content

--disallow-code-generation-from-strings does not work as documented#58221

@ChALkeR

Description

@ChALkeR

Doc: https://nodejs.org/docs/latest/api/cli.html#--disallow-code-generation-from-strings

It is advertised to cover built-in language features, but it doesn't cover data imports

No Node.js modules are directly imported here

// run with node and node --disallow-code-generation-from-stringsconstpayload='console.log("evaluated code from string")'try{eval(payload)}catch(e){console.log(e.message)}try{newFunction(payload)()}catch(e){console.log(e.message)}try{awaitimport('data:text/javascript,'+payload)}catch(e){console.log(e.message)}

Output:

% node --disallow-code-generation-from-strings 1.jsCode generation from strings disallowed for this contextCode generation from strings disallowed for this contextevaluated code from string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions