Skip to content

Escaped "use\x20strict" in directive prologue is emitted as 'use strict' #1474

Closed as not planned

Description

@trackoor

Expected Behavior

Obfuscating a script or function whose directive prologue contains an escaped "use\x20strict" string should not turn it into an unescaped 'use strict' directive, preserving non-strict mode semantics (printing false in the example below).

Current Behavior

javascript-obfuscator emits function f(){'use strict';return this===undefined;}console['log'](f());, which turns the escaped string in the directive prologue into an active 'use strict' directive and changes this === undefined inside f() from false to true.

Because directive ExpressionStatement nodes are skipped during literal transformation, their string literals do not receive the raw verbatim property and the code generator falls back to printing the cooked string value.

Steps to Reproduce

  1. Pass a function containing "use\x20strict"; in its directive prologue to JavaScriptObfuscator.obfuscate with { stringArray: false }.
  2. Execute the obfuscated code and compare its output with the original code.

JavaScript Obfuscator Edition

  • JavaScript Obfuscator Open Source

Your Environment

  • Obfuscator version used: 5.10.0
  • Node version used: v24.14.1

Stack trace

N/A (wrong runtime behavior, no exception thrown)

Minimal working example that will help to reproduce issue

const JavaScriptObfuscator = require('javascript-obfuscator');

const code = 'function f() { "use\\x20strict"; return this === undefined; }\nconsole.log(f());';
const obfuscated = JavaScriptObfuscator.obfuscate(code, { stringArray: false }).getObfuscatedCode();

console.log(obfuscated);
eval(obfuscated);

Credit: https://ucsbplse.github.io/

Activity

  1. added a commit that references this issue on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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