Summary
GCHQ CyberChef versions before 11.0.0 contain a cross-site scripting (XSS) flaw in the "Show Base64 offsets" recipe, where crafted input is reflected back into the UI without proper sanitization.
An attacker who can convince a victim to open a malicious CyberChef URL can cause arbitrary JavaScript to execute in the victim's browser within the context of the CyberChef application.
Affected context
The vulnerability occurs within CyberChef's web interface when using the "Show Base64 offsets" operation in recipes.
When user-supplied data is embedded into the page output or UI components without robust encoding, it can be interpreted as active script by the browser.
The risk is most pronounced when CyberChef is accessed via URLs that encode recipes and input values, and users routinely open shared or untrusted links.
Exploit preconditions
- Attack surface: Web UI of CyberChef, typically accessed via browser.
- Required access: Ability to craft and distribute a malicious CyberChef link or recipe (e.g., via email, chat, documentation).
- Trigger point: A victim visits a crafted URL that loads a recipe using "Show Base64 offsets" with attacker-controlled data.
- Why exploitation is possible: The Show Base64 offsets feature reflects untrusted input into the DOM without sufficient context-aware output encoding or sanitization, allowing the browser to interpret the content as executable JavaScript.
Why this happens
This issue stems from improper neutralization of input used in web page generation, aligning with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The underlying pattern is that data from the recipe or URL fragment is treated as display content but is inserted into the HTML/DOM without applying consistent HTML/JavaScript encoding.
As a result, special characters associated with script execution (e.g., <, >, quotes) are not safely encoded, enabling attacker-controlled data to break out of the intended context and execute as script.
Potential impact
- Execution of arbitrary JavaScript in the victim's browser when viewing a malicious CyberChef link
- Theft or manipulation of data processed within the CyberChef page (e.g., clipboard interactions, displayed data)
- Impersonation of the user within the CyberChef context, including modifying recipes or results shown
- Use of the CyberChef tab as a pivot point for phishing or misleading UI content
General mitigation guidance
Effective mitigation centers on robust output encoding and strict handling of untrusted data within the UI.
Recommended defensive patterns include:
- Applying context-aware output encoding for any user-controlled data rendered into HTML, attributes, or script contexts.
- Avoiding direct insertion of raw text into the DOM; use safe DOM APIs with explicit text nodes rather than HTML strings.
- Normalizing and validating operation output so that special HTML and JavaScript meta-characters are encoded before display.
- Enforcing Content Security Policy (CSP) that disallows inline scripts and restricts script sources to reduce XSS exploitability.
- Treating URL fragments and recipe parameters as untrusted input at all times, and sanitizing them before use in UI rendering.
How teams detect issues like this
Detection typically involves both code-centric and behavior-centric approaches:
- Static analysis: Look for DOM sinks that consume data derived from URL fragments, recipes, or user inputs without encoding (e.g.,
innerHTML,document.write, dynamic HTML templates). - Code review: Flag any rendering logic associated with the "Show Base64 offsets" operation where text is interpolated into HTML; verify that appropriate escaping functions are consistently applied.
- Security testing: Use automated or manual web scanners configured with XSS payloads in recipe and input fields, including URL-encoded fragments feeding the Show Base64 offsets operation.
- Policy enforcement: Incorporate linting rules or framework-level security guidelines that discourage insecure DOM manipulation and enforce safe templating patterns.

