-
Notifications
You must be signed in to change notification settings - Fork 294
Fixes :: #1489 :: Add security warnings against version ranges and special version qualifiers #1494
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
Open
HarshMehta112
wants to merge
1
commit into
apache:master
Choose a base branch
from
HarshMehta112:fix/#1489
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,27 @@ the code, dependencies and repositories that are used in your build. | |
| If you want to use Maven to build untrusted code, it is up to you to | ||
| provide the required isolation. | ||
|
|
||
| ## Security Best Practices | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the warning on this page. In my opinion this page is about CVE things. |
||
|
|
||
| ### Avoid Version Ranges and Special Version Qualifiers | ||
|
|
||
| **Strongly discouraged**: The use of version ranges and special version qualifiers like `min` and `max` suffixes. | ||
|
|
||
| Version ranges (e.g., `[1.0,2.0)`, `[1.5,)`) and special version qualifiers (e.g., `-min`, `-max`) introduce several security concerns: | ||
|
|
||
| - **Non-reproducible builds**: Different versions may be resolved at different times, making builds unpredictable | ||
| - **Unexpected vulnerabilities**: Newer versions within a range may contain security vulnerabilities that weren't present when the dependency was initially added | ||
| - **Supply chain attacks**: Attackers could publish malicious versions within an acceptable range | ||
| - **Lack of determinism**: The same `pom.xml` may produce different artifacts depending on when and where it's built | ||
|
|
||
| **Best Practice**: Always use explicit, fixed version numbers for dependencies (e.g., `1.2.3` instead of `[1.0,2.0)` or `1.2.3-min`). This ensures: | ||
| - Build reproducibility | ||
| - Predictable dependency resolution | ||
| - Better security auditing | ||
| - Explicit control over dependency updates | ||
|
|
||
| See the [POM Reference documentation](./pom.html#dependency-version-requirement-specification) for more details on version specifications and the [Version Order Specification](./pom.html#version-order-specification) for information about version qualifiers. | ||
|
|
||
| ## Security Vulnerabilities | ||
|
|
||
| Please note that binary patches are not produced for individual | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to only have warning a warning on this page that using those (as well as min/max, latest etc) are not recommended as they can lead to undesired behavior and pulled in artifacts and that we recommend using the enforcer-rule to enforce it. And then link to the page where version ranges are described, which is https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html and which also needs a warning with a more detailed explanation and examples and a link to the rule.
(at @elharo For me it's very similar to the system dependency: Maven support it and there are reasons to use it. Are those special and situations are rare? Yes, but they are there. So Maven should not warn about itself having a security problem, but explain it as best practice to avoid this pitfall. It's not a security problem of Maven, but of every automatic dependency mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,, this is much worse than system dependencies. It should never have been added and should never be used..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, not all uses of brackets and parentheses introduce version ranges. They can also be used to pin a specific version during transitive dependency resolution