R2 image hosting behind one master password: switching to per-user checks and 5-minute upload passes
Jeremy (@jeremy_develop) moved his extension’s image hosting to R2, then realised a single leaked master password could produce a large bill; he switched to per-user ID checks and short-lived direct-upload passes. Replies add per-user presigned URLs, a billing alert and bucket-scoped tokens.
- Products
- R2
- Source
- Author experience𝕏 post
- Author
- Jeremy (@jeremy_develop)
Key points
- He says the upload system was protected by a single "master password"; if it leaked, he could wake up to a massive Cloudflare bill.
- His changes: drop the master password and verify each user’s unique ID; stop proxying uploads through the server and instead issue a "5-minute temporary pass" so the browser uploads directly; and move from the free test domain to his own domain, which he says also avoids free-tier rate limits.
- Mohak Bajaj (@MohakBajaj5) suggests short-lived presigned upload URLs per user plus a Cloudflare billing alert, "so a leak costs you an evening, not a month"; Jeremy replies that billing alerts are his next step.
- FlareCost replies that R2 egress is $0, so a leaked key’s cost risk is writes and storage: uploads are Class A operations (1 million free a month, then $4.50 per million) and storage is $0.015 per GB-month after 10 GB; bucket-scoped tokens limit the damage. The R2 pricing page read on 2026-11-04 lists the same rates.
Original sources
Published
Original post
Read on 𝕏Jeremy (@jeremy_develop) moved his extension’s image hosting to R2, then realised a single leaked master password could produce a large bill; he switched to per-user ID checks and short-lived direct-upload passes. Replies add per-user presigned URLs, a billing alert and bucket-scoped tokens.
Jeremy
@jeremy_develop · Original 𝕏 post
Yesterday, I celebrated moving my extension's image hosting from a 3rd-party (ImgBB) to my own Cloudflare R2. But right before bed, it hit me: the system was protected by a single "master password." If leaked, I could wake up to a massive Cloudflare bill. So today, I fixed it. Here is what I changed: 1. Dropped the master password. The system now strictly verifies each user's unique ID—no more unauthorized file dumps. 2. The server is no longer the middleman. It now simply issues a "5-minute temporary pass", letting the user's browser upload files directly to the cloud. Faster exports, and zero server strain. 3. Upgraded the domain. Swapped the free test domain for our own brand: https://t.co/p5BrutxKCG. It looks way more professional in Notion and easily avoids free-tier rate limits. Users won't notice today's update, but hackers definitely will. Locked the doors so I can finally sleep in peace. #BuildInPublic #Cloudflare #ChromeExtension #IndieHacker #SaaS
Reply from @FlareCost: R2 egress is $0, so the risk is Class A writes (1M free a month, then $4.50/M) and storage ($0.015/GB-month after 10 GB); bucket-scoped tokens limit the damage.
Read on 𝕏FlareCost
@FlareCost · Original 𝕏 post
@jeremy_develop Good fix. R2 egress is $0, so a leaked key's real cost risk is writes and storage: uploads are Class A ops (1M free a month, then $4.50/M) and storage is $0.015/GB-month after 10 GB. Bucket-scoped tokens limit the damage. Estimate: https://t.co/2VrVNsNLKD
Reply from @MohakBajaj5: use short-lived presigned upload URLs per user plus a Cloudflare billing alert so a leak costs an evening, not a month.
Read on 𝕏Mohak Bajaj
@MohakBajaj5 · Original 𝕏 post
@jeremy_develop good catch before it hit the bill. i'd add short-lived presigned upload urls per user plus a cloudflare billing alert, so a leak costs you an evening, not a month
Jeremy replies that setting up Cloudflare billing alerts is his next step to limit the blast radius.
Read on 𝕏Jeremy
@jeremy_develop · Original 𝕏 post
@MohakBajaj5 Exactly! Setting up Cloudflare billing alerts is my next step to minimize the blast radius if I ever mess up again. Really appreciate the reminder!
More to read
Free tier storage fills up with old data: expire KV, R2 and D1 entries with a nightly cron
风易 (@Michael_liyang) says what fills the free tier first is storage, not request quota: KV caches, R2 backups and D1 logs only grow. He sets expiry on cache writes and runs a nightly cron that soft-deletes, confirms and then deletes expired keys and files.
Duncan (@ephraimduncan): card charged $1,264 while $7,032 in Cloudflare startup credits remained.
Duncan (@ephraimduncan) asks who to contact after Cloudflare charged the card $1,264 while $7,032 in startup credits were still available. Cloudflare social media manager Val Vesa replies that it is probably a glitch, asks for a private message with the account email and a billing ticket number so it can be escalated internally and fixed; Cloudflare developer advocate Harshil asks for a DM with details to forward to the team. The author replies that the details are being sent.
A budget alert is a horn, not a brake
@GUYUE_LGY points to Cloudflare’s Budget alerts documentation: alerts send email when spend crosses a threshold but do not pause or cap usage. Before letting AI run unattended, the author checks what actually happens at the line.