Skip to content
XSS Disclosed report Beginner CVE-2022-29548

Reflected XSS on Amazon EC2 Instance

A reflected cross-site scripting flaw existed in the errorCode parameter of an Amazon EC2 page, where input was echoed back without validation or sanitisation. An attacker could run arbitrary JavaScript in the context of the vulnerable page, potentially reaching sensitive data.

perigou Follow

Originally disclosed on HackerOne

High 7.2 View original
  • Disclosed after 2 months

Product: Amazon Elastic Compute Cloud (Amazon EC2)

Vulnerability Type: Reflected Cross-Site Scripting (XSS)

CVE: CVE-2022-29548 Severity: Medium

Description: A reflected XSS vulnerability was discovered on the Amazon EC2 instance, allowing an attacker to inject malicious JavaScript code, potentially leading to unauthorized access to sensitive data or system compromise. Proof of Concept:

URL: ███████);alert(document.domain)//

Impact

The payload is injected into the errorCode parameter, which is reflected back to the user without proper validation or sanitization. This allows an attacker to execute arbitrary JavaScript code in the context of the vulnerable page

The original report as published on HackerOne, by perigou. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The target is Amazon Elastic Compute Cloud (Amazon EC2), and the vulnerability class is reflected cross-site scripting. The report records the CVE as CVE-2022-29548 and rates the severity as Medium, while the platform entry for the disclosure lists it as high with a CVSS score of 7.2. The report was disclosed on 24 December 2024 under the AWS VDP on HackerOne. No bounty is recorded.

The researcher's description is brief: a reflected XSS vulnerability was found on the Amazon EC2 instance, allowing an attacker to inject malicious JavaScript that could lead to unauthorised access to sensitive data or system compromise.

The proof of concept is a single URL, with the host portion redacted in the published text:

Text
███████);alert(document.domain)//

The report states that the payload is injected into the errorCode parameter, which is reflected back to the user without proper validation or sanitisation. That reflection is what allows an attacker to execute arbitrary JavaScript in the context of the vulnerable page.

The report does not describe the request method, the surrounding page, the response body, or any reproduction steps beyond the URL. It also does not describe a fix or a timeline. What it gives is the parameter name, the payload shape and the reflection behaviour.

Root cause

The report says the value of the errorCode parameter is reflected back to the user without proper validation or sanitisation. The payload in the report closes whatever quoting or markup context the value is placed in, then runs alert(document.domain) and comments out the remainder with //. The report does not say where in the page the value is reflected. The report itself only says the value is reflected without validation or sanitisation.

Impact

The report's own framing is that an attacker could execute arbitrary JavaScript in the context of the vulnerable page, potentially leading to unauthorised access to sensitive data or system compromise. Those are the report's hedges, and they are the right ones: reflected XSS runs in the victim's browser session against the origin that served the page, so what an attacker can actually reach depends on what that origin holds, such as session state, tokens readable from the page, or actions the user can perform. The report does not demonstrate any of that beyond the alert(document.domain) proof.

How this kind of bug works

Reflected XSS happens when input from a request is echoed into a response and the browser parses part of that input as markup or script. The server treats the value as data, but the browser treats it as code because the output context was not accounted for. The three contexts that matter most are HTML body, HTML attribute values, and JavaScript. Each needs different encoding: HTML entity encoding for body text, attribute encoding plus quoting for attributes, and JavaScript string escaping (or safer, passing data through a JSON endpoint and setting it with DOM APIs) for script blocks. A payload that works in one context usually fails in another, which is why the exact placement of the reflection determines the exploit.

The defence is output encoding applied at the point of rendering, matched to context, ideally through a templating engine that escapes by default. Input validation helps but is not sufficient on its own. A Content Security Policy that disallows inline script reduces the damage of a missed encoding bug but does not fix it. The HttpOnly flag on session cookies limits what script can steal, though it does not stop script from acting as the user.

How to test for it

  1. Map every parameter that ends up in a response: query strings, path segments, form fields, headers that get echoed (referer, user agent, custom headers), and error or status parameters such as the one in this report.
  2. Send a unique, harmless marker value in each parameter and search the response body for it. Note the exact surrounding bytes: is the marker inside a tag, inside a quoted attribute, inside a script block, inside a comment?
  3. Craft a probe for that context. For HTML body, a tag that would be visible if interpreted. For attributes, a value that breaks out of the quotes. For script, a string terminator plus a simple expression. Keep probes non-destructive.
  4. Confirm execution in a real browser rather than trusting string matching. A reflected < character is not XSS if it is entity-encoded; a reflected payload is not XSS if a filter or CSP blocks it.
  5. Check whether the reflection is stable across requests and whether it survives URL decoding, double decoding, or parameter pollution.

Common false positives: the marker appears only inside an encoded form, the reflection lands in a context where the browser will not execute it (for example inside a <textarea> or a comment that is never closed), a WAF strips the payload but the raw reflection still shows in a proxy, or the page is served with a CSP that blocks inline script. Always verify in the browser with the policy in place.

How it is fixed

Apply context-aware output encoding to every reflected value, using a templating system that escapes by default. Quote all attributes and escape their contents. Avoid building JavaScript from server-side strings; pass data as JSON and assign it through DOM APIs. Validate and whitelist expected formats where the value has a known shape, such as an error code. Add a restrictive Content Security Policy as defence in depth, and set HttpOnly and Secure on session cookies.

Hunting notes

Reflected XSS tends to hide in error paths, search pages, redirect and return-URL parameters, language and locale switches, and status or code parameters like the one here, because these are often written by hand and missed by framework-level escaping. Recon signals worth following: parameters whose names suggest codes, messages or redirects; endpoints that echo input into inline scripts; older application stacks or custom error handlers; and pages where the response differs between an encoded and a raw probe.

Explain what the script could reach in that context, without overclaiming.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 8 min read.

What happened, in plain words

This report is about a security flaw in Amazon Elastic Compute Cloud, usually shortened to Amazon EC2. EC2 is Amazon Web Services' service for renting virtual servers in the cloud: instead of buying a machine, you start one on demand and run your software on it. The report was filed under the AWS vulnerability disclosure programme on HackerOne, a platform where researchers report bugs to companies. It was disclosed on 24 December 2024. The report itself rates the severity as Medium, while the platform entry lists it as high with a CVSS score of 7.2. No bounty is recorded.

The flaw is a reflected cross-site scripting bug, or reflected XSS. To understand the name, start with what a web page actually is. When you type an address into your browser, the browser sends a request to a server, and the server sends back a response, usually a chunk of HTML, the language that describes a page's structure and content. The browser reads that HTML and draws the page. If a server ever copies text from your request straight into the HTML it sends back, then whoever controls that text controls part of the page. Normally that is harmless, because the browser treats the copied text as plain words. But if the text contains characters that HTML interprets as instructions, the browser will follow those instructions instead of showing them. That is XSS: making a site deliver someone else's code to a visitor's browser.

"Reflected" means the value travels in with one request and bounces straight back in the response, without being stored on the server. Think of a shop assistant who repeats your name back to you; if you say something rude, the assistant is the one who says it out loud. The site becomes the messenger for the attacker's content.

The report records the CVE as CVE-2022-29548. A CVE is a public catalogue number given to a known vulnerability so people can refer to it unambiguously.

The researcher's description is short: a reflected XSS vulnerability was found on the Amazon EC2 instance, allowing an attacker to inject malicious JavaScript, the programming language browsers run, potentially leading to unauthorised access to sensitive data or system compromise.

The proof of concept is a single URL, with the host portion redacted in the published text:

Text
███████);alert(document.domain)//

Reading it piece by piece:

  • The redacted part is the address of the page.
  • ); closes whatever bracket or quoting the site had opened around the value.
  • alert(document.domain) is the payload. alert makes the browser pop up a dialog box, and document.domain is the current site's address. The dialog proves that code supplied by the attacker is running, and running as that site.
  • // starts a comment in JavaScript, so anything after it on that line is ignored.

The report states that the payload is injected into the errorCode parameter. A parameter is a named value attached to a URL, the part after a question mark, used to pass information such as a search term or an error identifier. The site takes the value of errorCode and reflects it back to the user without proper validation or sanitisation. Validation means checking that a value looks like what it should be; sanitisation means cleaning it so dangerous characters cannot act as code. Because neither happens, the browser executes the injected JavaScript in the context of the vulnerable page, meaning with the same permissions and access as the page itself.

Why does that matter? When you are logged in to a site, your browser holds a cookie, a small piece of data the site gave you to remember who you are, much like a wristband at an event. Any script running on that site's page can act as you: read what the page can read and do what you could do. The report's own wording is careful here, saying the flaw could potentially lead to unauthorised access to sensitive data or system compromise. It does not demonstrate anything beyond the pop-up.

The report does not describe the request method, the surrounding page, the response body, or reproduction steps beyond the URL, and it does not describe a fix or a timeline. What it gives is the parameter name, the shape of the payload and the fact that the value is reflected.

In general, how this kind of bug works

Reflected XSS happens when input from a request is echoed into a response and the browser parses part of that input as markup or script. The server treats the value as data, but the browser treats it as code because the place the value lands was not accounted for. Three contexts matter most: the HTML body, attribute values inside tags, and JavaScript blocks. Each needs different encoding, meaning different rules for turning special characters into harmless text. A payload that works in one context usually fails in another, which is why the exact position of the reflection decides whether there is a bug.

The defence is output encoding applied where the page is rendered, matched to context, ideally through a templating engine that escapes by default. Input validation helps but is not enough alone. A Content Security Policy, a header that tells the browser which sources of script to allow, reduces the damage of a missed encoding bug but does not fix it. The HttpOnly flag on session cookies limits what script can steal, though it does not stop script from acting as the user.

To test for it:

  1. Map every parameter that ends up in a response: query strings, path segments, form fields, echoed headers, and error or status parameters such as the one in this report.
  2. Send a unique, harmless marker in each parameter and search the response for it. Note the exact surrounding bytes: inside a tag, inside a quoted attribute, inside a script block, inside a comment?
  3. Craft a probe for that context. For the HTML body, a tag that would be visible if interpreted. For attributes, a value that breaks out of the quotes. For script, a string terminator plus a simple expression. Keep probes non-destructive.
  4. Confirm execution in a real browser rather than trusting string matching. A reflected < is not XSS if it is entity-encoded, and a reflected payload is not XSS if a filter or policy blocks it.
  5. Check whether the reflection is stable across requests and whether it survives URL decoding, double decoding, or parameter pollution.

Common false positives: the marker appears only in encoded form; the reflection lands where the browser will not execute it, such as inside a <textarea> or an unclosed comment; a web application firewall strips the payload while the raw reflection still shows in a proxy; or the page is served with a policy that blocks inline script. Always verify in the browser with the policy in place.

How it is fixed: apply context-aware output encoding to every reflected value, using a templating system that escapes by default. Quote all attributes and escape their contents. Avoid building JavaScript from server-side strings; pass data as JSON and assign it through DOM APIs. Validate and whitelist expected formats where the value has a known shape, such as an error code. Add a restrictive Content Security Policy as defence in depth, and set HttpOnly and Secure on session cookies.

Where it tends to hide: error paths, search pages, redirect and return-URL parameters, language and locale switches, and status or code parameters like the one here, because these are often written by hand and missed by framework-level escaping. Signals worth following are parameter names suggesting codes, messages or redirects; endpoints that echo input into inline scripts; older stacks or custom error handlers; and pages whose response differs between an encoded and a raw probe.

Explain what the script could reach there, without overclaiming.

Glossary

  • Amazon EC2: Amazon Web Services' service for renting virtual servers in the cloud.
  • AWS VDP: Amazon Web Services' vulnerability disclosure programme, the channel for reporting security bugs to AWS.
  • HackerOne: A platform where security researchers report vulnerabilities to companies.
  • CVE: A public catalogue number assigned to a known vulnerability.
  • CVSS: A standard scoring system for rating the severity of a vulnerability.
  • Reflected XSS: Cross-site scripting where input from a request is echoed straight back in the response and executed by the browser.
  • XSS: Cross-site scripting, a flaw that lets an attacker's code run in another user's browser on a site's page.
  • JavaScript: The programming language browsers execute to make pages interactive.
  • HTML: The language that describes the structure and content of a web page.
  • Request: The message a browser sends to a server asking for a page or data.
  • Response: The message a server sends back, usually containing HTML.
  • Parameter: A named value attached to a URL, such as a search term or error code.
  • Payload: The piece of code an attacker wants the victim's browser to run.
  • Validation: Checking that a value matches the expected format.
  • Sanitisation: Cleaning a value so dangerous characters cannot act as code.
  • Output encoding: Converting special characters into harmless text for the context where they are placed.
  • Context: The place in a page where a value lands, such as body text, an attribute or a script block.
  • Cookie: A small piece of data a site stores in your browser to remember who you are.
  • HttpOnly: A cookie flag that stops JavaScript from reading the cookie.
  • Secure: A cookie flag that sends the cookie only over encrypted connections.
  • Content Security Policy: A response header that tells the browser which sources of script are allowed.
  • Web application firewall: A filter placed in front of a site that blocks suspicious requests.
  • False positive: A finding that looks like a bug but is not exploitable.
  • DOM API: Browser functions that let script read and change a page's structure.

More by perigou

View all

1 more disclosed report, best first.

More from AWS VDP

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.