Case study (hypothetical): the 'View receipt' links in payment emails that expired after 7 days
Scheduled broken-link and redirect checks that tell you the moment a link breaks — linkbruno.com This is a hypothetical case study, built from a pattern that shows up in a lot of billing systems. The company and number
Scheduled broken-link and redirect checks that tell you the moment a link breaks — linkbruno.com
This is a hypothetical case study, built from a pattern that shows up in a lot of billing systems. The company and numbers are invented.
The setup
A small B2B SaaS company billed around 2,000 customers monthly. After each successful payment, it sent a receipt email with a big "View receipt" button. The button linked to a page showing the invoice and a PDF download.
The link looked like this:
https://app.example.com/receipts/inv_8731?expires=1700000000&sig=4b9f...
It was a signed URL: the server computed an HMAC over the invoice ID and the expiry time, and the receipt page accepted the request only if the signature matched and the expiry hadn't passed. No login was needed, which was the point. The person reading the email was often not the person with an account.
The expiry was set to seven days. Someone had copied the value from the password reset email, where seven days is generous.
What went wrong
Receipts are not password resets. Nobody uses a receipt link in the first seven days. People use them:
- At the end of the month, when the finance team collects receipts for expense reports.
- At the end of the quarter, for bookkeeping.
- At year end, when an accountant asks for every receipt from a supplier.
- During an audit, sometimes years later.
In every one of those cases, the "View receipt" button went to a page saying "This link has expired." There was no way forward from that page: no login link, no "send me a fresh link" button, no mention of where else to find the receipt.
Customers did what people do. They emailed support. "Your receipt links don't work." Support replied with the PDF attached, closed the ticket, and moved on. Each ticket looked like a one-off.
Why it took a year to notice
No link checker would have found it. A crawler or monitor that requested a receipt URL during the first week would get a 200. The links weren't broken when they were sent; they broke on a timer.
Support tagged the tickets as "billing question". About 40 tickets a month, which nobody connected because they arrived spread out, with different wording, mostly from people who weren't the main account contact.
The expired page returned 403. Nothing alerted on 403s from the receipt route, because 403 is also what you'd expect from someone tampering with a signature. The logs showed a steady stream of them with no one looking.
It was found when a large customer's finance department sent a formal complaint: they'd needed 140 receipts for an audit and every link had failed.
Expiring links are easy to miss until a customer complains. linkbruno.com rechecks the same URLs on a schedule and alerts you when a receipt or account link starts failing.
The fix
The team made four changes.
1. Separate the link's lifetime from the receipt's lifetime
The signed link now lasts 13 months instead of 7 days. A receipt is low-sensitivity compared with, say, account access: it contains the company name, the amount and the last four digits of the card. The team decided that someone who has the email can reasonably keep seeing the receipt for a year.
2. Make the expired page useful
When a link does expire, the page no longer dead-ends. It says what happened and offers two ways forward: a button to email a fresh link to the address the receipt was sent to (never to an address typed on the page), and a link to the billing section of the app for anyone who can log in.
That single change would have prevented almost all of the support tickets, even with the original seven-day expiry.
3. Attach the PDF to the email
The receipt email now includes the PDF as an attachment. Finance teams forward emails into expense tools and archives; an attachment survives that. A link only works as long as the server agrees.
4. Measure link failures on routes that matter
The team added a dashboard panel for 403 and 410 responses on the receipt, invoice and download routes, with the reason (expired, bad signature, not found). Expired-link hits from real users are a product problem, not a security event, and they're now visible.
How to test expiring links
The team added a test that would have caught the original bug in a minute. It generates a receipt link with the real signing code, then calls the receipt route with the server's clock set 35 days, 6 months and 14 months ahead (using a fake clock in the test, not by changing the system time). The first two must show the receipt. The third must show the friendly expired page with the "email me a fresh link" button, and must not reveal any invoice details. The same pattern works for any signed URL: download links, unsubscribe links, invitation links and magic login links all deserve a test at the age people actually click them.
What I'd take from it
- Expiry is part of a link's design. Pick it based on when people will actually use the link, not on the last expiry value you set somewhere else.
- A link in an email is a promise that outlives the email. Receipts, invoices, contracts and downloads get opened months or years later.
- Never dead-end an expired link. Offer a safe way to get a fresh one.
- Some broken links are time bombs. Link checkers verify a link at one point in time. For links that expire, test them at the age people actually use them, which in this case was a request made with a link signed 35 days earlier.
Tools like linkbruno.com are good at telling you which links are broken right now. Expiring links need one extra test in your own suite: generate a link, move the clock forward, and check what the user sees.
Related reading
- How to check every link in your npm package before you publish (README, homepage, repository and bugs)
- Every URL in your error messages is a promise: a 10-point checklist for links baked into software
- You fixed the link, but it's still broken: how cached 404s and redirects outlive your fix
- Soft 404s: your 'page not found' returns 200, and your link checker thinks it's fine
How long do the links in your transactional emails last? And what does someone see when they click one after it expires?
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.