Skip to content

Reject package requests with ? or # in the decoded path - #437

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
pinguinfuss:reject-query-in-path
Oct 12, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
pinguinfuss:reject-query-in-path

Conversation

@pinguinfuss

Copy link
Copy Markdown
Contributor

Handlers build upstream URLs from the decoded request path. An encoded ? or # therefore ends the path upstream but not in the proxy:
GET /apk/alpine/v3.22/main/x86_64/busybox-1.37.0-r12.apk%3F/foo-9.9-r0.apk

fetches busybox and caches it as foo@9.9-r0. Later clients asking for foo get busybox, and the denylist never sees busybox. PyPI can be poisoned the same way. Maven, Conda, CRAN, Gem, Hex, Pub and Go end up storing files under mangled names, which gets around the denylist and cooldown.

This adds one middleware in front of every ecosystem mount that answers such paths with 400, so new handlers are covered too. Composer archive downloads are let through: their upstream URL comes from the metadata, and git branches like dev-fix/#42 reach the proxy as dev-fix%2F%2342 (see #433).

A server test sends a crafted path to every mount and checks for 400 with no upstream request. Without the middleware, most of them get through.

…e middleware in front of every ecosystem mount. Handlers build the upstream URL from the decoded path, so busybox.apk%3F/foo-9.9-r0.apk fetched busybox but cached it as foo; PyPI could be poisoned the same way, and the other ecosystems stored files under mangled names past the denylist and cooldown.
…e the upstream URL from metadata, and with git-pkgs#433 a branch like dev-fix/git-pkgs#42 is requested as dev-fix%2F%2342. Adversarial review finding F1.

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard covers the ecosystem mounts and preserves Composer branch downloads. No changes requested.

@andrew
andrew merged commit 729138d into git-pkgs:main Oct 12, 2026
6 checks passed
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.

2 participants