Skip to main content
CriticalContentOWASP A05:2021CWE-200

How to fix: Credit Card Number Pattern

A Luhn-valid number carrying a card-network prefix appears in the page source next to payment vocabulary: a card-number label, a billing or checkout field, CVV, or an expiry date. Luhn is a single check digit, so a card-shaped number with no payment context (an order reference, a tracking number, a row of figures in a table) is not reported.

Why it matters

PCI DSS violation, data breach.

Card numbers should never appear in HTML. The detection requires three things together: a card-network prefix and length, a passing Luhn checksum, and payment vocabulary within about 120 characters. Published processor test cards are excluded, and so is a card-shaped window carved out of a longer run of separated digit groups.

How to fix it

  1. 1Never display full card numbers, mask or tokenize.

Code examples

Never store raw card numbers: use a payment processor

TypeScript
// NEVER store raw credit card numbers: PCI DSS violation
// Use a tokenization service:

// Stripe: card number goes directly to Stripe servers
import { loadStripe } from "@stripe/stripe-js";
const stripe = await loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY!);
const { paymentMethod } = await stripe!.createPaymentMethod({
  type: "card",
  card: cardElement, // card number never touches your server
});
// Store paymentMethod.id (a token), not the card number

References

Detected automatically by VulnRadar. The check id is credit-card-pattern, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is Credit Card Number Pattern?
VulnRadar rates this critical severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id credit-card-pattern, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Credit Card Number Pattern map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for credit card number pattern

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Credit Card Number Pattern | VulnRadar