-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Pulling in old vulnerable version of maven-core #7566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It does not drag in the library at compile scope, but at provided scope as can be observed when running
The maven dependencies are dependency-managed at version 3.6.3 in order to avoid any risk of using post-3.6.3 new maven API, thereby breaking our claim of Maven 3.6.3+ compatibility. The plugin will (because of this provided scope) use the maven libraries of the maven install that runs the plugin. |
What your project is surfacing is a potential bug in the plugin dependencies scope evaluation, or a scope override for maven-core by another part of your project. |
@chadlwilson may I ask why you closed the issue? Its title might be badly worded, I don't believe @johanblumenberg wants you to upgrade the version of |
Ok, was probably a bit hasty. Perhaps misinterpreted what aikebah and OP were saying. OP didn't respond. FWIW this project gets vast amounts of noise and I don't think anyone has the time to be second guessing over multiple interactions. Having hundreds of open issues doesn't get any of them resolved 😓 |
Thank you for reopening this issue. Indeed, the dependency to But when executing the plugin, it is clearly downloading Here I am removing
However, it looks like
|
It cannot open the jar file in your last example because you overwrote it with an empty string: echo "" > ~/.m2/repository/org/apache/maven/maven-core/3.6.3/maven-core-3.6.3.jar |
I decided to ask ChatGPT o4 and received a really interesting explanation: Yes, this behavior is subtle but understandable when you dig into how Maven resolves plugin dependencies and interprets the provided scope in the context of plugins, which differs from how it works for application dependencies. 💡 TL;DR:Even though you've declared maven-core as provided, Maven resolves the plugin's dependencies based on what's declared in its pom.xml, not based on the runtime Maven version—because plugin dependencies are resolved from the plugin's POM metadata, not the Maven runtime classpath. 🧩 Explanation
✅ How to avoid confusionIf your goal is to:
Then you have a few options:
🔎 Summary
|
As to the "root cause" here, when scanning Maven plugins, I don't think the current logic has the ability to apply the normal DependencyCheck/maven/src/main/java/org/owasp/dependencycheck/maven/BaseDependencyCheckMojo.java Lines 1398 to 1436 in 91ffcf6
|
After doing some more testing - I'm positive ChatGPT's answer is correct. In a sample project I ran
You'll see that when we resolve the plugin's dependencies the tree has two different versions of maven-core listed. Unlike what happens with the standard dependencies where it would select one. |
@chadlwilson we can get the scope by calling Maybe the best option would be to add a |
If that |
Exactly. The point was to see if the jar file is executed when executing the plugin. |
I tried to log the classpath of the plugin when executing. According to https://maven.apache.org/guides/mini/guide-maven-classloading.html#Plugin_Classloaders:
I get this list of artifacts, which incudes
|
Regarding the idea to use
Considering this, I think it would be a lot more safe to update the dependency-check plugin not to depend on vulnerable artifacts. |
BREAKING CHANGE: dependency-check-maven now requires maven 3.8.1 or newer resolves #7566
Precondition
Describe the bug
dependency-check-maven
contains a compile dependency toorg.apache.maven.shared:maven-artifact-transfer:0.13.1
which contains a compile dependency toorg.apache.maven:maven-core
.dependency-check-maven
contains a provided dependency toorg.apache.maven:maven-core:3.6.3
.This means that
dependency-check-maven
will pull inorg.apache.maven:maven-core:3.6.3
as a compile dependency.org.apache.maven:maven-core:3.6.3
contains the critical vulnerability CVE-2021-26291: https://mvnrepository.com/artifact/org.apache.maven/maven-core/3.6.3The recommendation is to have a provided dependency to
maven-core
, not compile, and theorg.apache.maven.shared:maven-artifact-transfer
artifact is deprecated.Version of dependency-check used
The problem occurs using version 12.1.0 of the maven plugin.
Log file
N/A
To Reproduce
Steps to reproduce the behavior:
dependency-check-maven
, like this: https://gist.github.com/johanblumenberg/72d74aa8520292e1fb220a06de1490afmvn verify
target/dependency-check-report.html
and check the critical items reported.Expected behavior
No critical vulnerabilities coming from the
dependency-check-maven
plugin itself.Additional context
N/A
The text was updated successfully, but these errors were encountered: