CVE-2021-26291 Overview
CVE-2021-26291 is an Origin Validation Error vulnerability in Apache Maven that allows the build tool to follow repositories defined in a dependency's Project Object Model (pom.xml) without proper validation. This behavior enables attackers who gain control of a referenced repository, or who position themselves to impersonate such a repository, to inject malicious artifacts into software builds. The vulnerability is particularly dangerous because it affects the software supply chain, potentially allowing arbitrary code execution during the build process when untrusted dependencies are resolved over insecure HTTP connections.
Critical Impact
Attackers can exploit this vulnerability to inject malicious code into software builds by compromising or impersonating HTTP-based Maven repositories referenced in transitive dependencies, leading to supply chain compromise affecting downstream applications.
Affected Products
- Apache Maven (versions prior to 3.8.1)
- Quarkus Quarkus
- Oracle Financial Services Analytical Applications Infrastructure
- Oracle GoldenGate Big Data and Application Adapters
Discovery Timeline
- April 23, 2021 - CVE-2021-26291 published to NVD
- November 21, 2024 - Last updated in NVD database
Technical Details for CVE-2021-26291
Vulnerability Analysis
This vulnerability stems from Apache Maven's default behavior of trusting and following repository URLs specified within a dependency's POM file. When Maven resolves dependencies, it recursively processes the POM files of each dependency, which can specify additional repositories from which to fetch artifacts. Prior to version 3.8.1, Maven would follow these repository references without restriction, including those using insecure HTTP connections.
The attack surface is significant because an attacker does not need to compromise the primary repository used by a project. Instead, they can target any HTTP-based repository referenced by any transitive dependency in the project's dependency tree. This creates a broad attack surface across the software supply chain.
Organizations using a repository manager such as Nexus, Artifactory, or Apache Archiva to govern their builds are protected from this vulnerability, as the repository manager acts as a proxy and enforces repository policies centrally.
Root Cause
The root cause is classified as CWE-346 (Origin Validation Error). Maven's dependency resolution mechanism inherently trusted repository URLs embedded in POM files without validating the origin or requiring secure transport. This design assumed that all repositories referenced in POM files were trustworthy, which creates an implicit trust relationship with potentially untrusted third-party repositories specified in transitive dependencies.
Attack Vector
The attack is network-based and requires no authentication or user interaction. An attacker can exploit this vulnerability through several methods:
- Repository Takeover: Taking control of an abandoned or expired domain hosting a Maven repository that is still referenced in existing POM files
- Man-in-the-Middle Attack: Intercepting HTTP traffic to a legitimate repository and injecting malicious artifacts when dependencies are fetched over unencrypted connections
- DNS Hijacking: Redirecting repository domain names to attacker-controlled servers
- Rogue Repository Insertion: Contributing to open-source projects with POM files that reference attacker-controlled repositories
When Maven resolves dependencies from a compromised repository, the malicious artifacts are downloaded and executed during the build process, allowing arbitrary code execution in the build environment.
Detection Methods for CVE-2021-26291
Indicators of Compromise
- Unexpected outbound HTTP connections to unfamiliar Maven repositories during build processes
- POM files in dependencies containing references to non-standard or HTTP-based repositories
- Build artifacts with unexpected checksums or signatures not matching known-good values
- Network traffic to recently registered or suspicious domains from build servers
Detection Strategies
- Monitor Maven build logs for repository URLs being accessed, particularly HTTP (non-SSL) endpoints
- Implement network monitoring to detect connections to unauthorized Maven repository domains from CI/CD infrastructure
- Use software composition analysis (SCA) tools to audit dependency trees for references to untrusted or HTTP-based repositories
- Configure intrusion detection systems to alert on HTTP traffic from build servers to external Maven repositories
Monitoring Recommendations
- Enable verbose logging in Maven builds to capture all repository access attempts and artifact resolution paths
- Deploy network monitoring on build servers to track outbound connections during dependency resolution
- Implement regular audits of effective POM files to identify third-party repository references in the dependency tree
- Set up alerts for Maven builds accessing repositories outside of approved repository managers
How to Mitigate CVE-2021-26291
Immediate Actions Required
- Upgrade Apache Maven to version 3.8.1 or later, which blocks HTTP repository references by default
- Audit existing projects for POM files containing HTTP repository URLs and update them to use HTTPS
- Configure a repository manager (Nexus, Artifactory, or Apache Archiva) to proxy all external Maven repositories
- Review the effective POM of projects to identify all repository references in transitive dependencies
Patch Information
Apache released Maven 3.8.1 which changes the default behavior to no longer follow HTTP (non-SSL) repository references. Users should upgrade to Maven 3.8.1 or later to receive this protection automatically. For detailed information, refer to the Apache Maven User Thread and Oracle April 2022 Security Alert for Oracle product patches.
Workarounds
- Deploy a repository manager to centrally control and proxy all Maven repository access, which prevents builds from directly accessing external repositories
- Explicitly block HTTP repositories in settings.xml by configuring mirror settings that redirect all repository requests through secure internal proxies
- Use Maven's --strict-checksums flag to verify artifact integrity and detect tampering during dependency resolution
- Implement network-level controls to block outbound HTTP connections from build servers to external Maven repositories
# Maven settings.xml configuration to block HTTP repositories
# Add this to your ~/.m2/settings.xml or project settings
# Example mirror configuration to redirect all repositories through a secure proxy
# <settings>
# <mirrors>
# <mirror>
# <id>secure-central</id>
# <name>Secure Central Repository</name>
# <url>https://your-repository-manager.example.com/repository/maven-public/</url>
# <mirrorOf>*</mirrorOf>
# </mirror>
# </mirrors>
# </settings>
# Verify Maven version (should be 3.8.1 or later)
mvn --version
# Run builds with strict checksum verification
mvn clean install --strict-checksums
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


