Skip to main content

Supply Chain Threats

🌟 Objective​

Identify the main attack vectors in the software supply chain, with an emphasis on external dependencies, and establish effective technical and organisational countermeasures.

⚠️ Supply chain attacks are among the most critical today, because they exploit the implicit trust in third-party packages used at build time or runtime.


🔧 Common types of attack​

Threat TypeDescriptionReal example
TyposquattingPackage with a name similar to that of a well-known onelodashs instead of lodash
Dependency ConfusionResolving packages from the public registry instead of the private oneinternal-lib published externally
Account hijackCompromised dev account publishes a malicious updateua-parser-js (2021)
Abandoned packageUnmaintained library used as a vectorevent-stream (2018)
Code InjectionMalicious payload in the postinstall or scriptnode-ipc (2022)

🔐 Mitigation strategies​

1. Origin verification​

  • Use internal repositories, proxies or mirrors
  • Block the installation of packages from outside an approved origin

2. Name monitoring​

  • Audit new packages added to package.json, pom.xml, etc.
  • Use typosquatting alerts with tools (e.g. Socket.dev, npm-proxy-check)

3. Review of embedded scripts​

  • Detect postinstall, preinstall, install with executable scripts
  • Use flags such as --ignore-scripts where appropriate

4. Approval and timeout policies​

  • Require review of new packages before use
  • Apply a TTL to abandoned dependencies

5. Build isolation and validation​

  • Use clean and immutable environments for the build
  • Sign artefacts and validate integrity

📖 Case studies​

event-stream​

  • Popular npm package with access transferred
  • An update introduced the flatmap-stream dependency containing malware
  • Affected financial applications

ua-parser-js​

  • Hijack of the maintainer's npm account
  • Version published with a cryptocurrency miner
  • Detected by the community via GitHub Actions

✅ Operational recommendations​

PracticeApply in
Internal proxy with an origin allowlistAll projects
Formal approval of new packagesL2 and L3
Scan for malicious scripts in packagesL2 and L3
TTL for dependencies that are not updatedL2 and L3
Alerts for typosquatting and suspicious namesL3 (high)

🔗 Links to other files​

DocumentLink with the supply chain
03-governanca-libs-terceiros.mdApproval of suspicious or risky packages
04-integracao-ci-cd.mdExecution of validators and blocking scripts
07-controle-registos-origem.mdReinforcement of trusted origin and internal mirrors

🚫 Control of the supply chain is inseparable from modern security. Ignoring it means blindly trusting code executed outside the organisation's control.