Your Code Is Mostly Other People’s Code – A Developer’s Guide to Securing Dependencies
Written by Al-Amin Ajao, Software Engineer
On 8 September 2025, attackers took over the npm account of a developer who maintains some of the most widely used JavaScript packages. He had been sent what looked like a genuine email from npm support, asking him to update his two-factor authentication. It was a phishing attack. The attackers used his account to publish poisoned versions of at least 18 packages, including chalk and debug. Together, those packages were being downloaded more than two billion times a week.
About a week later, a self-spreading worm nicknamed Shai-Hulud tore through the same ecosystem. GitHub says it compromised more than 500 packages, stealing developers’ secrets along the way. PHP developers have been hit too. In May 2026, attackers hijacked around 700 existing versions of four widely used packages from Laravel Lang, a community-run project that provides translations for the Laravel framework, so that installing them delivered a credential-stealing tool.
If you build software, these attacks were not someone else’s problem. They exposed an uncomfortable truth: most of the code running in your application was written by people you have never met.
Your app is mostly code you didn’t write
A JavaScript project may list only ten or so packages directly, but each of those brings its own dependencies, and those bring theirs. When GitHub studied projects for its 2020 Octoverse report, the median npm project had 683 indirect dependencies, most of which nobody on the team chose directly.
How much those hidden pieces matter became clear in March 2016. After a naming dispute with the messaging company Kik, a developer removed all 273 of his packages from npm. One of them, left-pad, was just 11 lines of code, yet its disappearance broke installs for projects including Babel and React until npm restored it.
Most of the code running in your application was written by people you have never met.
That isn’t a reason to avoid open source: no team could build modern software without it. But your security depends on links in a chain you can’t see. Black Duck estimates that open source makes up over 70% of a typical application, and its 2026 security report, based on audits of 947 codebases, found known vulnerabilities in 87% of them.
The risk isn’t limited to packages, either. In 2018, attackers compromised a third-party chatbot running on Ticketmaster UK’s payment page and harvested customers’ payment details. The Information Commissioner’s Office later fined the company £1.25 million for failing to put appropriate security measures in place.
Protecting your dependencies doesn’t require a security team. It requires a few habits.
| THE FIVE HABITS
1 Know what you depend on 2 Let tools do the scanning 3 Update fast, but not instantly 4 Check before you install 5 If you publish packages, protect the keys |
1. Know what you depend on
Commit your lockfile and install from it in your build pipeline (npm ci does exactly this), so every environment runs the versions you tested. For larger teams, a software bill of materials, a complete inventory of your components, means that when the next major vulnerability is announced, you can answer the question that matters within minutes: are we affected?
Log4Shell showed why. In December 2021, a critical flaw came to light in Log4j, a logging library used across a vast number of Java applications. Jen Easterly, then director of the US Cybersecurity and Infrastructure Security Agency, called it ‘one of the most serious’ vulnerabilities she had seen in her entire career. For many organisations, the hardest part was simply finding it: the UK’s National Cyber Security Centre (NCSC) warned that Log4j was often embedded as a dependency inside other software, sometimes in several copies, each of which needed updating.
That inventory should go beyond packages. The language runtime, container images and system libraries your code runs on are dependencies too, and they are easy to forget. When word of two critical flaws in PHP itself, nicknamed ‘PHP2Shell’, leaked ahead of their planned disclosure in October 2026, PHP released emergency fixes the next day, and within days attackers were exploiting servers that had not been updated: on 26 October, the US Cybersecurity and Infrastructure Security Agency added both flaws to its list of vulnerabilities known to be exploited. The NCSC’s advice to UK organisations began with taking an inventory of their PHP installations.
The UK government’s voluntary Software Security Code of Practice, published in May 2025 and developed with the NCSC, makes the same point. It asks software vendors to understand what their software is made of, assess the risks of third-party components, and proactively detect, prioritise and manage vulnerabilities in software components.
2. Let tools do the scanning
Some of the costliest breaches exploit flaws that already have fixes. In 2017, attackers stole data from Equifax through a known flaw in Apache Struts, an open-source framework, two months after a fix had been released. The personal data of nearly 148 million Americans was exposed, along with records belonging to UK consumers.
Old habits linger. Two years after Log4Shell, Sonatype found that 26% of Log4j downloads in a single week were still vulnerable versions.
Tools can track what no developer can by hand. npm audit checks your dependencies against a public database of known vulnerabilities, GitHub’s Dependabot can open pull requests to update vulnerable packages automatically, and Google’s OSV-Scanner works across many programming languages. Run at least one of them on every pull request, then fix first the flaws in code that actually runs in production.
3. Update fast, but not instantly
This sounds contradictory, but it is the main lesson of the past year. Security fixes should be applied quickly, as Equifax shows, yet installing every brand-new release the moment it appears is exactly how poisoned versions spread. In September 2025, the malicious versions were spotted within minutes and npm removed them the same day, so a team that waited a day before adopting new releases would most likely have avoided them.
Package managers now support this. Since pnpm 11, a setting called minimumReleaseAge makes pnpm pass over versions less than a day old by default, as long as an older matching version exists. The npm command-line tool has offered a similar min-release-age setting since version 11.10, though you have to switch it on. A short cooling-off period for routine updates, combined with fast-tracking genuine security fixes, gives you the best of both.
4. Check before you install
Before adding a new package, spend two minutes on due diligence. Is the name spelt correctly? How many weekly downloads does it have, who maintains it, and when was it last updated?
Typosquatting is an old trick. In 2017, a package called crossenv imitated cross-env, a popular tool for setting environment variables, and quietly sent developers’ environment variables, which often hold passwords and access keys, to an attacker’s server. It was one of around 40 look-alike packages npm removed from the same account.
Who maintains a package matters too, even for ones you already use. In 2018, the maintainer of event-stream, a package downloaded nearly two million times a week, handed it over to a little-known developer who had emailed him offering to maintain it. The newcomer added a hidden dependency designed to steal bitcoin from users of the Copay wallet, and it went unnoticed for more than two months.
AI coding assistants add a new twist. Researchers who analysed 576,000 code samples generated by 16 AI models found that, on average, at least 21.7% of the packages recommended by open-source models did not exist, compared with 5.2% for commercial models such as GPT-4. When one security researcher noticed AI tools repeatedly inventing a Python package called huggingface-cli, he registered the name with an empty package; it received more than 15,000 genuine downloads in three months. Never install a package simply because an AI suggested it.
It is also worth blocking install scripts, a favourite way for malware to run the moment a package lands on your machine. pnpm (since version 10) and npm (since version 12, released in July 2026) no longer run dependencies’ install scripts unless you approve them. PHP teams are not immune: in May 2026, attackers added malicious npm install scripts to eight PHP packages on Packagist, hiding them in the package.json files that projects use for their JavaScript build tools.
5. If you publish packages, protect the keys
Every maintainer is a target. Wiz found that 99% of the cloud environments it observed contained at least one of the packages hijacked in September 2025. Use phishing-resistant two-factor authentication, such as a security key or passkey, rather than codes that can be typed into a fake website, and where possible use trusted publishing, which links releases to your build pipeline instead of long-lived access tokens.
Attackers also look for forgotten doors. By 2022, the domain behind the email address of the maintainer of ctx, a Python package that had not been updated since 2014, had expired. An attacker bought the domain, reset the account password and published versions designed to steal developers’ AWS keys and other secrets. Keep the email address on your account, and the domain behind it, under your control.
GitHub, which runs npm, has since tightened the rules: it has revoked older ‘classic’ access tokens and limited new publishing tokens to seven days by default and 90 days at most. From around January 2027, it also plans to stop tokens that skip two-factor checks from publishing directly.
As someone who maintains an open-source npm package myself, I know how easy it is to treat account security as an afterthought. The past year has shown why it can’t be.
Security is a habit, not a tool
None of these steps is complicated or expensive. What they need is time and priority. For engineering leaders, that means making dependency checks part of the definition of done, rather than housekeeping for a quiet Friday afternoon.
Our applications will always be built mostly from other people’s code. That is the strength of open source. Our job is to know what we are building on.
| ABOUT THE AUTHOR
Al-Amin Ajao is a software engineer with years of experience building software applications for web and mobile. Based in Lagos, Nigeria, he likes to educate people on how everyday technology works and how to stay safe online. |