PerimeterX/restringer

Why is this segfaulting?

Closed this issue · 3 comments

Using restringer 1.10.1

const { REstringer } = require("restringer");

const main = () => {
  const result = new REstringer(`
    function a() {
      return "a";
    };
    
    function main() {
     // return a();          // Deobfuscates OK
      return a() + "b";      //  Segfault  during deobfuscate  
    };
  `);

  console.log("\nCommencing \n");

  const x = result.deobfuscate();

  console.log("\n Deobfuscate is complete\n");
};

main();
node restring.js

Commencing 

[+] Obfuscation type is Generic
        [+] normalizeEmptyStatements committed 2 new changes!
        [+] replaceFunctionShellsWithWrappedValue committed 1 new changes!
[+] ==> Cycle 1 completed in 0.003 seconds with 3 changes (13 nodes)
[+] ==> Cycle 2 completed in 0.001 seconds with 3 changes (13 nodes)
zsh: segmentation fault  node restring.js

I'm unable to reproduce. It seems to work fine on a clean project with node v20.6.1

Commencing 

[+] Obfuscation type is Generic
	[+] normalizeEmptyStatements committed 2 new changes!
	[+] replaceFunctionShellsWithWrappedValue committed 1 new changes!
[+] ==> Cycle 1 completed in 0.005 seconds with 3 changes (13 nodes)
[+] ==> Cycle 2 completed in 0 seconds with 3 changes (13 nodes)
	[+] resolveMinimalAlphabet committed 1 new changes!
[+] ==> Cycle 3 completed in 0.006 seconds with 1 changes (11 nodes)
[+] ==> Cycle 4 completed in 0 seconds with no changes (11 nodes)
[+] ==> Cycle 5 completed in 0 seconds with no changes (11 nodes)
[+] ==> Cycle 6 completed in 0 seconds with no changes (11 nodes)

 Deobfuscate is complete

This might be a version mismatch between the node used to install REstringer and the version used to run it.

I'm also getting a segfault with that script on node v20.9.0

Commencing 

[+] Obfuscation type is Generic
        [+] normalizeEmptyStatements committed 2 new changes!
        [+] replaceFunctionShellsWithWrappedValue committed 1 new changes!
zsh: segmentation fault  node test.js

@1trackprojects1 There does seem to be an issue with Node v20 and Isolated-vm. The issue doesn't appear in either v18 or v21, so I suggest either using them in the meantime if possible, or running node with the flag --no-node-snapshot.
See issue on Isolated-vm for more info