How Primedice was exploited for $1M in Bitcoin
medium.com
medium.com
If you're going to run a casino (whose entire business model is based on exploiting weaknesses of others for profit), don't be surprised if people try to exploit your weaknesses for profit.
I'm not saying there's anything wrong with running a casino, I think it is fine. I just think that what he did is fine too.
EDIT: Except the part where you apparently didn't pay out all of his winnings. I'm not fine with that part. Also doxing one of your customers just because he made a profit out of you.
There are plenty of casios, and many of them comply with the law. People who choose to gamble there might be exploited by some definition, but it is consentual. But Primedice is a casino that uses bitcoin to allow users to circumvent local gambling laws, and thus exploits weakness in criminal laws.
(I will not discuss the morality of current anti-gambling laws in the US, as any rational person can see the hypocrisy in the current system of state-sponsored lotteries and state-granted casino monopolies)
> don't be surprised if people try to exploit your weaknesses for profit.
Primedice reusing a nonce/seed is like a casino dealing blackjack from a marked deck. It is so incredibly stupid that you are guaranteed to have someone notice, and clean you out while still playing by yor rules.
Note that they are offering a reward for the "return of the [bit]coins". I assume that means they are offering that if someone hacks a bitcoin wallet and gives them the proceeds, they will share a fraction of the stolen assets. I would happily make the same offer; paying random people who give me bitcoins from hacked wallets some of the stolen bitcoin, except that I'm not an exploitive, criminal-minded narcissist rationalizing theft to support the operation of a gambling site based on a cyber-currency designed to facilitate extra-legal activity.
I'd assume that what they're saying is: if you provide information that lets them identify Hufflepuff, and they successfully sue him for the money, then they'll reward you.
My interpretation doesn't require you to have control of the bitcoins at any point, and also explains why they provided their information about the guy.
There are plenty of Nazis, and many of them comply with the law.
I feel like unless you are trying to troll, it is best to avoid all analogies that compare current events to what would be deemed by many as 'historical evil doers'.
Just because entities comply with "laws", which may have been created (and are modifiable) by the very same entities, does not provide any type of moral, or otherwise, justification that the entities' actions are reasonable, acceptable, exemplary, or other.
In fact, some Nazi's actually tried to argue something exactly analogous to what the sentence argued: that complying with the law can be used as axiomatic justification for any behavior.
I only state that such logic is fallacious.
>There are plenty of casios, and many of them comply with the law.
>There are plenty of Nazis , and many of them comply with the law.
Basically, if you believe the first sentence is legitimate, I have shown you a second sentence that is of equally legitimate construction. It is grammatically correct and has real semantic meaning. In fact, it is a true statement, just as the first statement (probably) is.
The fact that the second statement is true and is as legitimate as the first might strike a reader and cause them to think more about it.
Nazis rose to power by crafting law and used it to drive people to do things they wouldn't have otherwise. When some of those people were caught and tried for their actions, some of them argued that they did nothing wrong because they were merely complying with the law.
The sentences in comparison make the (implicit) argument that 'complying with the law' is somehow relevant to the exculpation of the actions of the entity in question. Many consider this to be absurd.
How you expected anyone to jump to the conclusion you were talking about the manner in which Nazis rose to power and their eventual punishment or lack there of as being the analogous part is beyond me. Especially since you kept your sentence in the present tense leading me to believe it was about modern day people who hold the beliefs of the Nazi party.
Exactly. The statement is irrelevant. Its use as the foundational axiom in the defense of casino's behavior is absurd.
Everything else (striking similarity to Nazi arguments) is bonus.
"We reached out to Hufflepuff via his bitcointalk forum account and demanded the return of the coins, however this backfired unbelievably hard. "
They asked him to stop playing at that point and he created a new account to evade that. I'm not sure why you feel people don't have the right to refuse service.
Going after the person on a bitcoin forum and attempting to demand repayment is a joke, however. How did Primedice think that was going to work out for them?
"Our database had seeds that were both inactive and in use at the same time all connected to Hufflepuff."
To me it sounds like your company simply didn't understand how the system you created worked, it sounds like you merely understood how you wished it to work. Gambling has always favored people who actually understand the system in place, by not understanding the system you yourselves were implementing you created the opportunity for a customer to understand it better than you. What you describe with your database having seeds that were both in use and inactive at the same time, sounds to me like you did not do a good job managing concurrency on records which were crucial to your business.
While I can not say whether the users did anything illegal, the post you have created to call attention to this does not make an adequate case for wrong doing on the users part. However your response does make an amazing case for you having responded to an implementation issue in your software very poorly, and I think would make future users who are aware of this less likely to use your service.
That is just my opinion given the information you have presented, as you seem to focus more on maliciously providing information of the person you are accusing as opposed to proving your accusations that the person in question committed a crime while doing so.
Of course, it's a great start.
Of course, relational data models only encourage this type of design: they do not require it, nor are they required for it.
Also, this is by no means the only possible bug of this nature. For example, the seed generation might be based on the current wall-clock time. I'd hope someone trying to run a casino would know better than that, but hopes of that nature are frequently unfulfilled.
I worked on a database that allowed (almost) every table to mark a row as deleted with a boolean-type column. This caused problems when you wanted to create a new row that had the same values for the table's key-columns as a deleted row. You can't just add the deleted column to the key and have all the functionality you want (multiple deleted rows with the same values in the table's key-columns). Each table could use (or not) the flag in different ways and there was no simple way to enforce consistent behavior across all tables. The constraint has to be placed somewhere else, either in explicit code, or by creating new abstractions inside the database that allow you to represent the actual constraints of your application.
The solution the problem you described would be to use a surrogate key column (typically a UUID/auto-increment), and not natural keys.
All tables had a unique, integer primary key.
However, if you want to enforce a uniqueness constraint across your data [eg. UNIQUE(name, location)], the constraint breaks when you introduce the boolean deleted column [and UNIQUE(name, location, deleted) does not provide the appropriate semantics]. The application semantics must be provided at some other level than SQL column constraints.
So, let's see if I get this. Three letters, that means 1/26th chance of getting the correct number. And.. wait, what do I do now?
> ...
> This was done by sending it more requests than it could handle in a small time period, think hundreds of requests in under a second
Sounds like your developers really messed up. The server logs would be the #1 place I would look. Where else really? How do you not notice hundreds of requests per second (from the same IP I assume)?
...I can't imagine the slightest reason why they would expect, would want, or would tolerate automated gambling. ANY evidence that someone is using a script or bot, making too many bets, making bets with an oddly regular pattern, making too many requests from a single IP, making requests from different IPs at the same time, etc. would seem to be a red flag, and should cause the associated account to be suspended. Right?
Like, if there's a hole in your code, the attacker is very likely to automate the attack to try and maximise their gains. But if there's no hole in your code, your punters are very unlikely to automate their playing. Any hint of automation is a huge red flag; any hint of automation combined with a string of "lucky" wins should be an automatic account suspension, because you're obviously looking at successful attack.
Saying that your developers couldn't find any "wrong-doing" just raises questions. Like, why do your developers need to look, shouldn't those checks be automated? And how did they miss it when it turns out it was obvious? And why were you even looking when the underlying activity was obviously illegitimate? Real casinos don't wait until they understand the scam before cutting someone off.
So many questions.
> How do you not notice hundreds of requests per second (from the same IP I assume)
To be fair to them, I imagine a bitcoin casino is a magnet for weird traffic patterns. Giving them the benefit of the doubt, maybe they're getting bursts of crazy traffic all the time, and they had no way of knowing which ones were "potential timing attacks" and not just "bored script kiddy with a botnet". Maybe "Hufflepuff" was hitting them from an unrelated network constantly, and a small fraction of those times he also made a bet he already knew the outcome of. Maybe he was also making normal bets at the same time. (...or maybe not.)
Still, even if the bad traffic was hidden by noise, I don't believe that his account activity could have looked normal the entire time he was building up his 1 million payout.
...man this is not a sympathetic story. You're running a gambling site (morally shady and an obvious magnet for abuse), using bitcoins (another huge abuse magnet), you had very supicious gambling patterns (a massive red flag that no real casino would accept), and you just let the guy keep playing? That's not how you're supposed to do that.
And as for the whole "we had a timing bug in our code, and we couldn't find it even with hard proof that it existed, and then we finally thought we'd fixed it, and then we asked the guy for the million dollars back (??!?), and then it turned out we hadn't fixed it at all, and he hit us up for another few thousand"? Like, that just sounds screaming amateurish.
If you can't be trusted to write secure code, or at least fix the bugs you find in it, maybe online bitcoin casinos aren't for you? And if you think asking people nicely to give you your money back works in casinos, maybe you don't understand the industry?
Edit: I'm not trying to be a dick, but I feel like the proper blogpost to write would be a grovelling "hey guys, I know it's super obvious, but if you're doing an online gambling website, monitor your transactions for specific patterns. Know what a real punter looks like, and aggressively throttle anyone who doesn't behave like one. Otherwise you'll be stupid idiots who lose a million dollars over a stupid bug, and then have to write a magnanimous letter congratulating the guy who exploited you for winning so much money (man that was painful to write)." You made some huge mistakes, and it doesn't sound like you really learned from them, or even identified them. Hint: Your core mistake was not a timing bug that emerged when your system was under heavy load.
If they have a legit exploit, then kicking them will just make them create a new account. Or perhaps distribute the +EV betting over a bunch of accounts so that it was much harder to detect.
If they don't have an exploit, then you want them to keep betting and lose. And if you have no real basis for kicking them, then, what, your casino just doesn't pay out people that win big?
The casino's only real option here was to discover the exploit.
I dunno, maybe anyone who is clearly automated (ie, betting every second for hours) and probably cheating (ie, implausibly lucky)?
> It seems like initially all they knew was that some accounts were unusually active (betting every second, for hours) and implausibly lucky.
Exactly.
> They saw the flags, they just didn't know any useful way to react
The useful way to react would be to not let them continue betting.
Maybe they took some measures like this that they didn't tell us about. With that much money at stake, maybe "do something, anything" does make sense -- my point was there's no way for them to ultimately prevail until they understood/addressed the root issue, and knee-jerk responses could backfire.
> There was also strong incentive for us to promptly pay him, so he’d keep playing.
I loved that line, because it's the converse of a casino player in a hole, thinking maybe they can make it back if they keep on playing.
It's more than an inverse in thinking, it's how the house makes money.
But, as you pointed out, they can't ban him, because they have no way of recognizing him when he walks back in.
From an observer's view, after fully reading it and seeing how hostile their response is, I can only applaud the player. To me it seems fair game. She exploited a weakness in the game, something that in meatspace is often hailed as genius. In bitcoin online gambling, race conditions are a part of the game that has to be expected to be attacked.
With their doxxing they lost any bit of sympathy I had.
We all face pressure to deliver but at the end of the day -like brakes on a car- testing is one thing you should never cut corners on.
Although another 2 weeks of testing may not have explicitly exposed the vulnerability, it surely would have offered a better baseline from which to evolve better heuristics for the analysis of the exploit when it did occur.
For concurrency issues someone thinking real hard is as important as testing.
With one caveat.
The "thinking real hard" has to happen before and as the code is written.
If you try to catch fundamental design problems and misconceptions during a code review, you're much too late. At that point there is a "status quo" i.e. the existing code, and a defensive resistance to change, even if you can demonstrate clear problems with said code. The end result is band-aids on top of band-aids, rather than a proper solution to the problems.
Edit: the article itself alludes to band-aids:
our developer had improperly patched the glitch
i.e. they attempted a quick fix, instead of understanding at a fundamental level the overall mistakes in what they were doing.What does this mean? Are they trying to steal the thief (according to them). Shouldn't they inform the local authorities and let them handle the case?
> Shouldn't they inform the local authorities and let them
> handle the case?
In which jurisdiction? The one containing the VPN IP addresses? Or the internet police?An open letter to the internet asking for help ends up sounding about 1000x more effective than phoning this in to the "authorities".
I think a bit more information included with the article to verify this was actually a 'hack' would be helpful. I mean, was this akin to counting cards or what? It's hard to tell from the article.
Obviously, the server only wants to divulge the server-secret of closed-out bets so that you can verify them as provably fair.
> Strange choice to put a picture from the Ocean's Eleven series at the top of the article, seeing as how the thieves in those films are considered the protagonists/heroes.
It's not so strange after reading a number of these HN comments.
... did the math and came to the conclusion that he was just
incredibly lucky
Woah. Red flag. Just incredibly lucky doesn't exist. Odds are odds.Judging by the contents of this thread, the Bitcoin/hacker community feels just the opposite. How odd. I feel like this more than anything will impede the mass adoption of Bitcoin.
However, it's not cool to break the casino's games from within. To make an analogy, if you discover that e.g. a casino's blackjack decks have twice as many 7s in them as they should, and you use that knowledge to make a ton of money playing blackjack at the casino, that's legitimate. However, if you break into the casino and replace all their normal blackjack decks with ones which have twice as many 7s, then use that knowledge to make a ton of money at blackjack, that's bad.
So the question is, which category does this particular attack fall into? Apparently they exploited a race condition, wherein outcomes became predictable if lots of games were played simultaneously. Is that exploiting the game within its rules, or is that breaking and entering?
To me, this feels legitimate. An analogy to physical games here might be finding a roulette table where the dealer under some circumstances lets you place a bet after it becomes apparent where the ball is going to land.
I've always wondered about this from the other perspective. Why can't the casino remove a few cards?
E.g. in Blackjack in a six-deck shoe the house edge is perhaps 0.5% to 2.0% against a "pretty good player" (depending on exact rules). Remove a few face cards and you would probably hurt the player by another 1% or thereabouts.
But you've now moved the house edge from 1% to 2%. Double the profit!
When is the last time you've ever seen any player at a casino ask the dealer to reconstruct the six or eight starting decks that are in a shoe? I've never seen that.
But I still do enjoy taking the occasional trip to Vegas.
You see the decks fanned out, each card visible, before they get shuffled and put in the shoe. It would require some sleight of hand from the dealer to cheat that way. If you're going to do that, it's much less risky to rig your slot machines or your craps dice or your Wheel of Fortune, where no one will ever notice any wrongdoing short of an audit by the gaming commission.
First, if people ever find out you're cheating, your reputation will take a huge hit and you'll lose a ton of clients. People know that the house always wins, but they still insist that the house must play fair within those bounds.
Second, I'm guessing there's some way for a player to take advantage of this change if he knows what's going on, so you're potentially losing money if anyone discovers it.
Compared against these downsides, what's the upside? Casinos practically print money. Why risk destroying that just so you might print a little more? Better to put your effort into convincing people to bet more, or getting less experienced players to play more.
Go to any Joe or Jane on the street and ask them if swindling (conning) $50 from a lifetime "professional" con artist is wrong. Out-conning the con artist is typically seen as a thing of approval.
"They deserve it!"
Didn't feel long at all; it was concise and had enough detail to satisfy a casual reader (me) with links to more detail if I wanted it.
[0] https://www.youtube.com/watch?v=lSLXv5Tz1ZY , linked from "$8000 worth of bitcoin every second for hours on end"