Honour configured policy and validate inputs on the legacy compat paths - #12978
Open
gnodet wants to merge 3 commits into
Open
Honour configured policy and validate inputs on the legacy compat paths#12978gnodet wants to merge 3 commits into
gnodet wants to merge 3 commits into
Conversation
AbstractRepositoryMetadata.getLocalFilename rejects a repository key that is the ".." token, contains '/', '\', ':', or an ISO control character, before using it in a local file name. LegacyLocalRepositoryManager.ArtifactMetadataAdapter applies the same validation. Backport of the corresponding fix from PR apache#12945 (maven-4.0.x). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DefaultRepositoryMetadataManager.readMetadata applies validateVersioning to reject metadata carrying version tokens (latest, release, versions, snapshot versions, snapshot timestamp) that contain '..', '/', '\', ':', or ISO control characters. DefaultRepositoryMetadataManager.resolve now catches ChecksumFailedException ahead of the generic TransferFailedException handler. Under checksumPolicy=fail a checksum mismatch fails metadata resolution instead of only logging a warning. The update-check file is only touched on success, not-found, or a generic transfer failure, so a checksum failure is retried on the next build. Backport of the corresponding fixes from PR apache#12945 (maven-4.0.x). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DefaultRepositoryMetadataManager.getArtifactMetadataFromDeploymentRepository and LegacyRepositorySystem.retrieve hardcoded checksumPolicy=warn for every transfer, so a repository configured with checksumPolicy=fail (or the global -C/--strict-checksums flag) was not honored on the deploy-metadata fetch or on generic retrieve() calls. Resolve the effective policy from the repository instead: the metadata fetch uses the same per-metadata policy resolution the download path already uses, and retrieve() takes the stricter of the repository's release and snapshot policies since a generic path cannot be classified as either. Backport of the corresponding fix from PR apache#12945 (maven-4.0.x). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
commented
Aug 31, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
Clean, faithful backport of the approved #12945 security hardening to maven-3.10.x. All adaptations for the 3.10.x module layout and API surface are correct; no logic drift from the source PR.
Adaptations verified:
- Module paths correctly split between
maven-core/(AbstractRepositoryMetadata, LegacyLocalRepositoryManager) andmaven-compat/(DefaultRepositoryMetadataManager, LegacyRepositorySystem) - Java language level adapted: traditional
instanceof+ cast instead of 4.0.x pattern matching - Reader API adapted:
ValidatingMetadataXpp3Reader(XPP3-based) instead of 4.0.xMetadataStaxReader(StAX-based) - Proxy clone-before-decrypt correctly omitted: confirmed
DefaultSettingsDecrypteron 3.10.x already hasserver.clone()andproxy.clone() ChecksumFailedException extends TransferFailedExceptioncatch ordering correctupdateCheckManager.touch()relocation fromfinallyto individual paths identical to 4.0.x logicchecksumRank()ranking (fail=2, warn=1, ignore=0) identical to 4.0.x
Observation (non-blocking):
- [low]
isInvalidPathTokenhelper duplicated betweenAbstractRepositoryMetadataandLegacyLocalRepositoryManager.ArtifactMetadataAdapter— same as 4.0.x, acceptable for backport.
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Labels | (none) | bug |
| Milestone | (none) | 3.10.0 |
🔀 Backport Status
✅ All branches covered:
This review was generated by an AI agent (Claude Code) and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Backport of the path traversal and checksum policy fixes from #12945 (maven-4.0.x) to maven-3.10.x.
AbstractRepositoryMetadata.getLocalFilenameandLegacyLocalRepositoryManager.ArtifactMetadataAdapter.getLocalFilenamenow reject a repository key that is.., contains/,\,:, or an ISO control character before using it in a local file name.DefaultRepositoryMetadataManager.readMetadatavalidates every version token carried by parsed repository metadata (latest, release, versions, snapshot versions, snapshot timestamp) for the same path traversal characters.DefaultRepositoryMetadataManager.resolvenow catchesChecksumFailedExceptionseparately and fails metadata resolution underchecksumPolicy=failinstead of downgrading to a warning. The update-check file is only touched on success, not-found, or generic transfer failure, so checksum failures are retried on the next build.getArtifactMetadataFromDeploymentRepositoryandLegacyRepositorySystem.retrieveresolve the effective policy from the repository configuration instead of hardcodingwarn.The proxy clone fix (
DefaultSettingsDecrypter) is already present on maven-3.10.x and is therefore not included here.Adapted for the 3.10.x module structure (no
compat/prefix) and API differences (MetadataXpp3Readerinstead ofMetadataStaxReader, no pattern matchinginstanceof).Test plan
AbstractRepositoryMetadataTest(4 tests): repo keys with/,\,..,:are rejected; well-formed key produces correct filenameLegacyLocalRepositoryManagerTest(3 tests): repo keys with path separators and..are rejected in the inner adapterDefaultRepositoryMetadataManagerValidationTest(2 tests): metadata with invalid version token (colon) and invalid snapshot timestamp (colon) are rejectedDefaultRepositoryMetadataManagerTest(1 test):resolve()throwsRepositoryMetadataResolutionExceptionwhen checksum policy isfailand checksums do not matchLegacyRepositorySystemTest.testRetrieveHonorsConfiguredFailChecksumPolicy:retrieve()throwsArtifactTransferFailedExceptionwhen checksum policy isfailmvn verify -pl maven-core -Bpassesmvn verify -pl maven-compat -Bpasses🤖 Generated with Claude Code