{{ message }}
Repository navigation
fix(security): encode tool-argument IDs in API URL paths (block path-segment injection) - #468
Open
SavioBS629 wants to merge 1 commit into
Open
SavioBS629 wants to merge 1 commit into
SavioBS629 wants to merge 1 commit into
Conversation
…f6g-wr5j) Tool-argument IDs (build / session / scan / snapshot / test-run / test-plan / project / folder / test-case ids) were interpolated into authenticated API URL paths either raw or via encodeURIComponent — which leaves "." and ".." intact, so a crafted id (e.g. "..") could climb a path segment under WHATWG URL / fetch parsing and redirect the credentialed request to another endpoint on the same host. IDs come from the LLM, so injected text can steer this. Add src/lib/url-path.ts#encodePathSegment (rejects "", ".", ".."; otherwise encodeURIComponent) and apply it to every id that enters a request URL path across automate, app-automate, failure logs, accessibility, Percy, self-heal, RCA / TFA, ask-browserstack, build-insights and test management. Query-string values keep encodeURIComponent; human-facing display links are left unchanged. Non-breaking for normal ids. Adds tests/lib/url-path.test.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

What & why
Fixes GHSA-rhpf-xf6g-wr5j — unencoded tool-argument IDs let an authenticated
API request be redirected to another endpoint on the same host.
Tool-argument IDs (build / session / scan / snapshot / test-run / test-plan /
project / folder / test-case ids) were interpolated into authenticated BrowserStack
and Percy API URL paths either raw or via
encodeURIComponent. The problem:encodeURIComponentleaves.and..intact, and WHATWG URL /fetchparsingresolves those as dot-segments — so an id such as
..(or../../ext/v1/otherwhen raw) can leave its path segment and send the request, with the user's
BrowserStack credentials attached, to a different endpoint on the same host.
IDs originate from the LLM, so injected text (a page under test, a log line, a
test-case body) can steer a tool into passing a crafted id. Scope is limited to
the hosts each tool already talks to — not arbitrary-host SSRF.
Change
src/lib/url-path.ts→encodePathSegment(value): rejects"",".",".."and otherwise returnsencodeURIComponent(value). (encodeURIComponentalready escapes
/ \ ? #; the only residual bypass is a bare dot-segment.)app-automate, failure logs, accessibility, Percy, self-heal, RCA / TFA,
ask-browserstack, build-insights, and test management (incl.
TCG-utils).Existing in-path
encodeURIComponent(id)calls were upgraded to it too.PR-…/TP-…pass throughunchanged).
encodeURIComponent(a
..can't climb a path there); human-facing display/UI links; andcapability-registry, which already has its ownpathSegmentguard.tests/lib/url-path.test.ts.Test
npm run build(lint + format + test + tsc): clean — 76 files / 1159 tests pass.🤖 Generated with Claude Code