Observatory research catalog · ATO.T6236E94A · High severity
LLM Jailbreak: CodeChameleon (published research family)
CodeChameleon (Lv et al., 2024) hides restricted requests using custom reversible encodings or pseudocode/Python decryption routines provided directly inside the prompt. Capable coding and reasoning models execute the embedded decoding logic internally before intent-matching safety filters recognize the true request.
Technique dossier overview
- Category
- Prompt and context integrity
- Severity
- High
- Attack surface
- LLM / Prompt Layer
- Platforms
- Generative AI
- Tactics
- Defense Evasion, Privilege Escalation
- Aliases
- CodeChameleon
- Catalog entry modified
- Earliest cited research
- · CodeChameleon: Personalized Encryption Framework for Jailbreaking Large Language Models · arXiv (author preprint; peer-review status not inferred)
How the mechanism works
- An adversary encodes a restricted query using a custom mapping (binary trees, string reversals, custom ciphers, or Python dictionary lookups).
- The prompt provides the model with an explicit decryption function or pseudocode specification and instructs it to decode and fulfill the hidden task silently.
- Input safety classifiers see only harmless code structures and opaque arrays, while the target LLM reconstructs and answers the underlying query.
Detection & telemetry signals
- Prompts combining custom inline decoding functions (`decrypt`, `reverse_tree`, cipher maps) with explicit instructions not to echo the decoded request.
- Obfuscated string arrays, base-N encodings, or programmatic character-assembly blocks paired with open-ended execution prompts.
- Output safety classifiers flagging prohibited content generated from prompts whose raw input score appeared benign.
- Elevated failure rates on ciphered or programmatic-encoding red-team tests relative to plaintext equivalents.
Architectural defensive countermeasures
- Rely strongly on semantic output classifiers (`AML.M0020`) and downstream output validation (`AML.M0033`), since plaintext intent only materializes inside model reasoning or final output.
- Train safety-alignment models explicitly on encoded, ciphered, and programmatic-obfuscation tasks (`AML.M0022`) so models refuse to decode and fulfill unsafe instructions.
- Flag and inspect prompts combining custom decryption code stubs with obfuscated string literals before serving high-risk capabilities.
- Continuously test models against CodeChameleon-style cipher transformations prior to shipping new reasoning upgrades (`AML.M0008`).
Framework crosswalk (OWASP LLM Top 10 & NIST AI RMF)
- OWASP LLM Top 10 (2025)
- OWASP rationale
- Programmatic cipher smuggling bypasses ingress filters as obfuscated Prompt Injection (LLM01) and risks unsafe decoded output generation (LLM05).
- NIST AI RMF functions
- NIST AI RMF guidance
- Benchmark reasoning models against ciphered/code-wrapped intent obfuscation under MEASURE, and enforce strong output-side inspection and validation under MANAGE.
Mapped defensive controls
- Validate AI Model AML.M0008
Run independent pre-release and post-fine-tuning assurance suites covering safety regressions, backdoor activation, alignment drift, and privacy leakage before promotion.
- Generative AI Guardrails AML.M0020
Deploy layered input and output classifiers, constitutional/topic rails, and structural validators with measured benign over-refusal rates—never relying on classifiers as the sole authorization boundary.
- Generative AI Guidelines AML.M0021
Codify explicit acceptable-use rules, prompt policy hierarchies, and refusal rubrics to steer model alignment and user expectations, recognizing text guidelines alone cannot stop attacks.
- Generative AI Model Alignment AML.M0022
Harden model weights via SFT, RLHF/DPO, deliberative alignment, and instruction-hierarchy training across base and fine-tuned revisions while monitoring residual safety drift.
- Input and Output Validation for AI Agent Components AML.M0033
Validate structured JSON schemas, types, bounds, and safety policies at every handoff between users, retrievers, LLMs, and downstream tools/renderers.
Related technique records
Documented incidents & exercises (2)
- CodeChameleon Encrypted Query & Decryption Reformulation Study OBS.EX0010 · Exercise · Feb 26, 2024 · Code-Capable Aligned LLMs · Obfuscated Code-Completion Bypass
Lv et al. (2024) hypothesized that LLM safety operates via sequential intent recognition before generation and tested CodeChameleon across seven LLMs by encoding queries inside custom decryption routines formatted as code-completion tasks. By delegating decoding to in-context…
- EquaCode Combined Equation & Code-Completion Jailbreak Study OBS.EX0035 · Exercise · Dec 29, 2025 · GPT Series & Frontier LLMs · Cross-Domain Mathematical & Code Reformulation
Liang et al. (2025) evaluated EquaCode, a single-query cross-domain jailbreak strategy that translates restricted intent into mathematical equation-solving and code-completion tasks to divert model attention away from safety checks. Experimental evaluation achieved a 91.19%…
Source citation records
- CodeChameleon: Personalized Encryption Framework for Jailbreaking Large Language Models · arXiv (author preprint; peer-review status not inferred) ·
Common questions
- What is LLM Jailbreak: CodeChameleon (published research family) (ATO.T6236E94A)?
- CodeChameleon (Lv et al., 2024) hides restricted requests using custom reversible encodings or pseudocode/Python decryption routines provided directly inside the prompt. Capable coding and reasoning models execute the embedded decoding logic internally before intent-matching safety filters recognize the true request.
- How do you mitigate LLM Jailbreak: CodeChameleon (published research family)?
- MITRE ATLAS maps 5 mitigations to ATO.T6236E94A: Validate AI Model, Generative AI Guardrails, Generative AI Guidelines, Generative AI Model Alignment, and Input and Output Validation for AI Agent Components. Rely strongly on semantic output classifiers (`AML.M0020`) and downstream output validation (`AML.M0033`), since plaintext intent only materializes inside model reasoning or final output.