Exploit Feature To Get High Bug impact
A paid private-messaging feature counted messages incorrectly when the message body contained HTML tags that Cloudflare stripped, so the sender's message balance was not reduced. An attacker could therefore keep sending messages to streamers for free after buying the first batch.
Published on 0xm5awy.medium.com
Bug Bounty
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.
Context
This write-up is about a platform that lets users send private messages to streamers. The feature is paid: a user buys private messages with tokens, and each message sent is supposed to consume one of the purchased messages. If a user buys 10 messages, they can send 10 messages, and after that they must buy more to keep talking to the streamer.
The platform also has the usual user-generated content surfaces, such as posts, comments and search, which is where most people start when hunting for cross-site scripting. The researcher's interest was in what happens to input that contains angle brackets, and then in how that interacts with the paid messaging feature.
Setup
The report does not name the target, the program or any versions. The only precondition described is a normal user account with enough tokens to buy private messages, plus a streamer account to message. The researcher bought private messages in order to be able to message the streamer, and started with a balance of 10 messages.
Finding it
The starting point was the standard XSS attempt. On features such as post, comment and search, the researcher tried to put the following payload into the fields:
<script>alert(1)</script>
Every attempt returned a Forbidden Error 403. Looking into how Cloudflare works, the researcher concluded that it deletes anything containing <> and leaves only the content, so the payload above would arrive as:
alert(1)
That raised the question of what would happen if this behaviour were used against the platform itself, in a feature where the content of a message has a cost attached to it.
Exploitation
Step 1: confirm normal message accounting
After buying private messages, the researcher sent a normal message to the streamer to establish the baseline:
hello Streamer
Before sending it the account had 10 messages; after sending it the account had 9. The deduction worked as expected for ordinary text.
Step 2: send a message containing a script tag
Next, the researcher sent a message containing a script tag around the text:
<script>alert(1)</script>
The expectation was that the platform would strip <script></script> and leave alert(1), the same way the Cloudflare filtering behaved on the other features. What actually happened was that the message was not deducted from the number of purchased messages.
Step 3: combine the tag with real message text
To see the effect on a message that still reads normally to the recipient, the researcher sent:
<script>"Hello Streamer"</script>
The result was the same: the remaining message count did not go down, the message was delivered with the text "Hello Streamer", and the balance stayed at 9.
Attack workflow
- The attacker buys private messages to talk to their streamer account.
- The attacker sends a message to the streamer account with
<script>"The Message"</script>. - The streamer receives the message "The Message".
- The attacker does not lose the message they bought, and can now use the feature for free to talk to any streamer, needing only to buy the first 10 messages.
Root cause
The report does not describe the server-side code, so the exact mistake is not shown. What the behaviour shows is that the message content is filtered or rewritten, with the tags removed and the inner text surviving, and that when the input contains <> the deduction does not happen while the message is still sent. When the input contains <>, the deduction does not happen, while the message is still sent. The Cloudflare filtering of angle brackets stopped script execution but did not stop the logic flaw: when the input contained <>, the deduction did not happen while the message was still sent.
Impact
An attacker can send unlimited messages without buying them, after paying for the first 10, and can include bad code such as:
<script>alert(1)</script>
in those messages. The researcher states the attacker can use the feature for free to talk to any streamer, needing only to buy the first 10 messages. The researcher notes that the severity was lowered to Medium.
Fix
Based on the behaviour described, the deduction should be performed independently of content filtering, so that any message that is delivered consumes a purchased message regardless of what characters it contains.
Variants to test
- Send a paid message containing only angle brackets, for example
<>, and check whether the balance drops. A positive result is a delivered message with an unchanged balance. - Send a paid message with a tag around ordinary text, as in
<b>hello</b>, and compare the balance before and after. A positive result is delivery without deduction. - Try the same pattern on other metered actions, such as paid reactions or paid posts, where a filter runs before the quota is charged. A positive result is the action succeeding while the quota stays the same.
- Check whether the same bypass works when the tag is split or nested, for example
<scr<script>ipt>, and watch both the delivered text and the balance. A positive result is delivery with no deduction.
What happened, in plain words
A website let people pay to send private messages to streamers. You bought a bundle of messages with an in-site currency called tokens, and each message you sent was supposed to use up one of the bundle. If you bought 10 messages, you could send 10, and then you had to buy more.
The researcher found that if a message contained angle brackets, the characters < and >, the message still reached the streamer but the website did not take one message off the balance. So after buying the first bundle, a person could keep sending messages for free by wrapping the text in a script tag. The messages could contain a script tag, though the filtering removed the tags and left only the inner text.
This is a logic flaw: nothing crashed and no password was stolen, but the rules the website was supposed to follow were broken, and the paid feature became free.
Background: the pieces involved
Before the steps, here are the ideas you need. None of them require any special tools.
- A web page and a server. Your browser shows a page, but the page is built from data the server sends. When you type something into a form and press send, your browser packages it up and ships it to the server, which decides what to do with it.
- A feature. A feature is one thing a website can do, for example posting a comment, searching, or sending a private message. Each feature usually has its own form and its own rules.
- User-generated content. Any text a visitor types in and the site stores or shows to someone else: posts, comments, search boxes, private messages. Because the text comes from strangers, sites have to be careful with it.
- Cross-site scripting (XSS). If a site shows your text to another visitor without cleaning it, and your text contains code, the other visitor's browser may run that code as if the site itself had written it. A classic test is a tiny script that pops up an alert box. If the alert appears, the site is executing text it should have treated as plain words.
- A script tag. In a web page, code is wrapped in
<script>and</script>. Anything between them is treated as a program, not as text. That is why<script>alert(1)</script>is the standard first test for XSS: it asks the browser to runalert(1), which shows a small pop-up. - Angle brackets. The characters
<and>. They are how web pages mark the start and end of tags, so they are the characters most closely watched by filters. - Cloudflare. A service many sites put in front of their server. It inspects traffic before it reaches the site and can block or rewrite requests. In this story it was the thing removing angle brackets.
- HTTP 403 Forbidden. A status code a server sends when it refuses a request. You see it as an error page. It means "I understood you, and I am not doing this".
- Tokens. The site's own currency. You top up tokens, then spend them on things like private messages.
- A streamer account. The recipient in this story: a person who broadcasts and receives private messages from viewers.
- A logic flaw. A bug where the site does what it was programmed to do, but the programming does not match the intended rule. Nothing is corrupted; a rule is simply skipped. A shop that gives you the item but forgets to charge your card is a logic flaw.
- Severity. How serious a bug is judged to be, usually on a scale from low to critical. It affects whether and how much a bug bounty programme pays.
The setup
The report does not name the website, the bug bounty programme or any software versions. What it does describe is the starting position: an ordinary user account with enough tokens to buy private messages, and a streamer account to send them to. The researcher bought a bundle of private messages and started with a balance of 10.
Finding it
The researcher began where most people begin: by trying to get XSS on the obvious places. Features such as posting, commenting and searching all accept text from users, so each is a candidate. The payload used was:
<script>alert(1)</script>
Line by line: <script> opens a script block, alert(1) is the instruction to show a pop-up containing the number 1, and </script> closes the block. If a site stores this and later shows it to someone without cleaning it, that person's browser runs the pop-up.
Every attempt came back as a Forbidden Error 403. So the site was refusing the request outright.
Looking into how Cloudflare works, the researcher concluded that it deletes anything containing <> and leaves only the content in between. Under that behaviour, the payload above would arrive at the site as:
alert(1)
In other words, the dangerous wrapper is removed and only harmless-looking text is left. That is a reasonable defence against script tags, but it raised a different question: what happens if this same filtering is used against the site itself, in a feature where the content of a message has a price attached? If the site's billing logic and its filtering logic are connected in the wrong way, the filter might interfere with the charge.
Exploitation
Step 1: confirm normal message accounting
After buying the private messages, the researcher first sent a completely ordinary message, to see what normal behaviour looks like:
hello Streamer
This is just plain text, no tags, no brackets. Before sending, the account had 10 messages. After sending, it had 9. So for ordinary text, the rule worked: one message sent, one message deducted. This baseline matters, because you cannot tell whether something is broken until you know what working looks like.
Step 2: send a message containing a script tag
Next, the researcher sent a message containing a script tag:
<script>alert(1)</script>
Again line by line: <script> starts a script, alert(1) asks the browser to show a pop-up, </script> ends it. The expectation, based on what Cloudflare did on the other features, was that the site would strip <script></script> and leave alert(1) behind.
What actually happened was different in an important way: the message was not deducted from the number of purchased messages. The balance did not move.
Step 3: combine the tag with real message text
A message that only says alert(1) is not much of a message. To check whether the trick still worked when the message read normally to the recipient, the researcher sent:
<script>"Hello Streamer"</script>
Here <script> and </script> wrap the words "Hello Streamer" in quotation marks. The result was the same as before: the remaining message count did not go down, the message was delivered with the text "Hello Streamer", and the balance stayed at 9. So the recipient sees a normal message, and the sender is not charged.
Attack workflow
The whole attack, as the researcher lays it out:
- The attacker buys private messages to talk to their streamer account.
- The attacker sends a message to the streamer account with
<script>"The Message"</script>. - The streamer receives the message "The Message".
- The attacker does not lose the message they bought, and can now use the feature for free to talk to any streamer, needing only to buy the first 10 messages.
In plain terms: pay once for the first bundle, then send as many messages as you like by wrapping the text in a script tag. The streamer sees ordinary text; the balance never falls.
Root cause
The report does not show the server-side code, so the exact mistake is not visible. What the behaviour tells us is this: the message content is filtered or rewritten, with the tags removed and the inner text kept, and the accounting for the purchased message is tied to that filtering step rather than to the successful delivery of the message. When the input contains <>, the deduction does not happen, yet the message is still sent.
The existing defence, Cloudflare's removal of angle brackets, did stop script execution. It did not stop the logic flaw: when the input contained <>, the deduction did not happen while the message was still sent. A filter that is meant to make text safe ended up deciding whether money was taken.
Impact
An attacker can send unlimited messages without buying them, after paying for the first 10, and can include bad code such as:
<script>alert(1)</script>
in those messages. The researcher states the attacker can use the feature for free to talk to any streamer, needing only to buy the first 10 messages. The researcher notes that the severity was lowered to Medium.
Fix
Based on the behaviour described, the deduction should be performed independently of content filtering, so that any message that is delivered consumes a purchased message regardless of what characters it contains. In everyday terms: charge for the delivery, not for the text.
Variants to test
These are follow-up checks in the same spirit, useful if you want to look for the same pattern elsewhere:
- Send a paid message containing only angle brackets, for example
<>, and check whether the balance drops. A positive result is a delivered message with an unchanged balance. - Send a paid message with a tag around ordinary text, as in
<b>hello</b>, and compare the balance before and after. A positive result is delivery without deduction. - Try the same pattern on other metered actions, such as paid reactions or paid posts, where a filter runs before the quota is charged. A positive result is the action succeeding while the quota stays the same.
- Check whether the same bypass works when the tag is split or nested, for example
<scr<script>ipt>, and watch both the delivered text and the balance. A positive result is delivery with no deduction.
Glossary
- Angle brackets: the characters
<and>, used in web pages to mark the start and end of tags. - Cloudflare: a service placed in front of a website that inspects and can block or rewrite incoming traffic.
- Cross-site scripting (XSS): a bug where text supplied by one user is shown to another and executed as code by their browser.
- Feature: one capability of a website, such as posting, commenting, searching or sending a private message.
- Forbidden Error 403: an HTTP status code meaning the server understood the request and refused to carry it out.
- HTTP status code: a number a server sends with its reply to say how the request went, for example 200 for success or 403 for refusal.
- Logic flaw: a bug where the site follows its programming but the programming does not match the intended rule, so a rule is skipped rather than broken.
- Payload: the specific piece of text or code you send to test or exploit a bug.
- Script tag: the
<script>and</script>markers in a web page that tell the browser the content between them is code to run. - Severity: a rating of how serious a bug is, usually from low to critical.
- Streamer: a person who broadcasts online and, in this story, receives private messages from viewers.
- Token: the website's own currency, used to buy things such as private messages.
- User-generated content: any text a visitor types in that the site stores or shows to others, such as posts, comments and messages.
- Web server: the computer that receives requests from browsers and decides what to send back.