Skip to content

feat: add From JS6Chars operation with a static decoder - #2932

Closed
Roma476 wants to merge 1 commit into
gchq:masterfrom
Roma476:feature/from-js6chars-static
Closed

Roma476 wants to merge 1 commit into
gchq:masterfrom
Roma476:feature/from-js6chars-static

Conversation

@Roma476

@Roma476 Roma476 commented Nov 6, 2026

Copy link
Copy Markdown

Description
Adds the From JS6Chars operation to decode JavaScript obfuscated using only [ ] ( ) ! +.

The decoder is implemented as a static interpreter:

  • Parses the input with esprima, which is already a production dependency. No new package is added.
  • Evaluates only the JavaScript subset needed to build the decoded string inside a self-contained value model.
  • Intercepts the Function constructor. Function bodies that are a single return <constant> are constant-folded; every other body is returned as source text.
  • Never calls eval, new Function, vm, or any equivalent. Input code is never executed.
  • Applies limits on input length, evaluation steps, call depth, string length and array length to avoid resource exhaustion.
  • Is loaded through the Code module, so the interpreter is only downloaded when the operation is used.

The operation is registered in the Code tidy category. A payload that constructs a Function body (return atont) is covered by a regression test: it is returned as text and never executed. A separate test uses a valid alert(1) payload.

Existing Issue
Relates to #1054.

Screenshots
N/A, this operation does not change any existing visual aspects of CyberChef.

AI disclosure
I used an AI coding assistant (DeepSeek V4.1 Flash) as a learning and development aid to help write parts of the code and to better understand some theoretical concepts. I defined the requirements and security constraints, reviewed and tested the final implementation, and take responsibility for the code submitted.

Test Coverage
Added 7 operation tests in tests/operations/tests/FromJS6Chars.mjs:

  • simple decode (a)
  • longer string (Hello)
  • numeric string (123)
  • a valid alert(1) payload that must be decoded without being executed
  • a Function-body payload that must be returned as text (return atont) and must not be executed
  • empty/whitespace input
  • invalid input (error message)

Verified locally with:

  • npm test: 279 Node tests + 2334 operation tests passing
  • npm run lint: passing

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution - unfortunately this repository only accepts pull requests from organisation members or approved outside collaborators. Due to that, this pull request has been closed automatically.

@GCHQDeveloper581

Copy link
Copy Markdown
Collaborator

@Roma476 we are currently working out the process on working with approved outside collaborators. When we've completed this exercise, relevant affected PRs will be reopened/looked at for processing.

In the meantime I suggest not making any changes to older PRs as this is likely to result in the bot closing them (as happened with your earlier PR), and older ones are more likely to be missed when reopening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants