CCyberwiki

Card testing

Card testing
ClassAvailability and abuse
Also known asCarding, card checking, account testing, enumeration, card stuffing
Automated threatOAT-001 Carding
CWECWE-799: Improper Control of Interaction Frequency
Typical severityMedium to High
AffectsPayment forms, card-saving forms, donation forms with a free amount, guest checkout, payment API routes

Stolen card data is of unknown quality until someone finds out which cards still work.1 Card testing is that sorting step: a script submits each card to a real merchant's payment or card-saving form and records whether the issuer approves or declines it.2 The approved cards are then used for purchases or sold again, and the merchant whose form did the checking is left with fees, disputes and a worse standing with the card networks.2

How a run works

The cards come from a breach at another application, from a different payment channel, or from a criminal marketplace.1 Automated testing of payment fields causes over a billion dollars a year in fraud losses across the payments system, and its most common target is a legitimate online shop with weak fraud controls.3

A script can test a card in two ways. Saving a card runs a validation with the issuer, and these checks often never show on the cardholder's statement, so testers prefer this route. The other way is a real payment for a small sum, which a cardholder is less likely to spot.2 The card networks also have a dedicated check: Visa's account verification request is an authorization for an amount of zero.3 Attack payments are often under 10 US dollars.3 Donation forms that accept any amount are a favoured target.3

A payment provider's publishable key sits in the page by design, and a script can use it to retry a large number of payments through the site.2 When the expiry date or security code is missing and has to be guessed, the related attack is called card cracking.1

Cost to the merchant

Some test payments succeed. Cardholders who see them report fraud, which produces early fraud warnings and chargebacks. The flood of declines raises the merchant's decline rate, issuers start to treat all its payments as riskier, and real customers can keep being declined after the testing has stopped. Authorization and dispute fees add up, a large volume can put the account into the card networks' monitoring programs, and the fake payments show up as new customers, which hides the true growth of the business.2

freeCodeCamp, January 2020

On 8 January 2020 the nonprofit freeCodeCamp, which usually gained 20 or 30 new donors a day, found 11,000 new customers and more than 60,000 dollars of donations in its Stripe account from one 24-hour period. One person had tried 20,000 stolen cards; Stripe declined all but 3,537. The team turned off the API route the script used. At Stripe's chargeback fee of 15 dollars at the time, the approved charges exposed the organisation to about 53,000 dollars. Refunds stalled after about 1,200 because automatic daily payouts had already sent 40,000 dollars towards the bank; all 3,537 were refunded later. The founder's first lesson was to turn off automatic payouts.4

Signs in the payment logs

Most attacks are visible in the provider's dashboard as a spike in failed or blocked payments, a spike in API requests that fail with HTTP 402 and the decline code generic_decline, and many low-value payments carrying nonsense names and email addresses.2 Other signs are a large volume of approvals or declines on similar card number ranges, and reversals sent straight after an approval.3 Aggressive automatic retries of failed subscription payments can produce a similar pattern of many attempts with a low success rate.2

Defences

Testers use many techniques, so a firewall rule or a filter on a single signal such as the IP address rarely stops them alone.2

Hosted payment pages

Stripe Checkout and the current Payment Element come with rate limiters, AI models, CAPTCHA triggers and ongoing reviews, and payments they stop are marked Blocked by Stripe. These controls work better when the integration sends the customer's IP address, email and name.2

A challenge checked on the server

The CAPTCHA has to be required on every request that can check a card or start a payment.3 A widget in the page proves nothing by itself, since a script can post any string as the token. With Cloudflare Turnstile, the server sends the token to the Siteverify endpoint, and each token is valid for 300 seconds and meant to be used once.5 See CAPTCHA and bot protection.

// Node.js: verify the Turnstile token before any card or payment call
const r = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    secret: process.env.TURNSTILE_SECRET,
    response: req.body["cf-turnstile-response"],
    remoteip: req.ip,
  }),
});
const { success } = await r.json();
if (!success) return res.status(403).end();
// only now create the PaymentIntent or SetupIntent

Fewer ways in

Guest checkout makes testing easier. Requiring a login or a validated session before payment narrows access, and CSRF tokens stop some simpler scripts.2

Limits on what testing needs

Useful rate limits count the things a tester has to create: new customers per IP address per day, cards added per account and per session, purchases of the same product.23 Combined with a challenge, the first attempt from an address goes through and later ones for some hours need a CAPTCHA.2 On Stripe plans with custom Radar rules, a rule takes the form {action} if {condition},6 and the attribute below counts the cards seen from one IP address in the past hour, including card setups. The threshold of 3 is an example. Many iCloud Private Relay users can share one address and push the same counter up.7

Block if :card_count_for_ip_address_transactions_hourly: > 3

Payment settings

Requiring the security code and the address check on every online card payment makes guessing slower and dearer, and a donation form should set a minimum amount as high as its donors accept.3

Keys

A leaked secret key lets testers create payments and save cards without the form at all.2 If an attack goes straight to the API rather than through the form, roll the keys.3 Key handling for a Stripe integration is in Securing Stripe payments; leaked keys in general are in Exposed credentials in source code repositories.

After an attack

Refund the test payments that got through, which heads off disputes, and stop retrying cards attached to the fake customers, since each retry repeats the attack.2

Prompt for a coding agent

Review every route in this project that creates a payment, saves a card or creates a payment customer (for Stripe: PaymentIntent, SetupIntent, Customer). For each one: require a CAPTCHA token (Cloudflare Turnstile or reCAPTCHA) and verify it on the server before calling the payment provider; add per-IP and per-account limits on new customers and on cards added; require a signed-in or validated session where the product allows it; pass the customer IP address, email and name to the payment provider. On donation forms with a free amount, set a minimum amount. Check that no secret payment key appears in client code. List each route you changed and anything you could not change.

In SecFlash

On the Exposure page, SF-EXP-306 lists public keys found in the page, Stripe publishable keys among them, and SF-EXP-301 reports a secret key in public JavaScript. SF-EXP-208 on the same page reports API calls with no rate limit, and SF-CLD-307 on the Cloud page reports a Cloudflare zone with no rate limiting rule.

See also

References

  1. a b c OWASP Automated Threats to Web Applications (n.d.). "OAT-001 Carding". OWASP Foundation.
  2. a b c d e f g h i j k l m n Stripe (n.d.). "Protect yourself from card testing". Stripe Docs.
  3. a b c d e f g h i Visa (June 2026). "Enumeration Mitigation and Considerations for Merchants", V1.3. Visa.
  4. back Larson, Q. (January 2020). "How I Stopped a Credit Card Thief From Ripping Off 3,537 People". freeCodeCamp.
  5. back Cloudflare (n.d.). "Validate the token". Cloudflare Turnstile docs.
  6. back Stripe (n.d.). "Rules reference". Stripe Docs.
  7. back Stripe (n.d.). "Supported attributes". Stripe Docs.