On this page
Gift cards are the only thing you sell that is already money. Nothing ships, nothing is named, and the balance moves the moment a code is known. That changes the attacker's problem: they are not trying to buy something and keep it, they are trying to turn stolen inputs into a clean, resellable balance.
Three attacks account for almost all of it, and they need different answers.
Draining: the balance-check endpoint is the target
Your balance checker is usually a small form that takes a card number and a PIN and answers instantly. No login, no rate ceiling worth the name, and a response that differs depending on whether the card exists. That is an oracle, and it is the softest endpoint most retailers own.
The attack is unglamorous: run millions of candidate numbers through it, keep the ones with money on them, and sell those. The cards were never stolen physically. They were guessed.
Use the same failure response for an invalid number, an incorrect PIN and a card that cannot be shown. Only return a balance after the recipient has supplied the required credentials. Enforce your attempt limit before reading the balance so refused requests reveal nothing about the card. An IP check can contribute context. The public lookup below illustrates what a listed Tor exit can return.
curl -X POST https://maskbreak.com/api/lookup \
-H 'Content-Type: application/json' \
-d '{"ip":"185.220.101.1"}'
{
"ip": "185.220.101.1",
"known": true,
"verdict": "block",
"risk_score": 90,
"signals": { "vpn": false, "proxied": false, "tor": true, "dch": false, "anon": true },
"network": { "asn": null, "org": "Tor exit node", "country": null, "city": null }
}
Try it on your own forms
One call before signup, login or checkout returns allow, review or block; the Free plan includes 10,000 visitor checks a month with no card, and setup starts in watch mode, which logs every decision and blocks no one until you turn blocking on.
Enumeration: why per-IP limits do nothing here
A device can submit requests from several networks. Keep the network limit and count attempts against the device as well. A shared household may use one device for several cards, so give legitimate recipients a way to verify ownership if the limit trips. OWASP covers this use case in its bot management and rate-limiting guidance.
This example allows 20 balance submissions per merchant and resolved device in the hour starting with the first counted attempt. The 21st gets a cooldown. Every HTTP submission, including a retry after a lost response, uses one attempt. Only the credential handler can show a balance. Choose the limit from your own legitimate traffic.
CREATE TABLE IF NOT EXISTS balance_attempts (
merchant_id TEXT NOT NULL,
visitor_id TEXT NOT NULL,
attempts INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
PRIMARY KEY (merchant_id, visitor_id)
);
CREATE INDEX IF NOT EXISTS balance_attempts_expiry
ON balance_attempts(expires_at);
Run the schema once on a persistent SQLite database shared by all processes serving this merchant. With replicas on different hosts, route these writes to the same counter service. The SQLite upsert increments and returns the new count in one statement. Both expiry and the cooldown use the database clock. Schedule DELETE FROM balance_attempts WHERE expires_at <= unixepoch() to remove inactive rows. The next request starts a fresh hour at expiry even if cleanup has not run yet.
function makeBalanceGate(db, maskbreak, merchantId) {
if (typeof merchantId !== 'string' || !merchantId.trim()) {
throw new Error('Configure the merchant for this route');
}
const increment = db.prepare(`
INSERT INTO balance_attempts (merchant_id, visitor_id, attempts, expires_at)
VALUES (?, ?, 1, unixepoch() + 3600)
ON CONFLICT (merchant_id, visitor_id) DO UPDATE SET
attempts = CASE WHEN expires_at <= unixepoch() THEN 1 ELSE attempts + 1 END,
expires_at = CASE WHEN expires_at <= unixepoch() THEN excluded.expires_at ELSE expires_at END
RETURNING attempts, expires_at - unixepoch() AS retry_after
`);
return async function balanceGate(req, res, next) {
const verify = () => res.status(409).json({ next: 'verify_ownership' });
const token = req.body?.monocle;
const fingerprintEventId = req.body?.sentinel_fp;
if (!token || !fingerprintEventId) return verify();
try {
const v = await maskbreak.evaluate({ token, fingerprintEventId });
if (!v || v.test || v.sandbox || v.sample) return verify();
if (v.decision === 'block') return res.status(403).end();
const visitor = v.device?.visitor_id;
if (v.decision !== 'allow' || v.degraded || v.device_evidence !== 'ok' ||
typeof visitor !== 'string' || !visitor.trim()) return verify();
const row = increment.get(merchantId, visitor);
if (row.attempts > 20) {
res.set('Retry-After', String(row.retry_after));
return res.status(429).end();
}
} catch {
return res.status(503).json({ error: 'Balance check temporarily unavailable' });
}
return next(); // The next handler still verifies the card credentials.
};
}
Install the gate before your existing balance handler. Supply the server-side merchant ID from your route configuration, a Node DatabaseSync connection and an initialized Maskbreak server SDK client. The visitor ID comes from the authenticated evaluation. The form sends only the browser evidence for that check and the card credentials for your own balance handler. Keep card numbers and PINs out of the counter and its logs.
A missing device or a review sends the recipient to your separate ownership-verification flow. That flow must verify the customer before showing a balance. An unavailable API, exhausted API quota or unavailable counter returns a temporary failure. The balance handler runs only for an allowed, complete visit under the limit.
Laundering: buying cards with stolen cards
The third attack runs in the other direction. Rather than draining your cards, the attacker buys them with a stolen payment card, because a gift card converts a card that will be charged back into a balance that will not be. Your chargeback arrives six weeks later; the code was resold on the day of purchase.
This is the one where the fraud check has to sit at purchase, not redemption, and where the useful signals are the ordinary ones — a datacenter or tunnelled connection at checkout, a device that has bought gift cards under several different accounts, a billing country that has never matched this device before.
The tell that separates it from ordinary card testing is the basket. Card testing wants the cheapest possible authorisation. Gift card laundering wants the highest denomination that will clear, often several at once, and it does not care about anything else in your catalogue.
Where to put the checks
Three surfaces, in the order they are worth doing.
- Balance check. The highest-volume, lowest-friction target you own, and the one that is usually completely unguarded. Uniform responses plus a device-keyed velocity counter.
- Gift card purchase. Where laundering is stopped, and where a review verdict should cost the buyer a verification step rather than the sale.
- Redemption. Worth logging, rarely worth blocking. By redemption the money has usually already moved, and the person holding the code is often the innocent recipient of a resold card.
That last point is the one teams get wrong. Blocking at redemption feels like enforcement and mostly punishes a customer who bought a card in good faith from a marketplace. The decision belongs earlier, where the attacker is, not later, where the victim is.
Keep the recipient out of it
Gift cards are given to people who are not your customers yet. They arrive with no account, no history, and no patience, often on a phone, often on a shared network. Anything that treats an unfamiliar device as suspicious by default will land hardest on exactly the person you most want to convert.
Route on the decision rather than the score: block the unambiguous, add a step for the uncertain, and let everything else through untouched. A first-time device on a residential connection with no velocity behind it is the normal case, not the risky one.
What this does not solve
None of this recovers balances already drained, and none of it helps if your card numbers are sequential or your PINs are short. Guessability is a design problem, not a detection problem: enough entropy in the code space makes enumeration uneconomic before any of this runs. Detection buys you the time to fix that, and catches the campaigns that come anyway.
Questions people ask
- Why does rate limiting the balance-check endpoint not stop gift card draining?
- A per-IP limit covers only requests from that address. Record each attempt atomically in a time-limited counter scoped to the merchant and a server-verified identity. If the device cannot be resolved or the counter is unavailable, use a verified ownership check before disclosing a balance.
- Should I block gift card redemption if the risk score is high?
- Usually not. By redemption the money has generally already moved, and the person holding the code is frequently an innocent buyer who got a resold card from a marketplace. Blocking there punishes the victim rather than the attacker. Put the decision at balance check and at purchase, and treat redemption as something to log rather than refuse.
- How is gift card laundering different from card testing?
- Card testing wants the cheapest authorisation that proves a stolen card works. Gift card laundering wants the highest denomination that will clear, often several at once, and ignores the rest of your catalogue. Both arrive at checkout with a stolen card, but the basket shape is the tell, and laundering converts a chargeback-able card into a balance that is gone the same day.
- Does a uniform balance-check response really matter?
- Yes. A failed check should return the same generic response for an unknown card, a wrong PIN or another failed credential. After verifying the recipient’s credentials and applying the attempt policy, the service can show the authorized recipient their balance.
Put the check where the attack enters
One call before signup, login or checkout returns decision, risk_score and the reasons behind them. The Free plan includes 10,000 visitor checks a month with no card, and setup starts in watch mode, so nothing is blocked until you turn blocking on.



