Unknown script on website: code from a new outside address
Last reviewed
Your pages now load code from somewhere they did not before.
A new outside script is code your pages now load from a web address that is not your own and was not there before. Most of the time someone added it on purpose: a chat box, a booking widget, analytics or an advertising tag. Occasionally it was slipped in by an attacker to redirect visitors or copy what they type. Finding out who added it, and why, usually takes one or two questions.
Why a new outside script costs you customers
A script loaded from an outside address runs inside your pages with the same reach as your own code. It can change what visitors see, send them somewhere else, or read what they type into a form. A script you approved is simply part of how the site works. One nobody approved could be serving spam redirects or capturing enquiries, and Google lists malicious JavaScript loaded from another site among the problems in its Security issues report, where a flagged site can also find hacked content kept out of search.
What usually causes a new outside script
- Someone added a chat, booking, review or analytics service and pasted its code into the site
- A marketing partner added an advertising or conversion tag, often through a tag manager
- An update to a plugin or theme started loading a file from its maker's servers
- A service you already use moved its code to a new web address
- A weak password or an unpatched plugin let someone inject code into the site
How to check for a new outside script yourself
- Type the address from the alert into your browser and visit its homepage. A legitimate service usually explains what it is, and the name often rings a bell.
- Ask each person with access to the site, and any agency, whether they added a new service recently. Match the address against their answers.
- Open the source code of an affected page (the View page source option in the right-click menu) and press Ctrl+F (Cmd+F on Macs) to find the address. The lines around it often name the service or the plugin that added it.
- If no company clearly owns it, look it up on a free WHOIS site, which shows the public registration record for a domain. A very recently registered domain with no business behind it deserves a closer look.
- An entry under Security issues in Google Search Console means Google has already spotted harmful content on the site.
How to fix a new outside script
- If your team added it: you note what the service is, who holds the account and which pages it should run on, in a simple list of approved services.
- If nobody added it: the developer or hosting firm treats the site as possibly compromised, finds where the script is inserted, removes it, updates WordPress and every plugin, and changes all administrator, hosting and database passwords.
- Your web person: strips out code for services you have cancelled, since each one is code you are trusting someone else to keep safe.
- Your web person: looks at adding a Content Security Policy, a header telling browsers which outside addresses your pages may load scripts from, so a script injected from anywhere else is blocked. Report-only mode logs what would be blocked without blocking it, which makes a safe first step.
- Your web person: adds Subresource Integrity to outside files that never change, such as a pinned copy of a library. It places a fingerprint of the file in the page, and the browser refuses the file if its contents differ. It does not suit scripts a service updates often.
- You: give logins to the site, the tag manager and the hosting account only to those who need them, and close old accounts after every handover.
How Prsona catches a new outside script
Prsona keeps a list of the outside addresses your approved snapshot loads scripts from. When pages begin loading from a new address, and still do on a repeat scan, the finding names that address and every page using it. Anything your team added you can mark as expected.
Prsona looks for a new outside script as part of hacked website detection and website security monitoring.
Get told when your pages start loading scripts from a domain that is new to them.
Questions about a new outside script
How do I find out who owns a script domain?
Visit the domain first: genuine services have a homepage describing what they do. Then search the domain name alongside words such as "widget" or "tag" to see which product uses it. If neither helps, a free WHOIS lookup shows when and through which registrar it was registered, although owner details are often hidden.
Does a Content Security Policy stop hackers?
It limits what an injected script can do, but it does not close the weakness that let the script in. MDN describes it as defence in depth rather than a replacement for fixing that weakness. Pair it with keeping WordPress and plugins current and logins tight.