GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: atomic file publication and authenticated IPC lock daemon by gnodet · Pull Request #2083 · apache/maven-resolver

Conversation

@gnodet

@gnodet gnodet commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes 3 findings from the maven-resolver security audit (scan-maven-resolver-20260811):

Finding Severity Description
f007 MEDIUM Windows final move is truncate-and-copy, not atomic; truncated artifact can survive as trusted
f020 LOW IPC lock daemon protocol is unauthenticated; bootstrap secret leaks via argv
f025 LOW IPC lock key digest concatenates names without separators

Root cause: The concurrency layer has spots where its own guarantee is violated: Windows publication is not atomic, and the IPC lock daemon trusts every connection and digests keys ambiguously.

Fix: Atomic rename on Windows with retry, authenticated IPC daemon with SecureRandom tokens and peer credentials, unambiguous length-prefixed key digest.

Test plan

  • Existing tests pass
  • Windows atomic move tested
  • IPC daemon authentication tested
  • Key digest uniqueness tested

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet closed this Aug 30, 2026
@gnodet
gnodet force-pushed the security/locking-atomicity branch from c4d9f95 to 14b23c9 Compare August 30, 2026 19:34
@gnodet @claude
fix: close locking and atomicity gaps in IPC, tracking, and checksum …
b79ea42
…handling

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gnodet gnodet reopened this Aug 30, 2026
@gnodet
gnodet marked this pull request as ready for review August 31, 2026 05:20
@gnodet
gnodet requested a review from cstamas August 31, 2026 05:20
@gnodet gnodet added bug Something isn't working priority:major Major loss of function labels Aug 31, 2026
@gnodet gnodet added this to the 2.0.23 milestone Aug 31, 2026
cstamas
cstamas approved these changes Aug 31, 2026
View reviewed changes
gnodet
gnodet commented Aug 31, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

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.

Excellent security-hardening PR — defense-in-depth across the IPC lock protocol with comprehensive tests.

Strengths

  • Bootstrap token via stdin instead of argv prevents exposure through /proc/<pid>/cmdline — the right approach
  • SecureRandom over Random for the bootstrap token — required for a security credential
  • Per-connection context scoping is a solid privilege-separation fix: one client can no longer close or acquire on another client's lock contexts
  • Netstring-like lock key digest prevents boundary-shifted collisions (["foo","bar"] vs ["foob","ar"]) — clean and correct
  • Bounded preallocation (Math.min(sz, 1024)) prevents memory exhaustion from malicious wire-supplied sizes
  • Socket file permissions (owner-only rwx) on Unix domain sockets add a second layer beyond the token
  • retryingMove never-truncate contract eliminates the torn-read window where a concurrent reader or process kill could observe a truncated file at the final path after checksum validation
  • Test coverage is thorough: IpcServerAccessControlTest validates context isolation and token enforcement, IpcNamedLockFactoryTest covers digest collision resistance, PathProcessorSupportTest covers retry, never-truncate guarantee, and staging fallback

One observation

@since 2.0.22 tags — Same question as the sibling PRs in this security audit batch (#2079–#2086): the maven-resolver-2.0.22 tag already exists in the repository, so these new API additions (IpcServer(SocketFamily, String) constructor at line 232, restrictToOwner in SocketFamily) should use @since 2.0.23 (or whatever the next release version will be).

Overall this is high-quality, well-thought-out security work. Well done!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet @claude
fix: correct @SInCE tags from 2.0.22 to 2.0.23
78506ea
2.0.22 is already released; new API additions must target 2.0.23.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
cstamas
cstamas approved these changes Aug 31, 2026
View reviewed changes
@cstamas
cstamas merged commit a7104fa into master Aug 31, 2026
24 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@cstamas
cstamas deleted the security/locking-atomicity branch August 31, 2026 11:07
@github-actions github-actions Bot assigned cstamas Aug 31, 2026
This was referenced Sep 4, 2026
Present the IPC token when attaching to a running daemon, and validate Redisson YAML addresses #2120
Closed
[1.9.x] Rename the collocated temp file into place on Windows instead of copying over the target #2124
Closed
This was referenced Oct 12, 2026
Windows AccessDeniedException on install when IDE holds the jar open (Maven 3.10.0 regression) #2204
Closed
Fix #2204: Windows AccessDeniedException on install when IDE holds jar open #2205
Merged
cstamas pushed a commit that referenced this pull request Oct 20, 2026
@gnodet
Fix #2204: Windows AccessDeniedException on install when IDE holds ja…
80657d3
…r open (#2205)

## Summary

Fixes a Windows regression introduced by PR #2083 (resolver 2.0.24 / Maven 3.10.0): `mvn install` throws `java.nio.file.AccessDeniedException` when an IDE (e.g. IntelliJ IDEA) keeps the installed `.jar` open.

Closes #2204 · Closes apache/maven#13329

## Root Cause

PR #2083 replaced the old stream-based file copy with `Files.move()` + `ATOMIC_MOVE` in `PathProcessorSupport.retryingMove()` to fix the f007 security finding. That was the right thing to do — but it introduced a behavioral regression on Windows.

**Old behavior (resolver ≤ 1.9.x):** `classicCopy()` opens the target with a truncating `FileOutputStream`. On Windows, this succeeds even when another process has the file open for reading, because the stream open uses `FILE_SHARE_READ` semantics.

**New behavior (resolver 2.0.24):** `Files.move()` maps to `MoveFileEx`/`ReplaceFile` on Windows. These system calls **require exclusive access** to the destination — any open handle (including a shared read-only handle from an IDE's class loader) causes `AccessDeniedException`. With only 5 retries at 50 ms (250 ms total), a persistent IDE lock is never released and all retries fail.

| Operation | Target open by reader? | Succeeds on Windows? |
|---|---|---|
| `FileOutputStream(target)` (stream write) | Yes (shared read) | ✅ Yes |
| `Files.move(src, target, ATOMIC_MOVE)` | Yes (shared read) | ❌ No — needs exclusive |

## Fix

After exhausting all `WINDOWS_MOVE_ATTEMPTS` with `AccessDeniedException`, fall back to `classicCopy()` directly to the target as a last resort, logging a `WARN` to identify the situation. The atomicity guarantee is lost for this edge case (a concurrent reader may observe a partially written file), but the build completes — matching the pre-2.0.24 behavior that users relied on.

A new system property controls the fallback:
```
-Dorg.eclipse.aether.spi.io.PathProcessor.WINDOWS_CLASSIC_COPY_FALLBACK=false
```
Setting it to `false` disables the fallback and propagates the original `AccessDeniedException` (strict never-truncate mode).

The fallback is also exposed as an overridable `protected boolean isClassicCopyFallbackEnabled()` method for subclasses and tests.

## Note on PR #2198

The open PR #2198 (hard-link install) sidesteps this problem for `mvn install` by not copying at all. This PR fixes the underlying `retryingMove` logic, which is also exercised in other code paths (download to local repo, `writeFile`). The two PRs are complementary.

## Changes

- `maven-resolver-spi/pom.xml` — add `slf4j-api` compile dependency and `slf4j-simple` test dependency
- `PathProcessorSupport.java` — add `WINDOWS_CLASSIC_COPY_FALLBACK` constant, `isClassicCopyFallbackEnabled()` hook, fallback logic in `retryingMove()`
- `PathProcessorSupportTest.java` — rename `retryingMoveNeverTruncatesTargetOnFailure` → `...WhenFallbackDisabled` (adds subclass override), add `retryingMoveFallsBackToClassicCopyOnPersistentLock`

_Hermès Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
This was referenced Nov 15, 2026
[1.9.x] Downloaded files get the download time instead of Last-Modified on Windows #2317
Closed
minimumReleaseAge uses the download time instead of the publication date on Windows with Maven 3.9.x mojohaus/versions#1497
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cstamas cstamas cstamas approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@cstamas cstamas

Labels

bug Something isn't working priority:major Major loss of function

Projects

None yet

Milestone

2.0.23

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gnodet @cstamas
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.