Skip to content

admin: normalize request path in remote admin access-control check (defense-in-depth) #7909

Closed

Description

@iabdullah215

Issue Details

Proposal / hardening

The remote admin API access-control check authorizes requests using a lexical prefix match against the raw request path, without normalizing it first.

RemoteAdmin.enforceAccessControls → adminPathAllowed (admin.go) compares r.URL.Path against each configured allowed path. Because the path is not cleaned first, a request such as:

/pki/ca/prod/../../../../load

Satisfies the prefix check for an identity scoped to /pki/ca/prod, even though it resolves to /load.

Is it exploitable today?

No — and I want to be upfront about that, so this is a hardening proposal rather than a security report. The admin router is http.ServeMux, which normalizes/redirects .. and duplicate-slash paths before dispatch, so the handler for /load is never reached via such a request. I confirmed this against Go 1.25's ServeMux:

  • /config/../stop → 307 redirect (never dispatches to /stop)
  • /config/%2e%2e/stop → dispatches to the /config/ handler the caller is
    already authorized for

Why fix it anyway

The access-control layer's correctness currently depends on the router's cleaning behavior. If the admin mux were ever swapped for a router that cleans-and-dispatches instead of redirecting (a common pattern; go-chi is already a dependency elsewhere in the tree), this silently becomes a real authorization bypass. Authorization should be self-contained and not rely on a downstream component to sanitize its input.

Proposed solution

Normalize both the request path and the allowed path with path.Clean (purely lexical — no filesystem access, no symlink resolution) before the boundary check. This preserves the existing GHSA-gx7w segment-boundary semantics (e.g. /pki must not match /pkisecret) and makes trailing-slash handling on the allowed path unambiguous.

I have a patch + regression tests ready (traversal out of scope, sibling traversal, collapsed slashes, exact request with trailing slash); the traversal tests fail without the change and pass with it. Happy to open the PR.

Assistance Disclosure

AI used

If AI was used, describe the extent to which it was used.

Claude (Claude Code) assisted with the investigation, the proposed code change, and the tests. I directed the analysis, reviewed every line, and verified the behavior manually (Go 1.25 ServeMux) and via the added automated tests, which I confirmed fail without the fix and pass with it.

Activity

  1. adityabagla7 commented on Sep 3, 2026

    @adityabagla7

    I'll work on this hardening: normalize request and allowed paths with path.Clean before the boundary check, and add regression tests for traversal-out-of-scope, sibling prefixes, collapsed slashes, and trailing-slash exact matches.

  2. adityabagla7 commented on Sep 3, 2026

    @adityabagla7

    Looks like this is already addressed on master: adminPathAllowed now path.Clean()s both the request and allowed paths, and admin_test.go already covers traversal / sibling / collapsed-slash cases. Happy to close if maintainers agree.

  3. iabdullah215 commented on Sep 3, 2026

    @iabdullah215
    ContributorAuthor

    Dear @adityabagla7 Kindly mark this issue as resolved as the linked PR has been merged.

    Thanks

  4. adityabagla7 commented on Sep 3, 2026

    @adityabagla7

    Thanks @iabdullah215 — closing as resolved by the merged PR #7910 (adminPathAllowed now path.Clean()s request and allowed paths).

  5. adityabagla7 commented on Sep 3, 2026

    @adityabagla7

    Thanks @iabdullah215 — agreed this is resolved by the merged PR #7910. I don't have permission to close issues here; could you (or a maintainer) please close #7909?

  6. mohammed90 commented on Sep 3, 2026

    @mohammed90
    Member

    @adityabagla7, shut down your agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions