Skip to main content
All Terms Glossary

1st-Party script

Definition

First-party scripts are pieces of JavaScript served directly from a website's own domain. They're typically under the control of that site's development team, making them simpler to audit and manage. Because the site itself hosts them, administrators can use internal code reviews, version control, and strict security headers (such as Content Security Policy) to reduce vulnerabilities. However, even first-party scripts may contain security flaws due to dependency chains, which are typically compiled via a package manager. In a client-side security context, properly vetting and updating first-party code is crucial to defending against attacks like cross-site scripting (XSS) and data exfiltration.

What first-party scripts are

A first-party script is JavaScript served from a site's own domain and, in principle, controlled by that site's own team. Because the organisation hosts and ships the code, it can apply the full range of internal controls: source review, version control, a build pipeline, and security headers such as Content Security Policy. First-party scripts handle a site's core behaviour, forms, interactivity, and application logic, and are usually the code a team trusts most. In practice, though, most first-party bundles are assembled from open-source packages pulled in through a package manager, so the code that actually ships includes many dependencies the team did not write itself.

Why first-party scripts still carry risk

Trusted does not mean safe. A first-party script inherits every vulnerability in its dependency tree, so a compromised or malicious npm package becomes first-party code at build time, a software-supply-chain path behind several real incidents. First-party code is also a frequent XSS sink: if it inserts untrusted input into the DOM or evaluates dynamic strings, it hands attackers execution under the site's own origin. And on a payment page the browser cannot tell first-party from third-party, both execute with the same access to form fields and cookies, so a flaw in first-party code exposes exactly the data an attacker wants.

Securing first-party scripts

Vet dependencies with lockfiles, audits, and pinned versions, review and encode any code that writes to the DOM, and use a strict CSP so an injected script has limited reach. Subresource Integrity guards code you load from a CDN. For compliance, PCI DSS 6.4.3 requires an inventory and authorisation of every script on payment pages, first-party included, and 11.6.1 requires detecting unauthorised changes to them. cside monitors the scripts that actually execute in the browser and analyses their behaviour, so a first-party bundle that starts reading card fields or contacting an unfamiliar domain, whether through a poisoned dependency or an injection, is flagged, can be blocked in real time, and is recorded for forensics.

Definition

Are first-party scripts safer than third-party scripts?

Generally yes, because you control the source, hosting, and release process, but not automatically. First-party bundles usually include third-party dependencies pulled from package managers, so they inherit supply-chain risk. The advantage is control and auditability, not inherent immunity from compromise or vulnerabilities.

Definition

Does PCI DSS treat first-party scripts differently from third-party ones?

No. Requirements 6.4.3 and 11.6.1 apply to every script that executes on a payment page regardless of origin. You must inventory and justify each one, first-party included, and be able to detect unauthorised changes to it, because the browser gives them all the same access to sensitive fields.

Got more questions

Talk to a security expert

We answer client-side security questions every day. Bring yours.

Book a demo

Want to walk through this with an engineer?

Thirty minutes, on your own site. Not a slide deck.

Book a personalized demo to see:

How to achieve PCI DSS requirement 6.4.3 & 11.6.1 compliance in 1 day
Why third-party scripts are a security risk for you and your visitors
Monitoring privacy and consent leakage (GDPR, CCPA) across every third party
Stopping signup abuse, account sharing, and chargeback fraud with device intelligence
Detecting and controlling AI agents and bots hitting your site in real time

Rather just send a question?

Finding open slots…

Real humans only. We'd know.

Having trouble booking? Open scheduler in a new tab

What are you trying to solve?

Tell us in a line and we'll come back with something useful, not a generic pitch.

We usually help with:

Seeing which third-party scripts run on your site
PCI DSS 6.4.3 and 11.6.1 evidence
Bots, AI agents and account takeover

Prefer to just book a time? Pick a slot instead