fix(github): crafted owner/repo can hit the wrong GitHub API path - #39
fix(github): crafted owner/repo can hit the wrong GitHub API path#39SebTardif wants to merge 1 commit into
Conversation
Accept only GitHub owner and repo names (A-Za-z0-9._-, not . or ..) before building the issues API URL. Attach the installation token only for openclaw/openclaw. Cover slash, dot, and encoding bypasses plus token attachment in the bun suite. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 8, 2026, 9:00 PM ET / September 9, 2026, 01:00 UTC. ClawSweeper reviewWhat this changesValidates repository names before fetching GitHub summaries, restricts installation-token use to openclaw/openclaw, and adds regression tests. Merge readiness⛔ Blocked before merge - 6 items remain The path-validation fix remains necessary on main. The branch contains useful hardening, but its authentication restriction introduces a compatibility regression and the supplied proof does not establish the changed production fetch behavior. Priority: P1 Review scores
Verification
How this fits togetherHermit turns Discord commands and message reactions into GitHub issue or pull-request summaries. Its shared fetch helper retrieves issue data, optionally summarizes the body through OpenAI, and returns a Discord card. flowchart TD
A[Discord command or reaction] --> B[Validate repository names]
B -->|Invalid| C[No GitHub request]
B -->|Valid| D[Select public or authenticated access]
D --> E[GitHub issue API]
E --> F[Optional AI summary]
F --> G[Discord summary card]
Decision needed
Why: The command default does not establish the installation's authorization policy, and selecting that policy determines which existing summaries remain available. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep validation at the shared fetch boundary and use an explicitly approved repository-access policy with demonstrated fresh-install and upgrade behavior. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the current command passes unrestricted strings into an authenticated URL interpolation, so slash and traversal segments can alter the request path. No live exploit or private-data retrieval was executed. Is this the best way to solve the issue? Partly: central validation is appropriately placed, but a command default is insufficient justification for replacing the configured installation's authentication behavior with a hardcoded repository policy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fd6920504d12. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Fixes an issue where Discord
/github(and summary-emoji reactions on a GitHub issue or PR URL) would treat a crafted owner or repo string as extra GitHub API path segments. The bot then called that URL with the GitHub App installation token, so a slash or..segment could change which API object was read. The issue body is also sent to OpenAI when a summary is generated.Why This Change Was Made
fetchGitHubSummaryDatanow accepts only GitHub owner and repo names (A-Za-z0-9._-, and not.or..) before it buildshttps://api.github.com/repos/{owner}/{repo}/issues/{number}. The installation token is attached only foropenclaw/openclaw(case-insensitive), which is the command default and the App installation target. Other valid public repos still fetch without that token. Both/githuband reaction summaries go through this one function.User Impact
/github number user repostill summarizes public issues and PRs. Crafted owner or repo values no longer change the API path or reuse the App token. Summaries ofopenclaw/openclawkeep authenticated access for private or rate-limited reads.Evidence
Terminal output from a live
bunrun of the patched helpers, plus a public GitHub API fetch with no installation token:Before the patch,
fetchGitHubSummaryData("foo/../users", "me", 1)builtrepoName: "foo/../users/me"and still called GitHub. After the patch that input returns null and no request is sent.Real behavior proof
Behavior or issue addressed: Crafted Discord
/githubowner or repo values could change the GitHub API path and were fetched with the App installation token.Real environment tested: Windows 11, Bun 1.4.1, hermit checkout at
fix/github-owner-repo-sanitizeonfd69205, livebunplus unauthenticatedfetchto api.github.com.Exact steps or command run after this patch:
Evidence after fix: terminal output from the patched helpers (table above). Traversal names are rejected before fetch.
octocat/hello-worldwould fetch without the installation token.openclaw/openclawstill uses the installation token. UnauthenticatedGET https://api.github.com/repos/openclaw/openclaw/issues/1returned HTTP 200 for PR 1.Observed result after fix: Unsafe names never reach
api.github.com. Public repos stay readable without the App token. The trusted default repo still authenticates.What was not tested: A live Discord
/githubclick in a production guild, and a private sibling repo under the same installation.Related
bbfa77bb(2026-05-20) and authenticated inc16b98b7(2026-05-21). Present for 111 days.[A-Za-z0-9_.-](desktop/desktop#3090, moby/moby#679).