Attack Simulation & Response

Red TeamEnd-to-end simulation using real adversary tradecraft Blue TeamThreat hunting, monitoring and incident response Purple TeamGrow your offensive and defensive teams together Ransomware Response24/7 emergency response for encrypted systems

Security Testing

Penetration TestingFinding flaws in web, network and mobile applications Enterprise Penetration TestingRegulation-aligned testing for finance and large enterprises Vulnerability ScanningContinuous scanning, prioritised with CVSS
A free scoping call tailored to your organisation.
All services Get a quote

Forensic Threat Hunting

PotreX VestigeHidden threat scanning across disk, memory and forensic traces

Threat Intelligence

PotreX ArgosDark web and leak-focused threat intelligence

Penetration Testing

PotreX BallistaEnterprise penetration testing platform with finding management
Every product can be deployed on-premises or in the cloud.
All products Request a demo
Services
Products
Blog Contact Us Sign In
Home / Blog / CVE-2023-4966
Threat Research

Citrix Bleed: From a Memory Leak to Session Takeover

Summary

On Citrix NetScaler ADC and Gateway, sending an over-long Host header to a specific endpoint makes the response run past the bounds of its buffer and return adjacent memory as well.

Those memory fragments frequently contain the session cookies of users who are currently logged in. With a stolen cookie the attacker takes over the session directly — no password, no MFA prompt. In 2023 this became the initial access method of choice for several ransomware operations.

Method note

The check below detects the leak through a size anomaly without storing the leaked content. Because the leaked bytes contain live credentials, test output must never be kept.

Advisory details

CVECVE-2023-4966 (Citrix Bleed)
ComponentNetScaler ADC / NetScaler Gateway — OpenID configuration endpoint
ClassCWE-119 · Out-of-bounds read (memory disclosure)
SeverityCRITICAL · CVSS 9.4
Affected versions13.0 / 13.1 / 14.1 builds released before October 2023
PrerequisiteThe appliance configured as a Gateway or AAA virtual server

Root cause: a copy without a length check

While building the response, a field taken from the request is written into a fixed-size buffer without validating its length, and the response length is calculated from that value. The reply therefore ships whatever stale data was left in the buffer.

Because that region neighbours the memory used for authentication, the practical content of the leak is valid session tokens.

Exposure check

Start by reading the build number.

analyst@ubuntu: ~/labs/netscaler –□✕
analyst@ubuntu:~/labs/netscaler$ ssh nsroot@gw.lab.local 'show version' | head -n 2
NetScaler NS13.1: Build 49.13.nc, Date: Jun 15 2023

#  below 13.1-49.15 — affected build

Figure 1 — Reading the appliance build number

Next, measure the size of the response to an over-long Host header. A patched appliance returns a small, fixed response; an affected one returns far more.

analyst@ubuntu: ~/labs/netscaler –□✕
analyst@ubuntu:~/labs/netscaler$ curl -sk -o /dev/null -w 'response size: %{size_download} bytes\n' -H "Host: $(python3 -c 'print("a"*8000)')" https://gw.lab.local/oauth/idp/.well-known/openid-configuration
response size: 63218 bytes

#  expected ~1 KB; the rest is adjacent memory
#  content was not stored, only the size was measured

Figure 2 — Detecting the leak through a response size anomaly

Impact

A leaked session token can be replayed with all of that user's privileges. The attacker never knows the password and never answers the MFA challenge, so classic “failed login” alerting stays silent.

Remediation: patching alone is not enough

The step most often missed is terminating existing sessions after patching. Tokens stolen before the patch remain valid afterwards.

analyst@ubuntu: ~/labs/netscaler –□✕
analyst@ubuntu:~/labs/netscaler$ ssh nsroot@gw.lab.local 'kill aaa session -all; kill icaconnection -all; show version' | head -n 2
Done
NetScaler NS13.1: Build 49.15.nc, Date: Oct 10 2023

#  all active sessions terminated, build current

Figure 3 — Terminating every session after the patch

  • Apply the patch, then kill all AAA and ICA sessions.
  • Review VPN session records from before the patch for the same account logging in from different countries at the same time.
  • Remove the management interface from the internet wherever possible.

Log hunting

analyst@ubuntu: /var/log/netscaler –□✕
analyst@ubuntu:/var/log/netscaler$ grep -hoE 'LOGIN .*Source [0-9.]+' ns.log* | awk '{print $NF}' | sort | uniq -c | sort -rn | head -n 4
    128 185.220.1xx.44
     31 45.148.1xx.9
     12 10.20.5.17

#  one account, three countries — takeover suspected

Figure 4 — Anomalous source distribution in session records

Conclusion

Citrix Bleed shows that memory safety bugs do not only cause crashes — they produce identity theft. Remote access appliances need discipline on two fronts: patching and session management. Invalidating sessions after every critical patch should be a standard step.

Sources

Test it in your own environment

We test your remote access and VPN estate, including session hijacking scenarios.

Call now · 0850 551 01 01 WhatsApp · Send a message Email · info@potrex.com