# Unit 42: LLMs obfuscating malicious JavaScript

- ID: unit42-llm-js-obfuscation-2024
- Reported: 2024-05-01
- Researcher: Unit 42
- Organization: Palo Alto Networks Unit 42
- AI role: llm_generated_malware (LLM-generated malware)
- Confidence in AI involvement: not assessed
- Research / borderline: true
- Last reviewed: 2026-10-20
- Entry page: https://openattacks.ai/attacks/unit42-llm-js-obfuscation-2024/
- Entry JSON: https://openattacks.ai/api/attacks/unit42-llm-js-obfuscation-2024.json
- Browse title: Unit 42: LLMs obfuscate malicious JavaScript
- Editorial summary: Research showed LLMs can effectively rewrite existing malicious JavaScript to evade detection, though writing full malware from scratch was less practical at the time.
- Evidence class (catalog annotation): Research demonstration
- Source-stated target environments: Not specified
- Stage hunts and conditional defenses: https://openattacks.ai/api/defenses/unit42-llm-js-obfuscation-2024.json

## Evidence qualification
Research demonstration of LLM obfuscation efficacy; not a single named campaign.

## Technique
Showed LLMs can effectively rewrite and obfuscate existing malicious JavaScript to evade detection, while finding fully AI-written malware from scratch less practical at the time.

## Stack relevance (editorial)
Assessment: attacker\_tool\_only. Editorial applicability reviewed against the catalog source account; not a scan or independent incident verification.
The named AI product is used by the attacker. No reviewed mapping from owning that product to the reported victim conditions is available.
A product mention alone is not a victim-side applicability mapping. Selection does not verify affected versions, permissions or compromise.

## Initial access
unknown

## AI tooling and models
- Commercial LLMs

## Other tooling
- unknown

## Victims and sectors
unknown

## Target geography
- unknown

## Attribution
unknown

## Scale and metrics
unknown

## Attack flow
Catalog reconstruction of the supplied source account. Unknowns and research caveats are preserved.
### step-1: Researchers provide malicious JavaScript [access]
The experiment starts with existing code rather than an observed delivery campaign.
Evidence: https://unit42.paloaltonetworks.com/using-llms-obfuscate-malicious-javascript/

### step-2: LLMs rewrite and obfuscate the code [ai]
Model output changes the script while retaining malicious behavior.
Evidence: https://unit42.paloaltonetworks.com/using-llms-obfuscate-malicious-javascript/

### step-3: Researchers test detection outcomes [execution]
The study compares detection before and after rewriting.
Evidence: https://unit42.paloaltonetworks.com/using-llms-obfuscate-malicious-javascript/

### step-4: Demo measures evasion [impact]
The finding concerns obfuscation efficacy, not a separate confirmed victim intrusion.
Evidence: https://unit42.paloaltonetworks.com/using-llms-obfuscate-malicious-javascript/

Connections:
- step-1 -> step-2
- step-2 -> step-3
- step-3 -> step-4

## Stage defense and hunting recommendations
Editorial recommendations, not validated coverage. Source-controlled query starters are drafts. Custom-schema examples require telemetry collection and field mapping; absence of a mapping means not assessed. MagicSword policy opportunities require managed Windows scope and enforcement.
### step-1: Independent malware-analysis validation
- Visibility: Review / research workflow
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/analysis-review.sigma.yml
- KQL query download: /api/detections/analysis-review.kql
- SPL query download: /api/detections/analysis-review.spl
- Hunt hypothesis: Instructions inside a sample influence an LLM analysis result, or obfuscation changes a model's classification without changing malicious behavior.
- Required telemetry: Sample hashes and static / dynamic analysis results; Model verdicts with prompt provenance; Independent analyst and deterministic scanner verdicts
- Investigate: Compare model conclusions with independent behavioral evidence and a controlled evaluation set.
- Investigate: Treat sample comments as data; measure disagreement and false negatives without following embedded instructions.
- Limitation: This evaluates analysis robustness, not victim endpoint compromise. Side behaviors mentioned elsewhere in a report do not establish edges in this flow.
- Qualification: Preserve sample hashes and independent behavior labels before the model transformation; this is a research workflow.
- No direct MagicSword prevention claim is recorded for this stage.

### step-2: Independent malware-analysis validation
- Visibility: Review / research workflow
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/analysis-review.sigma.yml
- KQL query download: /api/detections/analysis-review.kql
- SPL query download: /api/detections/analysis-review.spl
- Hunt hypothesis: Instructions inside a sample influence an LLM analysis result, or obfuscation changes a model's classification without changing malicious behavior.
- Required telemetry: Sample hashes and static / dynamic analysis results; Model verdicts with prompt provenance; Independent analyst and deterministic scanner verdicts
- Investigate: Compare model conclusions with independent behavioral evidence and a controlled evaluation set.
- Investigate: Treat sample comments as data; measure disagreement and false negatives without following embedded instructions.
- Limitation: This evaluates analysis robustness, not victim endpoint compromise. Side behaviors mentioned elsewhere in a report do not establish edges in this flow.
- No direct MagicSword prevention claim is recorded for this stage.

### step-3: Independent malware-analysis validation
- Visibility: Review / research workflow
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/analysis-review.sigma.yml
- KQL query download: /api/detections/analysis-review.kql
- SPL query download: /api/detections/analysis-review.spl
- Hunt hypothesis: Instructions inside a sample influence an LLM analysis result, or obfuscation changes a model's classification without changing malicious behavior.
- Required telemetry: Sample hashes and static / dynamic analysis results; Model verdicts with prompt provenance; Independent analyst and deterministic scanner verdicts
- Investigate: Compare model conclusions with independent behavioral evidence and a controlled evaluation set.
- Investigate: Treat sample comments as data; measure disagreement and false negatives without following embedded instructions.
- Limitation: This evaluates analysis robustness, not victim endpoint compromise. Side behaviors mentioned elsewhere in a report do not establish edges in this flow.
- No direct MagicSword prevention claim is recorded for this stage.

### step-4: Independent malware-analysis validation
- Visibility: Review / research workflow
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/analysis-review.sigma.yml
- KQL query download: /api/detections/analysis-review.kql
- SPL query download: /api/detections/analysis-review.spl
- Hunt hypothesis: Instructions inside a sample influence an LLM analysis result, or obfuscation changes a model's classification without changing malicious behavior.
- Required telemetry: Sample hashes and static / dynamic analysis results; Model verdicts with prompt provenance; Independent analyst and deterministic scanner verdicts
- Investigate: Compare model conclusions with independent behavioral evidence and a controlled evaluation set.
- Investigate: Treat sample comments as data; measure disagreement and false negatives without following embedded instructions.
- Limitation: This evaluates analysis robustness, not victim endpoint compromise. Side behaviors mentioned elsewhere in a report do not establish edges in this flow.
- Qualification: Compare model/scanner verdicts with known behavior on the evaluated set; this does not establish a separate victim intrusion.
- No direct MagicSword prevention claim is recorded for this stage.


## MITRE ATLAS
Mappings are catalog annotations based on described behavior, not assignments or endorsements by MITRE.
- AML.T0016.002: Generative AI — The supplied source explicitly describes generative-model tooling assisting the reported activity; this mapping does not establish additional autonomy or victim impact.
  Technique: https://atlas.mitre.org/techniques/AML.T0016.002
  Evidence: https://unit42.paloaltonetworks.com/using-llms-obfuscate-malicious-javascript/

## Defensive notes
Behavioral JS detections over static signatures

## Sources
- https://unit42.paloaltonetworks.com/using-llms-obfuscate-malicious-javascript/
