Audit Third-Party Scripts
Third-party scripts are pieces of code loaded from external domains into a payment page, checkout flow, or account area. They can run in the same browser session as card entry, observe page content, and send requests to their own servers. PCI DSS risk rises when those scripts can access cardholder data, influence the checkout experience, or create unclear data flows that auditors cannot trace.
A common example is a marketing tag manager that loads multiple vendors’ JavaScript on the checkout page. Even if the tag vendor never receives the full card number, the script can still capture metadata such as form field values, billing address fields, or error messages that reveal partial card data. Another example is a customer support widget that records page interactions for troubleshooting; if it records DOM content, it may capture sensitive inputs unless it is configured to redact them.
PCI DSS focuses on protecting cardholder data and reducing exposure across systems and processes. For web applications, that means you need evidence that third-party components do not access cardholder data, do not expand the scope of the Cardholder Data Environment (CDE), and do not weaken compensating controls. This audit is not a one-time checklist; it is a repeatable method that matches how scripts change over time.
Main Problems And Pain Points
Teams often audit third parties by reading vendor marketing pages or reviewing a single contract clause. That approach misses the technical reality: scripts can change behavior through configuration, remote updates, or conditional logic based on page content. A vendor can also provide a “PCI-friendly” integration guide that assumes a specific page structure, then your site diverges from it.
Another frequent failure is treating “no card number sent” as the whole story. PCI DSS scope can expand through other cardholder data elements, such as full magnetic stripe data, CVV, or data elements used to authenticate transactions. Even when full PAN never leaves the browser, scripts can still capture CVV if they read form fields before your client-side masking runs, or if the masking is cosmetic rather than enforced.
Dependencies complicate the audit. A tag manager may load scripts from multiple domains, and those scripts may load additional sub-resources. Content Security Policy (CSP) rules, browser caching, and service worker behavior can also affect what runs. In one audit I reviewed (tooling version noted as OWASP ZAP 2.14.0), the scanner flagged a “third-party” request, but the request was actually triggered by a cached service worker from a previous deployment, which made the timeline confusing.
Solutions And Advice
Map Script Sources And Flows
Start with an inventory that is tied to actual runtime behavior. Collect every script tag and dynamic loader used on pages that might be in scope: payment form pages, checkout steps, and post-payment confirmation pages that still display billing details. Include tag manager containers, A/B testing scripts, analytics, customer support widgets, and fraud tools.
Then map data flows. Identify which DOM elements each script can read, which network endpoints it calls, and whether it can access form inputs. Use browser developer tools to capture a HAR file during a controlled checkout test, and record the exact page URL, environment (staging vs production), and timestamp. A small but useful habit: save the HAR with a filename that includes the deployment build number, because script bundles often change without obvious UI changes.
Test For Card Data Exposure
Use runtime testing to validate that third-party scripts do not read or transmit sensitive fields. In staging, run a checkout flow with test card data from your payment provider and instrument the page to detect access to sensitive inputs. Practical methods include adding client-side hooks that log reads of specific input fields (PAN, CVV, expiry) and monitoring outbound requests for those values.
Network monitoring matters because scripts can exfiltrate data through query parameters, request bodies, or even error reporting. Review requests for patterns such as long digit sequences, CVV-like lengths, or billing address fields being sent to unexpected domains. Tools like OWASP ZAP, Burp Suite, or browser-based request capture can help, but you still need manual review of the captured payloads.
Set realistic expectations: you may not catch every issue with automated scanning. A script might only run after user interaction, after a specific error occurs, or only for certain geographies. Plan at least one test session that includes validation errors (for example, entering an invalid expiry date) because error messages can trigger logging code paths that capture field values.
Constrain With Browser Controls
Use CSP and other browser controls to reduce what third-party scripts can do. CSP can restrict script sources, connect endpoints, and form actions. When you tighten CSP, you gain evidence: if a script tries to call a blocked endpoint, you can detect it and decide whether the integration is safe.
Also review tag manager settings and script loading conditions. Many tag managers support rules like “only load on non-checkout pages” or “disable on payment steps.” If your checkout flow uses multiple routes, confirm that the rules match the exact routes and query parameters used in production.
Outcome targets should be measurable: for example, reduce the number of external “connect-src” destinations on checkout pages, and document the CSP changes with dates. One team I worked with (noting CSP policy revision date as 2026-03-18) reduced outbound endpoints from 22 to 9 on the payment step, which made later audits far less ambiguous.
Document Vendor Responsibilities
PCI DSS requires governance around third parties that affect cardholder data. Collect the vendor’s integration documentation, data processing terms, and any statements about what data the script receives. Then verify those claims through your own testing and code review.
For each third-party script, document: the purpose, the integration method, the data elements it can access, and the controls you use to prevent access to cardholder data. If the vendor provides a “redaction” or “no recording” mode for support widgets, confirm the configuration in your environment and keep a screenshot or exported configuration record.
Auditors often ask for evidence that you manage changes. Track script version identifiers when available, and record who approved changes to tag manager containers. A lightweight change log with timestamps and ticket IDs can reduce friction during assessments.
Case Examples
Scenario 1: Tag Manager On Checkout
A retailer loads a tag manager container on the checkout page. The container includes analytics and a session replay script. During staging testing, the team captures a HAR file and finds that the session replay vendor receives DOM snapshots that include billing form fields. The team disables session replay on payment routes and adds a CSP rule that blocks the replay vendor’s connect endpoints on those routes. After retesting, the replay vendor still loads but sends only anonymized events without form field content.
Scenario 2: Customer Support Widget Recording
A subscription site embeds a customer support widget on the payment page. The widget is configured to record user interactions, and the integration guide claims it masks sensitive fields. Runtime testing shows that masking applies to visible input values but not to underlying DOM attributes used for validation. The team updates the widget configuration to disable recording on payment steps and adds client-side logic to prevent sensitive fields from being present in the DOM in a way the widget can read. The site then documents the configuration and retests the error path where users enter an invalid CVV.
Comparison Table And Checklist
| Audit Method | What It Catches | Typical Gaps | Evidence To Save |
|---|---|---|---|
| Script Inventory | Which third parties run on which pages | Scripts that load conditionally or via sub-resources | Page list, tag manager export, HAR domain list |
| Runtime Testing | Whether sensitive fields appear in requests or logs | Edge cases like validation errors and retries | HAR files, request payload review notes, test steps |
| CSP And Controls | What scripts can call and where they can load from | Misconfigured policies that block too much or too little | CSP policy versions, blocked endpoint logs |
| Vendor Documentation Review | What the vendor claims about data handling | Claims that do not match your integration | Contracts, integration guides, configuration screenshots |
Step-by-step checklist for a PCI-focused script audit
- List every script loader on payment and checkout routes, including tag managers and dynamic imports.
- Record the exact domains contacted during a test checkout using HAR capture.
- Identify which scripts can access form inputs or page DOM content.
- Run tests that include both successful payment and validation error paths.
- Search captured requests for sensitive patterns and verify no sensitive values appear.
- Tighten CSP for checkout routes and confirm blocked calls do not break checkout.
- Document vendor responsibilities and your configuration choices with timestamps.
- Track changes to tag manager containers and script bundles with an approval trail.
Common Mistakes
Teams often audit only the production checkout page and ignore staging, preview environments, and customer support pages that show billing details. Scripts can differ across environments due to different tag manager containers or feature flags, so evidence from one environment does not cover another.
Another mistake is relying on “masked” fields without checking what the script can read. Masking can be visual only; a script can still access underlying values in the DOM or in JavaScript variables. If you see client-side masking, test whether the sensitive value still exists in memory or in request payloads before it reaches the payment provider.
Auditors also see weak documentation when teams say “we block it with CSP” but cannot show the policy version used during the test. CSP changes should be tied to a deployment and a date, because a later change can reintroduce outbound destinations.
FAQ
Do Third-Party Scripts Expand PCI Scope?
They can. If a script can access cardholder data or if you cannot clearly demonstrate that it does not, auditors may treat the systems involved as part of the Cardholder Data Environment or require compensating controls.
What Evidence Do Auditors Expect?
Expect an inventory of scripts on relevant routes, runtime test results showing no sensitive values in requests or logs, and documentation of browser controls like CSP plus vendor integration/configuration records.
Can We Rely On Vendor “PCI Compliant” Claims?
Vendor statements help, but they do not replace verification. You still need to test your specific integration because configuration, page structure, and conditional loading change what the script can access.
How Do We Test Without Using Real Card Data?
Use payment provider test cards and staging environments, then instrument the page and review captured network traffic for sensitive patterns. Avoid logging real PAN/CVV values in any environment.
What If A Script Breaks Checkout After CSP Changes?
Roll back the CSP change and narrow the policy using observed required endpoints from HAR captures. Document the iteration, because repeated policy tuning with evidence shows controlled risk management.
Author's Insight
PCI DSS web scope problems often come from unclear data flows rather than from obvious “card number in the URL” bugs. Third-party scripts can read page content, trigger logging, and send requests to multiple domains, which makes runtime testing and evidence collection more reliable than documentation alone.
When teams audit scripts, the most useful artifacts are usually HAR captures tied to a deployment, a domain allowlist derived from those captures, and a CSP policy version that matches the test window. If you cannot reproduce the behavior, you cannot defend the conclusion.
Script audits also benefit from a change-management habit: tag manager container updates and widget configuration changes should be tracked like code changes, because they often alter behavior without a visible UI release.
Key Takeaways
- Inventory third-party scripts by actual runtime behavior on checkout and payment-related routes.
- Validate with runtime tests that sensitive fields do not appear in outbound requests or recorded content.
- Use browser controls like CSP on payment routes and tie policy versions to specific deployments.
- Document vendor integration details and your configuration choices, then track changes over time.