When a Single Delivery Event Exposed Weaknesses in Coupon Security
In late 2023, CodeBroker completed a global campaign that delivered over 3 billion mobile coupons to customers via SMS and email links. At first glance the project looked like a scale problem: deliver a lot of offers, track redemptions, report ROI. The turning point came the moment operators saw duplicated redemptions at multiple retailers and a cascade of contested transactions. That single event changed everything about how CodeBroker thought about "single-use" coupons.

This case study explains the technical problem, the architectural strategy they adopted, the step-by-step implementation, measured outcomes, and practical lessons. The goal is practical: explain why a signalscv.com design that looks simple - issue a code, mark it used - fails at extreme scale and in the messy real world of mobile links, point-of-sale systems, and human behavior.
The Redemption Security Challenge: Why Simple Tokens Failed
On paper, a single-use coupon is trivial: generate a random code, mark it redeemed when used. In production with millions to billions of claims, a set of hidden problems appear:

- Token copying and reuse: SMS and email links get forwarded, cached, or screenshot. Static codes issued to multiple recipients were reused across transactions. Race conditions at point of sale: two cashiers scanned the same code near-simultaneously; without atomic checks the system allowed both redemptions. Offline redemption paths: some retailers accept codes offline and later reconcile, creating windows where prevention must happen elsewhere. Scale of state: tracking 3 billion unique tokens in a database requires storage, indexing, and fast writes to avoid user-facing latency. Fraud and chargebacks: duplicated redemptions caused merchant disputes, increased refund rates, and damaged trust.
CodeBroker’s initial implementation used opaque alphanumeric codes stored in a central database. The database accepted the first write as redemption, then updated the token status. That worked at low volume but collapsed under concurrent scans, network partitions, and aggressive attackers who tried to redeem the same code simultaneously at different retailers.
A Cryptographic Single-Use Model: Reducing State Without Sacrificing Control
Rather than doubling down on the naive stateful approach, CodeBroker adopted a hybrid model that combined cryptographic token properties with a disciplined redemption ledger. The core ideas:
- Make tokens tamper-resistant and self-validating using an HMAC signature so they cannot be forged. Embed minimal metadata in the token (offer ID, expiry, merchant whitelist) so basic validation can occur without database lookups. Keep a lightweight redemption ledger that records the single-use event and supports atomic checks for concurrent redemption attempts. Design for eventual connectivity: accept offline attempts but validate and reconcile using cryptographic proofs and time windows.
Think of the token as a sealed envelope with the offer printed inside and a tamper-evident tape. Anyone can look at the envelope and know what the offer is, but only the holder who can prove they have the envelope at the right time can redeem it. The ledger is the official stamp that says the envelope was claimed.
Implementing the Single-Use Security Model: A 6-Month Roadmap
Implementation fell into four workstreams: token design, redemption API and ledger, merchant integration, and monitoring + incident response. CodeBroker executed them in parallel over roughly six months.
Month 0-1: Token design and crypto choices
- Selected HMAC-SHA256 with a 256-bit key stored in an HSM-like key vault service for signing tokens. Defined token payload fields: offer_id (32-bit), issued_ts (Unix seconds), expiry_ts (Unix seconds), merchant_id (16-bit), nonce (64-bit). Built a compact base32 encoding so tokens fit into SMS and QR payloads under typical carrier limits.
Month 1-2: Building a stateless validator
- Developed a "stateless validator" library that could verify token signatures and check embedded metadata without any DB call. That reduced latency for routine validation. Implemented strict clock skew rules: validators accept tokens only if issued_ts <= now <= expiry_ts + grace_window. Added merchant whitelist checks embedded in token or queried from a small in-memory cache to guard against cross-merchant reuse. </ul> Month 2-4: Redemption ledger with atomic operations
- Designed the redemption ledger as the single source of truth for consumption. Each ledger record is a mapping of token_id -> redemption_event. Used a Redis cluster with persistent backing for fast atomic compare-and-set (CAS) operations to reserve a token at redemption time. If CAS succeeded, the ledger wrote a durable record to a columnar DB asynchronously for reporting. Implemented idempotency keys and retry logic so POS retries wouldn’t cause duplicate ledger entries.
- Defined an offline redemption protocol for merchants with limited connectivity: accept a cryptographic proof (signed transaction bundle), then submit to CodeBroker for verification and ledger claim within a 48-hour window. Created a reconciliation pipeline to process late submissions, detect duplicates, and settle disputes using timestamps and merchant-provided transaction IDs.
- Built dashboards tracking redemption velocity, CAS contention rates, failed signature checks, and late reconciliation counts. Created runbooks for high contention (e.g., sudden mass-scanning), key rotation events, and merchant dispute handling. Rolled out blue/green deployment for validators to test resilience without disruption.
- Use an HMAC-signed token with minimal embedded metadata. Keep keys in a managed key store and rotate them on a schedule. Implement a fast redemption ledger with atomic operations (Redis CAS, strongly consistent KV store, or a transactional DB with optimistic locking). Build a stateless validator library for front-line systems to validate tokens without DB access. Design an offline redemption protocol with signed receipts and a defined reconciliation window. Instrument key metrics: contention rate (CAS failures per second), token signature failures, offline reconciliations, and chargebacks.