Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

How I Found a $90,000 Remote Code Execution Vulnerability in Google - 2228

simon koeckPosted 1 Month Ago
  • The author of this post was reviewing the OAuth flow of the Google developer docs site. Upon finishing, it sets a Flask session cookie that contains a three part format: session=<payload>.<timestamp>.<signature>. What caught their eye was how large it was, at 1200 bytes. They decoded it to check out what was going on.
  • The Flask tokens are signed and zlib-compressed but not encrypted, using pickle. Upon decoding this, they found a client_secret, and a client_id for OAuth. Typically, these are secret values so this was a bad sign.
  • Here's the craziest part: the client secret was also the Flask secret! So, the signing key for the cookie was in the cookie! In the case of Flask sessions, this is particularly bad because you know the signing key. You can create a valid pickle object to get RCE from the google_oauth2_flow value! They just ran it with time delays so they wouldn't get in trouble, though.
  • For security reasons, they rotated all exposed OAuth client secrets. To fix the actual issue, they did a few things. First, they rotated the SECRET_KEY to a sever-side store that has nothing to do with OAuth. Second, the OAuth flow is kept on the server. Finally, the usage of pickle was entirely removed to prevent this attack vector in the future.
  • All in all, several issues compounded, leading to RCE. The bug seems simple, but it took a lot of trial and error and good intuition to know what to try. A fantastic and short blog post!