- Cloud Native Applications
- Application Security
- Application Security
- Web Application Security
- Application Security Posture Management (ASPM)
- Microsegmentation
- Python Security
- SaaS Security
- Node.JS Security
- PHP Security
- AI in Cyber Security
- Cybersecurity for Financial Services
- The Principle of Least Privilege (PoLP)
- Identity and Access Management
- Cybersecurity in Banking
- Threat Detection and Response
- Cyber Kill Chain
- Threat Hunting
- Zero Trust Security
- Zero Trust Architecture
- Fileless Attacks
- DSPM
- Container Scanning
- Kubernetes
- Kubernetes
- Kubernetes Alternatives
- Kubernetes Namespace
- Kubernetes Architecture
- Kubernetes Cluster
- Kubernetes Nodes
- Kubernetes Pods
- Kubernetes Jobs
- Kubernetes Workloads
- Kubernetes Monitoring
- Kubernetes Security
- Kubernetes RBAC
- Secret Scanning
- Kubernetes Security Posture Management (KSPM)
- Kubernetes on AWS
- Kubernetes on VMware
- Kubernetes Vulnerability Scanning
- Managing Containers in Kubernetes
- K3s
- eBPF in Kubernetes
- Kubernetes Dashboard
- Kubernetes Operators
- Kubernetes Services
- Kubernetes Devops
- Kubernetes Networking
- Kubernetes ConfigMap
- Kubernetes Management
- Kubernetes Helm
- Kubernetes as a Service
- Kubernetes Serverless
- Kubernetes Tutorials
- Cloud Attacks
- Cloud Attacks
- Malware Attacks
- Zero Day Attack
- Top 10 Cyber Security Threats
- Arbitrary Code Execution
- Cryptojacking
- AI Attacks
- Prompt Injection
- Backdoor Attacks
- Reverse Shell Attack
- Remote Code Execution
- Defense Evasion
- Honeypots in Cybersecurity
- Malware Analysis
- AI Malware
- Lateral Movement
- Advanced Malware Protection
- CNAPP
- AI Security
- Container Platforms
- Containerized Architecture
- Containerized Architecture
- Docker Secrets
- Container Runtime Interface
- Container Images
- Image Scanning
- Container Compliance
- Docker Security Best Practices
- Container Security
- Container Security Best Practices
- Container Security Tools
- ECS Security
- Network Segmentation
- Istio security
- runC
- Service Mesh
- Image Repository
- Container Escape
- Container Runtime
- Docker Container
- OSS Container Image Scanning Tools
- What Is a Container?
- Docker Images
- Containerization 101
- VM vs. Container
- Containerization vs. Virtualization
- Containerized Applications
- Microservices and Containerization
- Registry Scanning
- Docker CVEs
- Docker Monitoring
- Securing Containers with Docker Scanning
- Docker CIS Benchmark
- Seccomp
- Docker Alpine
- Docker API
- Docker Tools
- 100 Best Docker Tutorials
- Docker Alternatives
- Docker Swarm
- Docker Containers vs. Virtual Machines (VMs)
- Docker Architecture
- Docker Networking
- Docker Registries
- Docker Orchestration
- OpenShift vs Docker
- Container Cloud Computing
- Container DevOps
- Docker in Production
- Container Monitoring
- Container Advantages
- Docker Hub
- Serverless Architecture
- Supply Chain Security
- Supply Chain Compliance
- SolarWinds Attack
- Supply Chain Security
- Secure Software Development Lifecycle
- Software Supply Chain Attacks
- Dependency Confusion Attack
- SLSA
- SSDF
- Software Composition Analysis
- Security Misconfigurations
- Repojacking
- Privilege Escalation
- CI/CD Security
- SAST Security
- GitLab Security
- GitHub Secret Scanning
- OWASP Dependency-Check
- Software Bill of Materials
- SBOM Tools
- NPM Vulnerabilities
- Log4j Vulnerability
- Text4Shell
- Secrets Management
- Jenkins Security
- Yarn vs. NPM
- Source Code Leaks
- Container Image Signing
- Open Source Licenses
- Vulnerability Management
- Vulnerability Management Tools
- Vulnerability Scanning Process
- Vulnerability Management
- Vulnerability Scanning
- Vulnerability Prioritization
- Open Source Vulnerability Scanning
- Vulnerability Remediation
- Vulnerability Scanner
- Risk-Based Vulnerability Management
- Vulnerability Exploitability eXchange (VEX)
- Malware Detection
- Fileless Malware
- Attack Vectors
- Malicious Code
- Risk Posture
- Alert Fatigue in Cybersecurity
- Cyber Security Posture
- MITRE ATT&CK
- MITRE ATT&CK Framework
- LLM Security
- Code Scanning
- Attack Surface
- Attack Surface Management
- What Are Indicators of Compromise (IoC)?
- Secure Code
- Configuration Drift
- Trivy
- DevSecOps
- DevSecOps
- DevSecOps Pipeline
- DevSecOps Best Practices
- DevSecOps vs SecDevOps
- Threat Modeling
- Mean Time to Repair (MTTR)
- eBPF Linux
- Cloud DevOps
- DevOps Tools
- GitOps vs DevOps
- Code Security
- Secure Code Review
- DevOps Security
- Infrastructure as Code (IaC) Security
- Infrastructure as Code DevOps
- Executive Order 14028 (U.S. Cybersecurity Executive Order)
- Open Source Security
- Shift-Left Security
- Shift Right Testing and Security
- What Is SecOps (Security Operations)?
- SecDevOps
- DevSecOps Tools
- Linux Security
- Rocky Linux
- Azure DevOps
- Cloud Security
- Cloud Security
- Cloud Security Challenges
- Cloud Security Tools
- Code to Cloud
- Cloud Protection
- Cloud Security Frameworks
- Cloud Security Standards
- Cloud Security Controls
- Cloud Security Posture Management (CSPM)
- AI Workloads
- Cloud Digital Forensics
- Cloud Computing Security Architecture
- What Is Enterprise Cloud Security?
- Virtualized Security
- CSPM Tools
- Vulnerabilities in Cloud Computing
- Top 7 Risks of Cloud Computing
- Cloud Security Assessment
- Cloud Visibility
- Cloud Governance
- Cloud Security Strategy
- Cloud Security Policy
- DFIR
- Cloud Workloads
- Public Cloud Security
- Private Cloud vs. Public Cloud
- Runtime Security
- Azure Cloud Security
- Azure Security Best Practices
- Azure Security vs. AWS Security
- AWS GovCloud: Basics & How It Compares to Azure & GCP
- S3 Security
- Cloud Misconfiguration
- Terraform Security
- Hybrid Cloud Security
- Multi-Cloud Strategy
- Agentless vs. Agent-Based Security & Monitoring
- Cloud Infrastructure Security
- Gartner CSPM
- Cloud Security Scanner
- AWS CIS Benchmark
- Cloud Configuration Management
- Cloud Workload Protection (CWP)
- Cloud Workload Protection Platforms (CWPP)
- Cloud Workload Security
- Cloud Vulnerabilities and Tools that Can Help
- Google Cloud Security
- Shared Responsibility Model
- AWS Shared Responsibility Model
- AWS Cloud Security
- Multi Cloud Security
- Cloud Compliance
- Kubernetes in Production
- Cloud Detection And Response
Table of Contents
- What is a dependency confusion attack?
- What is an application dependency?
- How can attackers abuse dependencies?
- How does a dependency confusion attack work?
- Real-world examples of dependency confusion PoC
- Dependency attacks via package hallucination: An emerging trend
- Preventing a dependency confusion attack
In some cases, the easiest way for threat actors to compromise an application is not finding security flaws within the app itself. Instead, they manipulate the application’s software supply chain through a dependency confusion attack, which substitutes malicious code for legitimate application dependencies.
Here’s a breakdown of what dependency confusion means, how it works, and how to prevent dependency confusion attacks.
In this article:
- What is a dependency confusion attack?
- How can attackers abuse dependencies?
- How does a dependency confusion attack work?
- Real-world examples of dependency confusion PoC
- Dependency attacks via package hallucination: An emerging trend
- Preventing a dependency confusion attack
What is a dependency confusion attack?
A dependency confusion attack is a type of software supply chain attack that deploys malicious code in place of legitimate application dependencies. To explain fully what that means, let’s discuss what application dependencies are and how attackers can exploit them.
What is an application dependency?
A dependency is a third-party component that needs to be present when an application runs. For example, many applications rely on various software libraries, which supply functionality that the applications use but that is not built into the applications themselves. Likewise, an app may require certain modules or frameworks to be present on a host system in order for the app to run.
Application dependencies are typically defined in one of two places. The first is within an application itself. For example, if you write a Python app, you might include code such as the following, which declares a dependency on the math module:
import math
The second common way to specify an application dependency is to include configuration code in the application’s package that specifies other packages that should be installed on the system where the application runs. For instance, the Debian package (a common packaging format on Linux-based operating system) for Firefox includes a file called control whose contents look like this:
Package: firefox
Version: 126.0.1-1
Architecture: amd64
Maintainer: Maintainers of Mozilla-related packages <[email protected]>
Installed-Size: 244175
Depends: libasound2t64 (>= 1.0.16), libatk1.0-0t64 (>= 1.12.4), libc6 (>= 2.38), libcairo-gobject2 (>= 1.10.0), libcairo2 (>= 1.10.0), libdbus-1-3 (>= 1.9.14), libevent-2.1-7t64 (>= 2.1.8-stable), libffi8 (>= 3.4), libfontconfig1 (>= 2.12.6), libfreetype6 (>= 2.3.5), libgcc-s1 (>= 4.2), libgdk-pixbuf-2.0-0 (>= 2.22.0), libglib2.0-0t64 (>= 2.38.0), libgtk-3-0t64 (>= 3.13.7), libnspr4 (>= 2:4.32~), libnss3 (>= 2:3.99~), libpango-1.0-0 (>= 1.14.0), libstdc++6 (>= 13.1), libvpx9 (>= 1.12.0), libx11-6, libx11-xcb1 (>= 2:1.8.7), libxcb-shm0, libxcb1, libxcomposite1 (>= 1:0.4.5), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxrandr2 (>= 2:1.4.0), zlib1g (>= 1:1.2.3.4), fontconfig, procps, debianutils (>= 1.16)
Recommends: libavcodec60 | libavcodec-extra60 | libavcodec59 | libavcodec-extra59 | libavcodec58 | libavcodec-extra58 | libavcodec57 | libavcodec-extra57 | libavcodec56 | libavcodec-extra56 | libavcodec55 | libavcodec-extra55 | libavcodec54 | libavcodec-extra54 | libavcodec53 | libavcodec-extra53
Suggests: fonts-stix | otf-stix, fonts-lmodern, libgssapi-krb5-2 | libkrb53, libcanberra0, pulseaudio
Breaks: xul-ext-torbutton
Provides: gnome-www-browser, www-browser
Section: web
Priority: optional
Description: Mozilla Firefox web browser
Firefox is a powerful, extensible web browser with support for modern
web application technologies.
The strings following the Depends: parameter define names and versions of packages that are automatically installed alongside Firefox, if you install the browser using a standard package management tool.
How can attackers abuse dependencies?
Normally, it’s perfectly fine to install dependencies when installing an application. In fact, if you don’t satisfy an app’s dependencies, the app usually won’t run properly.
However, the security risk surrounding dependencies is that attackers might find ways to trick an application installer or package manager into downloading malicious code instead of legitimate dependencies. When that happens, a dependency confusion attack occurs.
How does a dependency confusion attack work?
Dependency confusion attacks typically involve the following steps:
- Attackers inspect dependency configurations for applications and identify dependency packages that they can exploit.
- Attackers plant a malicious version of the dependency in a place where application installers or package managers will access it.
- When an admin or user installs a vulnerable application, the application installer or package manager installs the malicious code to satisfy its dependencies.
From the perspective of attackers, the most difficult step in this process is number 2: Finding a way to “trick” application installers or package managers into downloading malicious packages in place of legitimate ones. There are multiple ways to do this:
- Creating malicious software packages and repositories with the same names as those of legitimate ones. This type of attack works in situations where dependency configurations don’t define a complete URL or download path for a dependency, causing the installer to default to using the first dependency package it finds whose name matches the dependency defined by the application.
- Injecting malicious code into legitimate software packages that satisfy dependencies. For example, attackers could “contribute” malicious code to an open source project. If none of the project’s legitimate developers notice the malicious code, anyone who downloads the package would end up installing the malicious software on their systems alongside the legitimate code.
- Using typosquatting, which involves planting malicious versions of packages whose names or URLs are misspelled versions of legitimate ones. This method can cause dependency confusion in cases where developers mistype the name or download path for a dependency (hence the term typosquatting), causing an installer to pull the malicious version.
- Modifying network settings to redirect application installers to malicious repositories. For example, by changing DNS configurations, attackers could point requests to github.com to a site they control. This effectively tricks installers into pulling packages from the malicious site, while it appears to users that they come from GitHub.
The ease of carrying out dependency confusion attacks can vary widely depending on factors like how carefully application installers validate dependency source paths and who creates and maintains the software that satisfies dependencies. A major open source library that has hundreds of active maintainers would be challenging to poison with malicious code, for example. However, an obscure project with little activity could be easier to breach as part of a dependency confusion exploit.
Real-world examples of dependency confusion PoC
Dependency confusion attacks are far from theoretical. Real-world examples of major dependency confusion incidents include:
- The planting of a malicious version of PyTorch, a popular open source Python library, into a software repository in 2022.
- Attacks involving malicious packages in npm, a widely used registry for Node.js software dependencies and other components.
- A dependency confusion attack by an ethical hacker who demonstrated how typosquatting could have allowed him to breach companies like Apple.
Dependency attacks via package hallucination: An emerging trend
More recently, an interesting twist on dependency confusion attacks has emerged among threat actors seeking to take advantage of code produced by generative AI tools. In some cases, that code contains references to dependencies that AI models “hallucinate” – meaning they refer to dependencies that don’t actually exist initially. By creating malicious packages with names that match those of the hallucinated dependencies, attackers can plant malicious code on victims’ systems.
In a 2024 dependency confusion proof-of-concept for this type of exploit, security researchers created a fake package (which didn’t actually contain malicious code, but which easily could have if the researchers had been threat actors) with a name that AI models frequently hallucinated. Over a period of three months, the package was downloaded more than 30,000 times, presumably by unwitting application installers.
Preventing a dependency confusion attack
Given the multiple ways in which dependency confusion attacks can happen, there is no simple solution to blocking them all. Instead, organizations should deploy a variety of defenses to minimize their risk of falling victim to dependency confusion:
- Scan applications and dependencies comprehensively before installing them to detect malicious code inside the apps. This is important even if the applications appear to originate from legitimate sources, since attackers can sometimes insert malicious code into otherwise legitimate software components, as noted above.
- Ensure that application installers and package managers check the complete download path when satisfying dependencies. This helps prevent situations where installers default to using the first package they find with a matching name, which could be malicious.
- Define the versions of dependencies explicitly so that installers download a specific version rather than defaulting to the most recent one.
- Use signed packages. Signed packages contain digital signatures that verify their sources. This won’t protect against all dependency confusion risks because again, attackers sometimes find ways to compromise legitimate packages. But it will protect against instances where installers download dependencies from illegitimate sources.
- Only allow installers to download dependencies from registries or other sources that you trust. You can do this by creating an allow list of URLs or repositories that installers can use.
- Installing network security monitoring tools to detect network-based attacks, such as DNS spoofing, that could lead to dependency confusion.
Reducing dependency confusion risks with Aqua
Dependency confusion is a real threat, and it’s likely only to get worse as generative AI technology creates novel ways to launch dependency confusion attacks.
Aqua can help keep you safe. Using the Aqua platform, businesses can automatically scan all applications and dependencies to detect malicious code. No matter where your dependencies come from, Aqua helps you identify dependency risks before they give attackers access to your systems.
- Supply Chain Compliance: 4 Standards You Should Know
- SolarWinds Attack: Play by Play and Lessons Learned
- Supply Chain Security: Mitigating the Supply Chain Threat
- What Is the Secure Software Development Lifecycle (SSDLC)?
- Software Supply Chain Attacks: 6 Examples and 6 Defensive Strategies
- What Is SLSA and How to Use it for Supply Chain Security
- What Is SSDF (Secure Software Development Framework)?
- What Is Software Composition Analysis (SCA)?
- Security Misconfiguration: Types, Examples & Prevention Tips
- Why Repojacking Is a New Mega Threat & Protecting Your Projects
- Privilege Escalation in Windows, Linux, and K8s and 6 Ways to Prevent It
- CI/CD Security: Threats, Tools, and Best Practices
- SAST Security: Is SAST Still Relevant for Modern Applications?
- GitLab Security
- GitHub Secret Scanning
- How to Analyze the OWASP Dependency-Check?
- SBOM (Software Bill of Materials)
- What Are SBOM Tools?
- 6 Common npm Vulnerabilities and How to Fix Them
- Log4j Vulnerability: Updated Info and Protection for 2023
- Text4Shell CVE (CVE-2022-42889): Impact and Fixes
- What Is Secrets Management? Challenges and Best Practices
- Jenkins Security: How it Works & Best practices
- Yarn vs. NPM: Which Package Manager You Should Choose, and Why?
- Source Code Leaks: How to Avoid Them Before They Happen
- Container Image Signing: A Practical Guide
- 5 Open Source Licenses and Compliance Risks to Know About
- Show more
Aqua Cloud Native Application Protection Platform (CNAPP)
Go cloud native with the experts!