Skip to content

bug(network): L7 path canonicalization treats percent-encoded %3B as a path-parameter delimiter and silently truncates the forwarded path #3902

Open

Description

@CloneOfAlex

User Story

As an operator running agents behind an L7 rest endpoint,
I want request paths that contain an encoded semicolon (%3B) to reach the upstream unchanged,
so that the agent acts on the resource it named and not on a different one.

Problem Statement

With the default strip_path_parameters: true, canonicalize_request_target percent-decodes %3B into a literal ; before splitting and stripping ;params. An encoded semicolon, which is data under RFC 3986, is then treated as a path-parameter delimiter: it and everything after it in that segment are dropped. Because the request line is rewritten with the canonical path (rewritten == true), the truncated path is what goes on the wire.

Observed with the canonicalizer from main (0ea0d31) built standalone:

request-target canonical path sent upstream
/a/%3Bx /a/
/objects/backup%3Bold /objects/backup
/a/..;/b /b (intended: ..; traversal guard)

Relevant code:

The existing tests (/public/..%3B/secret → /secret) cover the dot-segment case only; there is no test asserting that %3B inside an ordinary segment survives.

Impact / Why This Matters

The agent's request is retargeted without any error or log entry:

  • DELETE /v1/objects/backup%3Bold is forwarded as DELETE /v1/objects/backup, which deletes a different object.
  • GET/PUT on resource names, S3-style keys, or IDs that contain ; read or overwrite the wrong resource.
  • Nothing is surfaced to the agent or operator (no OCSF event, no 4xx), so the data loss is silent.

The only workaround today is setting strip_path_parameters: false on the endpoint, which also disables the intended ;jsessionid-class mitigation.

Acceptance Criteria

  • A %3B inside a non-dot segment is preserved as %3B in both the policy input and the forwarded request line (e.g. /a/b%3Bc → /a/b%3Bc).
  • ..%3B / %2e%2e%3B traversal is still resolved or rejected as today.
  • Alternatively, the request is rejected with a clear 4xx + OCSF event instead of being silently rewritten.
  • Unit tests cover %3B in ordinary segments, including the trailing-segment case.

Reproduction Steps

  1. Create a sandbox with a protocol: rest endpoint for a test upstream (e.g. an HTTP echo server) and an allow rule for /** with method *.
  2. From inside the sandbox: curl -X DELETE "http://<upstream>/objects/backup%3Bold"
  3. Observe the upstream receives DELETE /objects/backup.

Environment

  • OpenShell: main @ 0ea0d31 (code review; canonicalizer exercised standalone)
  • Component: openshell-supervisor-network L7 REST relay, default CanonicalizeOptions
  • Any driver (the behavior is in the supervisor proxy)

Logs

Activity

  1. added
    state:triage-needed
    on Sep 29, 2026
  2. sachinsharma3191 commented on Oct 2, 2026

    @sachinsharma3191

    I'd like to work on this one.

    Root cause: canonicalize_request_target decodes %3B to a literal ; in percent_decode_with_sentinel and only afterwards strips ;params. So encoded data gets treated as a delimiter, and the truncated path is what goes on the wire. build_canonical_path also emits ; literally, which would let an upstream re-interpret a decoded %3B.

    Proposed fix: handle %3B the same way %2F is handled now. Decode it to a sentinel byte, which a literal ; can't collide with because control bytes are already rejected. strip_path_parameters cuts only at a literal ;, and build_canonical_path re-emits the sentinel as %3B.

    One deliberate exception: a %3B directly after a . or .. segment name is still treated as a delimiter. The existing regression tests require /public/..%3B/secret to resolve to /secret, because servers that decode before stripping would read ..; as ... That keeps the traversal guard intact.

    Behavior change to confirm: /a/%3Bx goes from forwarded as /a/ to forwarded as /a/%3Bx, with rewritten == false. Operators who relied on %3B being stripped will see a difference. Is that acceptable, or do you want it behind an option?

    Scope: the change is limited to l7/path.rs plus unit tests. I'll run cargo test and clippy on openshell-supervisor-network. Could a maintainer confirm that approach and accept the issue?

  3. github-actions commented on Oct 16, 2026

    @github-actions

    This issue has had no activity for 14 days and is now marked stale. It may be closed in 14 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  4. added
    state:stale
    on Oct 16, 2026
  5. CloneOfAlex commented on Oct 16, 2026

    @CloneOfAlex
    Author

    Still relevant — please keep this open.

    Quick status for triage: a fix already exists in #3986 (encoded-%3B sentinel mirroring the %2F handling, with the ..%3B traversal guard preserved and regression tests added). It was auto-closed by the vouch check before any review, not on the merits.

    Two decisions would unblock this:

    Is the approach in #3986 acceptable? If so, it can be reopened once the author is vouched, or @sachinsharma3191 offered to take it.
    On the behavior change (/a/%3Bx forwarded as /a/%3Bx instead of /a/): should this be the new default, or gated behind a CanonicalizeOptions flag? I’d argue default, since the current behavior silently retargets requests (e.g. DELETE /objects/backup%3Bold → DELETE /objects/backup) with no 4xx or OCSF event.

    cc @derekwaynecarr @mrunalp @sjenning (code owners on #3986)

  6. removed
    state:stale
    on Oct 17, 2026
  7. github-actions commented on Nov 15, 2026

    @github-actions

    This issue has had no activity for 28 days and is now marked stale. It may be closed in 14 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  8. added
    state:stale
    on Nov 15, 2026
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

    state:stalestate:triage-needed

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions