You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MNG] Warn or fail when an external-model profile repository shadows central #13146
When a dependency POM contributes a repository through a JDK/OS/activeByDefault-activated profile (the legitimate path, see #13100 / #13116 / #13141), that repository can declare a URL that shadows central or another well-known repository with a different (potentially malicious) URL.
Maven currently has no defense against this: the repository is accepted as-is and used for artifact resolution.
Proposed Solution
Implement a WARN (or optionally FAIL with a flag) policy that triggers when:
A repository contributed by an external-model profile has the same <id> as a repository already registered in the effective repository list (e.g. central), but a different URL.
This is a repository URL-mismatch check, scoped to the dependency resolution path.
I looked into this on current master and found that the behavior depends on the repository merge mode.
With an external dependency POM whose active profile declares central with a different URL:
REQUEST_DOMINANT (used by DefaultArtifactDescriptorReader): the existing central repository wins and the conflicting external repository is dropped. A repository with a unique id is still accepted.
POM_DOMINANT: the external central declaration replaces the existing one.
So the normal artifact descriptor resolution path already prevents the shadowing described here, but does so silently.
Adding a generic same-id/different-url warning also looks problematic because many existing POMs redeclare central using legacy URLs, which could generate a large number of warnings.
For the remaining POM_DOMINANT case, making external models recessive would change the existing precedence semantics.
Would you prefer this issue to:
add a warning for conflicts that are already discarded in the REQUEST_DOMINANT path, or
change the POM_DOMINANT semantics so external models cannot override an existing repository id?
After analysis, the current REQUEST_DOMINANT merge mode (used by DefaultArtifactDescriptorReader for all dependency resolution) already fully mitigates this concern:
Same-id shadowing is blocked: when a dependency POM declares a repository with an id that already exists in the request (e.g. central from the super POM), the dependency's declaration is silently dropped. The existing URL is preserved.
The scope is limited: each dependency is resolved in its own derived ModelBuilderSessionState. Repository changes during dependency resolution don't propagate back to the parent state — they are subtree-scoped.
A warning would not be actionable:
If the user has already redeclared the repository in their POM (the natural "fix"), it's already overridden — no warning needed.
If the user has not redeclared it, the dependency's repository (with a new id) is legitimately needed for resolving that dependency's transitive dependencies — no warning needed either.
For central specifically, it's always present from the super POM, so the shadow is always blocked without any user action.
The POM_DOMINANT case (raised in the earlier comment) only applies to the project's own parent chain during project building, where overriding central is expected behavior (since central comes from the super POM's defaults).
Activity
Update TODO to reference new issue apache#13146
Reconcile with apache#13141: add activeByDefault test, TODO(apache#13146
Fix #13100: honor repositories from legitimately-active external mode…
Fix #13100: honor repositories from legitimately-active external mode…
Fix #13100: honor repositories from legitimately-active external mode…
arturobernalg commentedon Oct 10, 2026
I looked into this on current master and found that the behavior depends on the repository merge mode.
With an external dependency POM whose active profile declares
centralwith a different URL:REQUEST_DOMINANT(used byDefaultArtifactDescriptorReader): the existing central repository wins and the conflicting external repository is dropped. A repository with a unique id is still accepted.POM_DOMINANT: the externalcentraldeclaration replaces the existing one.So the normal artifact descriptor resolution path already prevents the shadowing described here, but does so silently.
Adding a generic same-id/different-url warning also looks problematic because many existing POMs redeclare
centralusing legacy URLs, which could generate a large number of warnings.For the remaining
POM_DOMINANTcase, making external models recessive would change the existing precedence semantics.Would you prefer this issue to:
REQUEST_DOMINANTpath, orPOM_DOMINANTsemantics so external models cannot override an existing repository id?gnodet commentedon Oct 20, 2026
After analysis, the current
REQUEST_DOMINANTmerge mode (used byDefaultArtifactDescriptorReaderfor all dependency resolution) already fully mitigates this concern:Same-id shadowing is blocked: when a dependency POM declares a repository with an id that already exists in the request (e.g.
centralfrom the super POM), the dependency's declaration is silently dropped. The existing URL is preserved.The scope is limited: each dependency is resolved in its own derived
ModelBuilderSessionState. Repository changes during dependency resolution don't propagate back to the parent state — they are subtree-scoped.A warning would not be actionable:
centralspecifically, it's always present from the super POM, so the shadow is always blocked without any user action.The
POM_DOMINANTcase (raised in the earlier comment) only applies to the project's own parent chain during project building, where overridingcentralis expected behavior (sincecentralcomes from the super POM's defaults).Closing as already mitigated.
Claude Code on behalf of Guillaume Nodet
fix: replace #13146 TODO with resolution note (#13645)