Skip to content
Crypto Write-up Intermediate

Stealing a $500 Gift Card With Nothing But a Timestamp

Gift card codes were generated by a weak linear congruential generator seeded with the purchase timestamp, which the app returned to the millisecond. Anyone who could read that timestamp could rebuild the code offline and redeem another user's card from any account that was not the buyer.

medium.com

Published on medium.com

You’re going to take a $500 gift card that belongs to someone else and spend it from your own account. The card’s code isn’t random.

OopsSec Store, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code was produced by a non-cryptographic pseudo-random generator seeded with an attacker-visible millisecond timestamp, so the output was fully predictable.

Impact

Any account other than the buyer could redeem the rebuilt code and gain the card's full value as store credit, without being the recipient and without paying.

What the attacker needed

Local lab instance running; access to the buyer's card list; a second account to redeem

The fix

The code should be generated from a cryptographically secure random source with no seed, the millisecond timestamp should not be exposed, and codes should be hashed at rest.

How it was found

  1. Log in as the buyer and fetch her gift cards from the API to read the card's createdAt value to the millisecond.
  2. Run the same generator maths offline with that timestamp as the seed to produce the 12-character code.
  3. Log in as a different account and submit the rebuilt code to the redeem endpoint.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A gift card code is meant to be a secret, like a password. Here the shop built the code with a simple maths recipe that always gives the same answer for the same starting number, and that starting number was the time of purchase, which the site showed to anyone. So a person could work out the secret code on their own computer without ever seeing it.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.