Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Card numbers in logs or URLs: how to find and remove them

OPS-369High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A card number, also called a PAN (primary account number), should only ever travel from the customer's browser to your payment provider. If the full number shows up anywhere else, you have this issue. Common places are: the page URL (?card=4242...), web server access logs that record that URL, application or error logs that dump the request body, browser history and referrer headers, and analytics or ad tracking requests.

Why it costs you leads or sales

Leaked card data is a security incident, not just a tidy-up job. It can bring card-brand fines, a forced audit, higher processing fees or the loss of your merchant account. Customers whose cards are exposed may be hit by fraud and stop buying from you.

How a card number leaks
  1. Customer types cardForm on your own page
  2. Sent in URL (GET)?card=4242...
  3. Server and CDN logsPAN stored in plain text
  4. Analytics and ad tagsPage URL sent to third parties

The leak starts at the form and spreads to every system that records the URL or request.

How to check if your site has it

Look for card numbers by hand
  1. Use a test card in your checkout

    Only in your payment provider's test mode, enter a documented test number such as 4242 4242 4242 4242. Never use a real card.

  2. Watch the address bar and Network tab

    Open browser DevTools, go to Network, and submit. Check every request URL for the number or its digits. Look at query strings and redirects.

  3. Search your logs

    Search access and application logs for the test number and for any 13 to 19 digit sequence.

  4. Check analytics

    In GA4 DebugView or your tag manager's preview mode, inspect the page_location and any custom parameters for card digits.

Search logs for the test card and for card-like numbersbash
grep -rn "4242424242424242" /var/log/nginx/ /var/log/apache2/ 2>/dev/null
grep -rEn "[0-9]{13,19}" /var/log/nginx/access.log | head

How to fix it

Remove the source, then clean up
  1. Stop card entry on your own page

    Use your payment provider's hosted fields or hosted checkout so the number goes straight to them and never touches your server.

  2. Use POST, never GET, for sensitive forms

    A form with method="get" puts every field in the URL. Change it to method="post" or remove card fields from your form.

  3. Turn off request-body debug logging

    Disable verbose logging of payloads on checkout routes and in any plugins.

  4. Mask or drop data in logs and tags

    Add a masking rule so digit sequences are redacted, and stop tags from reading form fields.

  5. Purge existing copies

    Securely delete or redact old logs, backups and analytics data that contain card numbers. Ask your host and analytics provider how, and tell your payment provider if real cards were exposed.

Platform-specific steps
  1. Check payment plugins

    Use a gateway plugin that uses hosted fields or redirects to the provider. Avoid plugins that post raw card fields to your server.

  2. Disable debug logging

    Set WP_DEBUG_LOG to false and turn off the gateway plugin's debug or log option under its settings (for WooCommerce, WooCommerce > Status > Logs).

GTM custom JavaScript variable: page URL with long digit runs removedjavascript
function() {
  return {{Page URL}}.replace(/\d{13,19}/g, '[redacted]');
}
Log the path without the query string on checkoutnginx
log_format nocard '$remote_addr [$time_local] "$request_method $uri" $status $body_bytes_sent';
location /checkout {
    access_log /var/log/nginx/checkout.log nocard;
}
Before and after

Leaking

  • Card field posted with GET
  • PAN stored in access logs
  • Full URL sent to analytics

Fixed

  • Hosted field sends card to the provider
  • Logs hold no digits
  • Tags receive a redacted URL

How to confirm it's fixed

Confirmation checklist
  • A test purchase in test mode shows no card digits in any URL in DevTools
  • Searching fresh logs for the test number returns nothing
  • Old logs and backups containing PANs are deleted or redacted
  • Analytics DebugView shows clean page_location values
  • Tag manager preview shows no tag reading card fields
  • Your payment provider has been told if real cards were exposed

How to prevent it happening again

Prevention
  • Use hosted fields or hosted checkout only
  • Review every new plugin, app or tag that touches checkout pages
  • Keep debug logging off in production
  • Run a scheduled log search for 13 to 19 digit sequences
  • Set log retention limits
  • Re-test checkout after each theme, plugin or tag change

How FunnelGuard handles this

FunnelGuard detects this issue only partly. Its check (no_pii_in_tracking) looks at the tracking hits the robot visitor sends to ad and analytics platforms while it runs your journey, and flags personal data that appears in them. That can catch a card-like value or other sensitive data travelling in a tracking request.

Questions people ask

Why are card numbers showing up in my URL?

Usually the form uses method="get", so every field is appended to the URL. It can also come from a redirect that passes form values along. Switch to POST and use your payment provider's hosted fields so the card never reaches your page.

Is it against PCI-DSS to have card numbers in server logs?

Generally yes unless the PAN is rendered unreadable, and the security code must never be stored after authorisation. Logs are a common place for accidental storage. Check with your payment provider or assessor for your exact obligations.

How do I find credit card numbers in my log files?

Search for known test numbers and for 13 to 19 digit sequences using grep or your log tool. Expect false positives such as timestamps and order IDs, so review matches carefully. Never copy real numbers into tickets.

How do I remove card numbers from old logs?

Securely delete or redact the affected files and any backups, and ask your host or log service how to purge them. Fix the source first so new data is not written. If real cards were exposed, inform your payment provider.

Can card numbers leak into Google Analytics?

Yes, if the number is in the page URL or a tag reads form fields, it can be sent as page_location or a custom parameter. Redact URLs in your tag manager and stop tags reading checkout inputs.

Does using Stripe or PayPal fix this?

Hosted fields and hosted checkouts keep the card number off your server, which removes the main source. You still need to check logs, tags and custom code so nothing else captures card data.

Can FunnelGuard find card numbers in my logs?

No. FunnelGuard checks tracking hits for personal data during its journey runs but does not read server logs. You need to search logs yourself.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: no_pii_in_tracking.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.