Reflected XSS in trek.nasa.gov TrekWS /rest/light endpoint via unescaped et (date) parameter
A date parameter on the TrekWS light configuration endpoint was reflected into an HTML error response without output encoding. A crafted URL could therefore run JavaScript in the trek.nasa.gov origin when a victim opened it.
Originally disclosed on Bugcrowd
- Accepted in 2 days
- Fixed in 24 days
- Disclosed after 28 days
Summary by itz_madhusankha
Reflected Cross-Site Scripting (XSS) in NASA TrekWS
Researcher: Madhusankha Nayanajith
Affected service: NASA Trek Web Services (TrekWS)
Affected host: trek.nasa.gov
Vulnerability type: Reflected Cross-Site Scripting (XSS)
Severity: P3
Status: Resolved
Summary
During authorized security research under the NASA Vulnerability Disclosure Program, I identified a reflected Cross-Site Scripting (XSS) vulnerability in the TrekWS light configuration endpoint hosted on trek.nasa.gov.
The issue occurred when attacker-controlled input supplied through date parameters was reflected into an HTML error response without appropriate output encoding. Under the affected response conditions, a specially crafted request could cause JavaScript to execute in the context of the trek.nasa.gov origin when a victim opened the crafted URL in a browser.
Potential Impact
Depending on the victim's access and the application's security controls, successful exploitation could allow an attacker to perform actions within the affected web origin, access information available to the injected script, or present deceptive content through a trusted NASA subdomain.
Remediation
Recommended mitigations included context-appropriate output encoding, strict validation of date parameters, consistent use of a non-HTML content type for API error responses, and appropriate browser security headers.
Disclosure Status
The vulnerability was reported through Bugcrowd, reviewed by the platform, and subsequently marked as Resolved.
This summary documents the finding for responsible disclosure and defensive security awareness.
Context
NASA Trek Web Services (TrekWS) is a web service hosted on trek.nasa.gov. Among its functions is a light configuration endpoint under the /rest/light path, which takes date parameters and returns configuration data. When a request is malformed, the service answers with an HTML error response rather than a machine-readable API error.
The finding is a reflected Cross-Site Scripting (XSS) issue in that endpoint: input supplied through the date parameters was reflected into the HTML error response without appropriate output encoding. The report was filed under the NASA Vulnerability Disclosure Program through Bugcrowd, rated P3 (medium), and marked Resolved.
Setup
The research was carried out as authorised security research under the NASA Vulnerability Disclosure Program. The only precondition the report describes is the affected response condition: the reflection appears in the HTML error response, so the crafted request has to be one that triggers that error path. No accounts, roles, tool versions or special configuration are mentioned.
Finding it
The issue involved date parameters of the /rest/light endpoint. Supplying attacker-controlled input through the date parameters caused that input to be reflected into an HTML error response without output encoding. Because the response is HTML and is served from the trek.nasa.gov origin, a crafted request could cause JavaScript to execute in that origin's context when a victim opened the crafted URL in a browser.
Either one alone would be far less interesting.
Exploitation
Step 1: Craft a request that reaches the error path with a payload in the date parameter
The report does not reproduce the exact request line, payload or response body. What it establishes is the mechanism: a specially crafted request places JavaScript in the date parameter, the service reflects it into the HTML error response, and the browser executes it in the trek.nasa.gov origin.
Step 2: Deliver the crafted URL to a victim
When a victim opens the crafted URL in a browser, the reflected script runs in the context of trek.nasa.gov. The report notes that this depends on the affected response conditions being met, that is, the request must produce the error response that carries the reflection.
Root cause
The mistake is missing context-appropriate output encoding: user-controlled input from the date parameters is written into an HTML error response as-is. The second contributing factor is that API error responses are returned with an HTML content type, so the browser parses and renders the reflected markup rather than treating it as inert data.
Impact
Depending on the victim's access and the application's security controls, successful exploitation could allow an attacker to perform actions within the affected web origin, access information available to the injected script, or present deceptive content through a trusted NASA subdomain. The report frames these as potential outcomes under those conditions rather than as demonstrated results.
Fix
The report lists the recommended mitigations, and the issue was subsequently marked Resolved:
- Context-appropriate output encoding for reflected values.
- Strict validation of date parameters.
- Consistent use of a non-HTML content type for API error responses.
- Appropriate browser security headers.
Variants to test
- Other date or time parameters on the same service: send a payload and look for it reflected unencoded in an error page.
- Other error paths on REST endpoints: malformed values that force a stack trace or validation error rendered as HTML.
- Content-type mismatches: endpoints that return
text/htmlfor what should be JSON or plain text, where any reflected value becomes live markup. - Other date parameters that feed the same handler.
A positive result is the payload appearing verbatim in an HTML response body served from the target origin, with the browser executing it.
Hunting notes
This kind of bug tends to hide in error handling rather than in the happy path: validation failures, parse errors and fallback pages are often written by different code, or with different escaping, than the main response. During recon, look for API endpoints that answer with text/html on bad input, and for parameters whose values reappear in the response. The report does not describe the recon steps that led to the endpoint, so the path from discovery to the et parameter is not documented here.
It was reviewed through Bugcrowd and marked Resolved.
What happened, in plain words
A security researcher found a bug on a NASA website called trek.nasa.gov. The site runs a service called NASA Trek Web Services, or TrekWS for short. One part of that service, the light configuration endpoint under /rest/light, takes date values and returns configuration data. When someone sends it a badly formed request, it answers with an error page written in HTML, the same language web pages are made of.
The bug is that the service copied whatever the visitor typed into the date parameter straight into that error page, without cleaning it first. If the text someone typed was actually a small piece of JavaScript (the programming language browsers run), the browser would treat it as part of the page and run it. Because the page comes from trek.nasa.gov, that script would run with the trust of that NASA address. This kind of bug is called reflected Cross-Site Scripting, or reflected XSS.
The researcher reported it through the NASA Vulnerability Disclosure Program on the Bugcrowd platform. It was rated P3, which the report describes as medium severity, and it was marked Resolved.
Context
What the product is
trek.nasa.gov is a NASA website. On it sits a web service called TrekWS. A web service (often called an API) is a way for one piece of software to talk to another over the internet, rather than a page built for a person to look at. Think of a restaurant: the dining room is the website you see, and the kitchen is the API. You do not walk into the kitchen yourself; you give an order and something comes back. Here, the order is a request with parameters, and the reply is data.
One of the service's jobs is the light configuration endpoint under the /rest/light path. A path is the part of a web address after the domain name, a bit like a folder route inside a building. This endpoint takes date parameters and returns configuration data.
What goes wrong when a request is malformed
When a request is malformed, meaning it does not follow the rules the service expects, the service answers with an HTML error response instead of a machine-readable API error. That difference matters. A machine-readable error is plain data, something like a short note saying "bad date". A browser does not draw pictures from it; it just shows text. An HTML error response is a web page, and browsers do not merely display web pages, they run them. Any script inside an HTML page is executed.
The finding
The finding is a reflected XSS issue in that endpoint. "Reflected" means the harmful input is not stored on the server for later; it bounces straight back in the reply to the same request. Input supplied through the date parameters was reflected into the HTML error response without appropriate output encoding. Output encoding is the act of converting special characters into harmless lookalikes before putting them on a page, so that < becomes something the browser displays rather than something it obeys. Without it, the browser cannot tell the difference between text the site meant to show and text an attacker supplied.
The report was filed under the NASA Vulnerability Disclosure Program through Bugcrowd, rated P3 (medium), and marked Resolved.
Setup
The research was carried out as authorised security research under the NASA Vulnerability Disclosure Program. "Authorised" is the key word: the researcher had permission to probe NASA systems within the programme's rules, which is what separates this from unauthorised intrusion.
The only precondition the report describes is the affected response condition: the reflection appears in the HTML error response, so the crafted request has to be one that triggers that error path. In everyday terms, the bug only shows itself when you knock on the door marked "error". A perfectly valid request would not display it.
No accounts, roles, tool versions or special configuration are mentioned.
Finding it
The issue involved the date parameters of the /rest/light endpoint. A parameter is a named value attached to a request, like a field on a form: the name says what it is, the value is what you filled in. Here the name is et and the value is meant to be a date.
Supplying attacker-controlled input through the date parameters caused that input to be reflected into an HTML error response without output encoding. Because the response is HTML and is served from the trek.nasa.gov origin, a crafted request could cause JavaScript to execute in that origin's context when a victim opened the crafted URL in a browser.
Two ideas in that sentence deserve unpacking for a newcomer:
- Origin: the combination of scheme, host and port that a browser uses to decide who is allowed to touch what.
https://trek.nasa.govis one origin. Scripts running on a page from that origin are treated as belonging to it, so they can read and change what that origin is allowed to read and change. That is why a bug on a trusted NASA address is more serious than the same bug on a random site. - Victim: the person who ends up opening the crafted link. The attacker does not need to break into the server; they only need someone with a browser to follow a prepared URL.
Either one alone would be far less interesting. A parameter echoed back inside plain text is just text. An HTML error page with no attacker input in it is just an error page. Put them together and the attacker's text becomes part of a page the browser will run.
Exploitation
Step 1: Craft a request that reaches the error path with a payload in the date parameter
A payload here simply means the piece of input the attacker wants the browser to run. The report does not reproduce the exact request line, payload or response body. What it establishes is the mechanism: a specially crafted request places JavaScript in the date parameter, the service reflects it into the HTML error response, and the browser executes it in the trek.nasa.gov origin.
Why take this step? Because the bug lives on the error path. The request has to be shaped so the service rejects it and produces the HTML error page, while the date value still carries the script. A valid date would be accepted and never reach the code that builds the error page.
Step 2: Deliver the crafted URL to a victim
When a victim opens the crafted URL in a browser, the reflected script runs in the context of trek.nasa.gov. The report notes that this depends on the affected response conditions being met, that is, the request must produce the error response that carries the reflection.
Why does delivery matter? Reflected XSS is not triggered by the attacker alone. The attacker prepares a link and needs someone else to click it. The click is what makes the browser send the request, receive the HTML error page, and run the script inside it as if NASA had written it.
Root cause
The mistake is missing context-appropriate output encoding: user-controlled input from the date parameters is written into an HTML error response as-is. "Context-appropriate" means the cleaning has to match the place the value lands. Text going into an HTML page needs different treatment from text going into a database query or a JavaScript string, just as a label for a glass jar needs different glue from a label for a freezer box.
The second contributing factor is that API error responses are returned with an HTML content type, so the browser parses and renders the reflected markup rather than treating it as inert data. The content type is a label the server puts on its reply telling the browser what kind of thing it is. If the label says HTML, the browser builds a page and runs scripts. If it said plain text or JSON, the browser would show the characters without acting on them.
Error handling is often written separately from the main feature, sometimes by different people or at a different time, so protections added to the normal path can be missing there.
Impact
Depending on the victim's access and the application's security controls, successful exploitation could allow an attacker to perform actions within the affected web origin, access information available to the injected script, or present deceptive content through a trusted NASA subdomain. The report frames these as potential outcomes under those conditions rather than as demonstrated results.
In plain words: a script running as trek.nasa.gov can do what that site's own scripts can do in that visitor's browser. It might act on the visitor's behalf, read what the page can read, or show fake content under a real NASA address. The report is careful to say "could" and "depending on", because the exact reach depends on what the site allows and what the visitor is logged into.
Fix
The report lists the recommended mitigations, and the issue was subsequently marked Resolved:
- Context-appropriate output encoding for reflected values.
- Strict validation of date parameters.
- Consistent use of a non-HTML content type for API error responses.
- Appropriate browser security headers.
Why each one helps:
- Encoding turns the attacker's angle brackets and quotes into harmless characters, so the browser displays them instead of obeying them.
- Validation means checking that a date really looks like a date before using it. If the value must match a strict date format, there is no room left for a script.
- A non-HTML content type tells the browser "this is data, not a page", so even a reflected value is not executed.
- Browser security headers are instructions the server sends alongside a page that restrict what the browser will run or load. They act as a second line of defence when something slips through.
Variants to test
These are the neighbouring places where the same kind of mistake might appear:
- Other date or time parameters on the same service: send a payload and look for it reflected unencoded in an error page.
- Other error paths on REST endpoints: malformed values that force a stack trace or validation error rendered as HTML.
- Content-type mismatches: endpoints that return
text/htmlfor what should be JSON or plain text, where any reflected value becomes live markup. - Other date parameters that feed the same handler.
A positive result is the payload appearing verbatim in an HTML response body served from the target origin, with the browser executing it. "Verbatim" means unchanged, character for character, which is exactly what you do not want to see.
Hunting notes
This kind of bug tends to hide in error handling rather than in the happy path. The happy path is the normal, successful use of a feature: a correct date, a correct reply. Validation failures, parse errors and fallback pages are often written by different code, or with different escaping, than the main response, so they can miss protections the main response has.
During recon, look for API endpoints that answer with text/html on bad input, and for parameters whose values reappear in the response. Recon, short for reconnaissance, is the mapping stage: finding out what endpoints exist and how they behave before trying anything clever.
The report does not describe the recon steps that led to the endpoint, so the path from discovery to the et parameter is not documented here.
It was reviewed through Bugcrowd and marked Resolved.
Glossary
-
API: a way for software to talk to software over the internet, returning data rather than a page built for a person to read.
-
Authorised security research: testing done with permission, here under the NASA Vulnerability Disclosure Program, within its rules.
-
Bugcrowd: the platform through which the report was filed and reviewed.
-
Content type: a label on a server's reply saying what kind of thing it is, such as HTML, JSON or plain text, which decides how the browser treats it.
-
Context-appropriate output encoding: cleaning a value in a way that matches where it will be placed, so special characters are displayed rather than obeyed.
-
Crafted request / crafted URL: a request or link deliberately built to trigger a specific behaviour, here the error path carrying a payload.
-
Endpoint: a specific address inside a service that performs one job, such as
/rest/light. -
Error path: the code that runs when a request is rejected or fails, as opposed to the normal successful path.
-
Happy path: the normal, successful use of a feature, with valid input.
-
HTML: the language web pages are written in; browsers render it and run any scripts inside it.
-
HTML error response: an error reply formatted as a web page, which a browser will render and execute rather than treat as inert data.
-
JavaScript: the programming language browsers run inside web pages.
-
JSON: a plain data format commonly used by APIs, which browsers display rather than execute.
-
Malformed request: a request that does not follow the rules the service expects.
-
Origin: the scheme, host and port combination a browser uses to decide what a page and its scripts may access;
https://trek.nasa.govis one origin. -
Output encoding: converting special characters into harmless equivalents before placing them on a page.
-
P3: the priority rating given to this report, described in it as medium severity.
-
Parameter: a named value attached to a request, such as
etwith a date as its value. -
Payload: the piece of input an attacker wants the browser to run.
-
Recon: reconnaissance, the mapping stage of finding endpoints and observing how they behave.
-
Reflected XSS: Cross-Site Scripting where the harmful input bounces straight back in the reply to the same request instead of being stored.
-
REST endpoint: a web service address following the common REST style, where paths and parameters describe the request.
-
Security headers: instructions sent with a response that restrict what the browser will run or load.
-
Stack trace: a technical error listing showing internal details of how the code failed.
-
TrekWS: NASA Trek Web Services, the service hosted on
trek.nasa.gov. -
Validation: checking that input matches the expected format before using it.
-
Verbatim: unchanged, character for character.
-
Victim: the person who opens the crafted link in a browser and whose browser runs the reflected script.
-
Vulnerability Disclosure Program: a programme through which outsiders can report security issues to an organisation under agreed rules.
-
XSS (Cross-Site Scripting): a bug where attacker-supplied input ends up being run as script by a victim's browser in the context of a trusted site.