Skip to content

Jail LocalFetcher to a root directory and cap POM read size - #10

Merged
andrew merged 1 commit into
mainfrom
jail-local-fetcher
Jun 28, 2026
Merged

Jail LocalFetcher to a root directory and cap POM read size#10
andrew merged 1 commit into
mainfrom
jail-local-fetcher

Conversation

@andrew

@andrew andrew commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

LocalFetcher.walk follows <parent><relativePath> and reads files from disk. It already rejects absolute paths and symlinks but does not bound ../, so a hostile POM can read arbitrary files relative to the caller's working directory. This matters once the parser runs server-side against pushed repositories rather than a user's own checkout.

NewLocalFetcherFrom, NewLocalFetcher and ResolveLocal now take an fsRoot argument. The walk refuses to step outside it, and an empty fsRoot skips the walk entirely so callers handling untrusted bytes can opt out of filesystem access altogether. The containment check compares cleaned absolute paths with a trailing separator so /tmp/repo-evil is not treated as inside /tmp/repo.

Separately, ParsePOM now rejects input over MaxPOMBytes (10 MB, tunable), and readPOMFile, DirFetcher.Fetch and HTTPFetcher.FetchBytes apply the same limit at read time so an oversized file or response is never fully buffered.

This is a breaking change to the three LocalFetcher constructors. Known caller to update: manifests/internal/maven/maven.go:43.

@andrew
andrew merged commit ac586a4 into main Jun 28, 2026
5 checks passed
@andrew
andrew deleted the jail-local-fetcher branch June 29, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant