Java projects frequently rely on package managers such as Maven to manage complex webs of external dependencies. While these tools streamline development, they also introduce subtle risks to the software supply chain. In this paper, we present Maven-Hijack, a novel attack that exploits the order in which Maven packages dependencies and the way the Java Virtual Machine resolves classes at runtime. By injecting a malicious class with the same fully qualified name as a legitimate one into a dependency that is packaged earlier, an attacker can silently override core application behavior without modifying the main codebase or library names. We demonstrate the real-world feasibility of this attack by compromising the Corona-Warn-App, a widely used open-source COVID-19 contact tracing system, and gaining control over its database connection logic. We evaluate three mitigation strategies, such as sealed JARs, Java Modules, and the Maven Enforcer plugin. Our results show that, while Java Modules offer strong protection, the Maven Enforcer plugin with duplicate class detection provides the most practical and effective defense for current Java projects. These findings highlight the urgent need for improved safeguards in Java's build and dependency management processes to prevent stealthy supply chain attacks.
翻译:Java项目通常依赖Maven等包管理器来管理复杂的外部依赖网络。尽管这些工具简化了开发流程,但也为软件供应链引入了潜在风险。本文提出Maven-Hijack,一种新型攻击方法,其利用Maven打包依赖的顺序以及Java虚拟机在运行时解析类的方式。通过将具有与合法类相同全限定名的恶意类注入到较早打包的依赖中,攻击者可在不修改主代码库或库名称的情况下,静默覆盖应用程序的核心行为。我们通过入侵广泛使用的开源COVID-19接触者追踪系统Corona-Warn-App,并控制其数据库连接逻辑,证明了该攻击在现实中的可行性。我们评估了三种缓解策略,例如密封JAR、Java模块和Maven Enforcer插件。结果表明,虽然Java模块提供强效防护,但配备重复类检测功能的Maven Enforcer插件为当前Java项目提供了最实用且有效的防御手段。这些发现凸显了在Java构建和依赖管理流程中加强防护机制以防止隐蔽供应链攻击的迫切需求。