Hello, I am reporting a hack on the leaderboard for the HTML5-Asteroids game, not because this particular game is important, but because its a forked repository on Firebase's github, and serves as a really bad security practice, simply because of how fast I was able to manipulate the leaderboard. I will also make the case that even if this developer had wrote security rules to validate the score, there would still be no way for him to stop me from writing my own score into the leaderboard. This leaderboard is also vulnerable here:
https://github.com/firebase/examples/blob/master/leaderboard/rules.json. The hack is simply breaking and modifying a reference in the developer console. I put the full instructions below.
This leads me to conclude that client-side user data in Firebase is impossible to protect from malicious writes. I've read the security docs several times, and its focused mostly on ensuring the data is the correct schema. Don't get me wrong, ensuring that and the user is authenticated is critical and protects from maliciously setting other users data. But there's nothing to stop clients from writing whatever data they want into their own legal writable data, hundreds of times in a row. Firebase might protect from malicious spamming, but simply setting a fake score in a game doesn't seem like something that can be fixed without server-side code.
In the Tetris example, malicious clients can just reset the board whenever they want. The game is a great learning exercise, but the entire architecture of maintaining client state is just very insecure to the point that it's questionable why there are even security rules at all, if anyone can just easily ruin any game.
Which is why Firebase should advocate the server-side admin for writing and maintaining game state as a more secure option. Its the only way to truly validate gameplay. By only allowing the admin write access to the game state and leaderboard, it becomes impossible for the client to manipulate these values.
Firebase should remove "and perhaps most importantly, there is no need for an intermediate referee, such as a server, to protect data from the world" from its security docs because the opposite of that is true from what I discovered. A server-side admin is more secure, and also hides your proprietary logic, which is another topic. I don't think anyone would seriously release a production game with 100% client-side code, as anyone can just steal it.
Please let me know if I am missing something. I'm going to re-architect my game around state on the server, and I wish I had considered this approach in the first place. If Firebase agrees I think the security docs should be updated to reflect a more realistic app architecture.
The hack :
Go here:
https://mmoasteroids.firebaseapp.com/
Put a breakpoint after scoreListRef is declared, line 199 in game.js
Enter in console: scoreListRef.push({user:currentUser, score: '123456'})