How i was able to get free money via sending negative tokens
The website allowed a user to send a negative number of tokens as a tip to a streamer, which instead of deducting tokens from the sender increased the sender's balance. An attacker could repeat this to generate unlimited free tokens that convert to real money.
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
The target described here is a streaming platform with two roles: a normal user and a streamer. Users buy tokens to support streamers, and streamers can also send tokens to other streamers. Tokens sent to a streamer are converted into money for that streamer. The researcher's stated goal was to obtain tokens without paying for them, then create a streamer account and send tokens to himself indefinitely.
The feature that mattered in the end was private messaging. To send a private message to a streamer, a user must first buy private messages with tokens. Once a user has bought private messages and can message a streamer, the private chat exposes three functions:
- Send a private message to the streamer (no issue found).
- Upload an image or video file to the streamer (no issue found).
- Send token tips to the streamer (the bug).
Setup
The researcher used two accounts: one as a streamer and one as a user. The user account needed enough tokens to buy private messages, which is the precondition for reaching the chat functions. The report does not name the platform, the endpoint, the tooling or any software versions.
Finding it
After buying private messages and gaining access to the chat, the researcher looked at the tip function and asked what would happen if a tip were negative, for example -5 or -10. The request body carried the tip amount in a tokens field, so the researcher sent a negative number and observed how the server handled it.
Exploitation
Step 1: send a negative tip
With the user account holding 150 tokens, the researcher sent a tip of -100 tokens to the streamer account. The request was:
POST /endpoint HTTP/1.1Host: 0xM5awy.com{"message":"negative tips","tokens":-100"}
The tokens field appears in the request body with the value -100. Sending a negative value resulted in the sender's balance increasing. The result was that 100 negative tokens were sent to the streamer, and the user account, which had 150 tokens before, ended up with 250. In other words, the sender's balance increased by the absolute value of the tip rather than decreasing.
Step 2: repeat
The researcher notes that the same operation can be performed more than 100 times, and that at that scale the credited tokens would be worth more than 10K dollars.
Attack workflow as described
- The attacker has two accounts, one streamer and one user.
- The attacker buys private messages to talk to his own streamer account.
- The attacker sends negative tokens to his streamer account.
- The attacker sends 100 negative tokens to the streamer, and his account is increased by 100 free coins.
- The attacker repeats this more than 100 times, which the researcher estimates would yield more than 10K dollars.
Root cause
The server applied a negative tip amount in a way that credited the sender. The result was that the sender's balance increased by the size of the negative tip. The report does not show the server-side code, so the exact implementation is not stated; the behaviour is consistent with a missing sign or range check on the tokens parameter before the balance arithmetic runs.
Impact
An attacker with a user account and enough tokens to buy private messages can credit their own balance repeatedly and convert the resulting coins into money through a streamer account they control. The researcher describes the gain as unlimited free coins and, at the scale of more than 100 repetitions, more than 10K dollars.
Fix
Variants to test
- Send a zero or negative amount to any endpoint that accepts a numeric amount from the client (tips, transfers, refunds, top-ups) and watch whether the sender's balance increases. A positive result is a balance that grows when it should shrink.
- Send very large values and values with decimals to see whether the amount is validated for type and range. A positive result is an accepted value that produces an unexpected balance change.
- Repeat the accepted request many times and check whether any rate limit or anomaly detection intervenes. A positive result is repeated credit with no throttling.
- Try the same negative value on the streamer-to-streamer transfer path, since the report says streamers can send tokens to other streamers. A positive result is the same credit behaviour on that path.
What happened, in plain words
A security researcher found a way to give himself free money on a streaming website. The site sold "tokens", which are like arcade coins: you buy them with real money, and you can hand them to a streamer as a tip. The streamer can then turn those tokens into cash.
When you tip a streamer inside a private chat, the amount of the tip is sent in the request to the website's server. He tried sending a negative amount, minus 100 tokens instead of plus 100. The server accepted it. Instead of his balance going down, it went up: he started with 150 tokens and ended with 250. He notes he could repeat this more than 100 times, and because tokens convert to money, that would yield more than 10K dollars.
This kind of bug is called a logic flaw (or business logic vulnerability). It is not a broken lock or a crashed program; every piece of the site works exactly as programmed. The program applied a negative tip amount in a way that credited the sender instead of rejecting it. It is like a shop till that, when you ask for a refund of minus ten pounds, hands you ten pounds instead of taking ten.
The platform and its two roles
The site has two kinds of account:
- A user: an ordinary viewer who buys tokens and spends them on streamers.
- A streamer: a person who broadcasts, receives tokens, and converts them into money.
Users buy tokens to support streamers. Streamers can also send tokens to other streamers. Any token that reaches a streamer becomes money for that streamer.
The researcher's plan, stated up front, was simple: find a way to get tokens without paying, then open a streamer account and send tokens to himself forever.
Understanding the site before attacking it
Before trying anything, the researcher went through the site's features one by one to learn what each one did. This is the normal first step in security testing: you cannot spot something that behaves wrongly until you know what "rightly" looks like.
One feature stood out: sending a private message to a streamer. To use it, a user must first buy private messages using tokens. That purchase is a gate: you cannot reach the chat until you have paid.
He bought private messages and looked inside the chat. It offered three things:
- Send a private message to the streamer. He found nothing wrong here.
- Upload an image or video file to the streamer. He found nothing wrong here either.
- Send token tips to the streamer. This is where the bug was.
The idea: what if the tip is negative?
The tip amount appears in the request body as a tokens value. In a web application, anything you type or select in your browser has to travel to the server, and the server has to trust or check it. The researcher's question was: what happens if I send a tip of -5, or -10, instead of a normal positive amount?
A server is the computer that runs the website and holds the real data, including account balances. Your browser is the client: it displays things and sends requests. A request is a message your browser sends to the server, for example "please send a tip of 100 tokens to this streamer". The server is supposed to check every request, because the client can send anything at all, including values no normal button on the page would produce.
Step 1: sending a negative tip
With his user account holding 150 tokens, the researcher sent a tip of -100 tokens to his streamer account. The request looked like this:
POST /endpoint HTTP/1.1Host: 0xM5awy.com{"message":"negative tips","tokens":-100"}
Line by line, in plain words:
POST /endpoint HTTP/1.1is the first line of an HTTP request. HTTP is the language browsers and servers use to talk.POSTmeans "I am sending data to you to create or change something", as opposed to simply asking to view a page./endpointis the address of the function on the server being called. The report uses a placeholder here rather than the real path.Host: 0xM5awy.comtells the server which website the request is for. One server can host many sites, so the request names the one it wants. The report uses a placeholder host name.{"message":"negative tips","tokens":-100"}is the body of the request: the actual data being submitted. It is written in JSON, a common text format for structured data, where names and values are paired up.messagecarries the text of the tip, andtokenscarries the amount: here, minus 100.
The key point is that tokens is a number supplied by the client. The server applied that number to the balances, and the sender's balance increased.
The result: 100 negative tokens were sent to the streamer, and the user account that had 150 tokens before ended up with 250. The sender's balance grew by the size of the tip instead of shrinking. In effect, the site paid him 100 tokens for sending a tip of -100.
Step 2: repeating it
The researcher notes that the same operation can be carried out more than 100 times. At that scale, the credited tokens would be worth more than 10K dollars.
The attack workflow, as described
- The attacker has two accounts: one streamer and one user.
- The attacker buys private messages so he can talk to his own streamer account.
- The attacker sends negative tokens to his streamer account.
- The attacker sends 100 negative tokens to the streamer, and his account is increased by 100 free coins.
- The attacker repeats this more than 100 times, which the researcher estimates would yield more than 10K dollars.
By controlling both sides, the attacker keeps everything: the user account generates the free tokens, and the streamer account cashes them out.
Why it works (the root cause)
The server applied a negative tip amount in a way that credited the sender. The result was that the sender's balance increased by the size of the negative tip.
The report does not show the server-side code, so the exact implementation is not stated. The behaviour fits a missing sign or range check on the tokens parameter before the balance arithmetic runs. In everyday terms: the till has no rule saying "refunds must be positive", so a negative refund is treated as a payment to you.
Impact
Anyone with a user account and enough tokens to buy private messages can credit their own balance over and over, then convert the coins into money through a streamer account they control. The researcher describes the gain as unlimited free coins and, at more than 100 repetitions, more than 10K dollars. The report does not describe any rate limiting, fraud checks or other controls that would have stopped the repetition.
Fix
The lesson generalises: never trust a number that arrives from the client, and always validate it on the server before using it.
Variants to test
These are the same idea applied elsewhere, useful when you are learning to look for this class of bug:
- Send a zero or negative amount to any endpoint that accepts a numeric amount from the client (tips, transfers, refunds, top-ups) and watch whether the sender's balance increases. A positive result is a balance that grows when it should shrink.
- Send very large values and values with decimals to see whether the amount is validated for type and range. A positive result is an accepted value that produces an unexpected balance change.
- Repeat the accepted request many times and check whether any rate limit or anomaly detection intervenes. A positive result is repeated credit with no throttling.
- Try the same negative value on the streamer-to-streamer transfer path, since the report says streamers can send tokens to other streamers. A positive result is the same credit behaviour on that path.
Glossary
- API: the set of functions a website's server exposes so that a browser (or any program) can ask it to do things, such as send a tip.
- Body (of a request): the part of an HTTP request that carries the actual data being submitted, such as a tip amount.
- Business logic vulnerability: a flaw where the program works as written but the rules of the business (for example "tips must be positive") are not enforced.
- Client: the program on your side, usually your browser, that sends requests and displays results.
- Endpoint: the specific address on a server that handles one function, such as sending a tip.
- HTTP: the language browsers and servers use to exchange requests and responses.
- JSON: a text format for structured data, made of name and value pairs, commonly used in request bodies.
- Logic flaw: see business logic vulnerability; the program behaves exactly as coded, but the code allows something it should not.
- Parameter: a named value sent in a request, such as
tokensin the tip request. - POST: an HTTP method meaning "here is data, create or change something with it".
- Rate limiting: a control that blocks or slows repeated requests, for example after many tips in a short time.
- Request: a message from the client to the server asking it to do something.
- Root cause: the underlying reason a bug exists, as opposed to its visible symptom.
- Server: the computer that runs the website, stores the data and decides what to do with each request.
- Server-side validation: checking data on the server, where the user cannot tamper with the check, before acting on it.
- Streamer: on this platform, an account that receives tokens and converts them into money.
- Token (platform currency): the site's internal coin, bought with real money and tipped to streamers, who can turn it into cash.
- User: on this platform, an ordinary viewer account that buys and spends tokens.