Skip to content

🚨 transformObjectKeys: true changes the behavior of the code: default parameter objects become shared across calls #1455

Closed

Description

@regnaio

Expected Behavior

Obfuscated code behaves the same as the original. Here f() returns a new object on every call:

function f(o = { a: 1 }) { return o; }
f() === f(); // false

Current Behavior

transformObjectKeys: true changes the behavior of the code: f() === f() becomes true.

It moves the default object out of f(), so every call returns the same object:

var a = {};
a['a'] = 0x1;
function f(b = a) {
    return b;
}

Any mutation of that object leaks into later calls.

Steps to Reproduce

  1. Open https://obfuscator.io/legacy-playground
  2. Paste function f(o = { a: 1 }) { return o; } console.log(f() === f());
  3. Turn on "Transform Object Keys", then click "Obfuscate"
  4. Run the output. It prints true, but the original code prints false.

JavaScript Obfuscator Edition

  • JavaScript Obfuscator Open Source

Your Environment

  • Obfuscator version used: 5.8.0 (also 1.0.0 to 5.4.7)
  • Node version used: 22.22.2

Stack trace

None. No error is thrown, the code silently behaves differently.

Minimal working example that will help to reproduce issue

const JavaScriptObfuscator = require('javascript-obfuscator');
const code = 'function f(o = { a: 1 }) { return o; } console.log(f() === f());';
eval(code); // false
eval(JavaScriptObfuscator.obfuscate(code, { transformObjectKeys: true }).getObfuscatedCode()); // true

Activity

  1. changed the title [-]🚨 `transformObjectKeys` hoists object-literal default parameters, sharing one object across calls[/-] [+]🚨 `transformObjectKeys: true` changes the behavior of the code: default parameter objects become shared across calls[/+] on Sep 29, 2026
  2. sanex3339 commented on Sep 30, 2026

    @sanex3339
    Member

    Will be released later today as 5.8.1

  3. regnaio commented on Oct 2, 2026

    @regnaio
    Author

    Thank you so much for all of your help, @sanex3339 😄

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions