Lion Cipher Lab

Lock down direct-to-S3 browser uploads with a presigned POST policy (built and enforced offline)

Why it matters

Almost every modern app that takes photos, documents or videos lets the browser upload straight to cloud storage instead of streaming gigabytes through its own servers. On AWS the classic way to do that is a browser-based POST: your backend hands the browser an HTML form whose hidden fields carry a POST policy (a small JSON document listing what this upload is allowed to be) and a signature over it. S3 checks the form against the policy and stores the file. The policy is the only thing standing between 'alice uploads her avatar' and 'alice overwrites bob's files, parks a 2 GB file on your…

What you'll learn

Steps in this lab

  1. What a browser POST upload is, and why apps use it
  2. Recap the SigV4 signing key, then the one big difference for POST
  3. Anatomy of a POST policy: expiration, conditions, and five rules to remember
  4. Write postpolicy.py: the backend that mints a form for one user
  5. Prove your signing matches AWS's documented example
  6. Write verify.py: an offline emulation of S3's checks (and what it is not)
  7. Write matrix.py and measure: three policies against nine abuse attempts
  8. Read the matrix: which line of the policy stopped which attack
  9. POST policy versus a presigned PUT URL (and the presigned GET sibling lab)
  10. The honest negatives: what no POST policy can stop
  11. The judgment: when to use a POST policy, and how a pro writes one

Open the full interactive lab →