fix(broker): traversal is a path SEGMENT of .., not the substring anywhere - #2231
Merged
Merged
Conversation
…nywhere
`normalisePath()` denied any path containing the substring `..`. That rejected
legitimate paths whose segments merely contain dots — most importantly GitHub's
diff endpoint, `/repos/{o}/{r}/compare/{base}...{head}`, so EVERY commit
comparison was refused as traversal.
That is not a cosmetic refusal. `hydra-flows-first-port` task 2.5 makes "diff
the produced tree against the base before moving the ref" a MANDATORY rail on
the commit-by-API path — precisely because `base_tree` overwrites rather than
merges, so a tree built against a base that has moved silently reverts every
file the caller did not send while producing a clean-looking commit. The rail
could not be built at all over the brokered path while this guard stood.
Found by running the chain: blob 201, tree 201, commit 201, then compare 403.
The check now looks for a segment that IS `..`, which is what traversal
actually is. The security property is unchanged and pinned both ways:
- `/repos/Conduction/../../etc/passwd` still denied
- `/repos/Conduction/%2e%2e/%2e%2e/etc/passwd` still denied (the guard decodes
once BEFORE checking, so an encoded traversal segment is caught — pinned
separately because a segment check running before the decode would be
trivially bypassable)
- `/repos/Conduction/openregister/compare/A...B` now allowed
- `/repos/Conduction/some..name` now allowed
Double-encoding is unaffected: `%252e%252e` single-decodes to `%2e%2e`, which
is not `..`, exactly as before.
15,553 unit tests green (4 new); phpcs, phpstan clean.
Contributor
Quality Report — ConductionNL/openregister @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| composer | ✅ | ✅ 174/174 | |||
| npm | ✅ | ✅ 616/616 | |||
| PHPUnit | ✅ | ||||
| Newman | ✅ | ||||
| Playwright | ⏭️ |
Quality workflow — 2026-07-31 14:28 UTC
Download the full PDF report from the workflow artifacts.
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 was wrong
CredentialBrokerService::normalisePath()denied any path containing the substring... That rejected legitimate paths whose segments merely contain dots — most importantly GitHub's diff endpoint:So every commit comparison through the broker was refused as traversal.
Why it matters more than it looks
hydra-flows-first-porttask 2.5 makes "diff the produced tree against the base before moving the ref" a mandatory rail on the commit-by-API path. The reason is specific:base_treeoverwrites rather than merges, so a tree built against a base that has since moved silently reverts every file the caller did not send, and the resulting commit looks clean. That has happened for real (two files lost an import and a template gate during the nc-vue migration, caught only by running the full suite).The rail could not be built at all over the brokered path while this guard stood.
Found by running the chain end to end: blob
201, tree201, commit201, then compare403.The fix
Check for a segment that IS
.., which is what traversal actually is. A segment like..b,a..bor...is a literal name and never walks anywhere.Security property unchanged, pinned both ways:
/repos/Conduction/../../etc/passwd/repos/Conduction/%2e%2e/%2e%2e/etc/passwd/repos/Conduction/openregister/compare/A...B/repos/Conduction/some..nameThe encoded case is pinned separately on purpose: the guard decodes once before checking, so an encoded traversal segment is still caught — a segment check running before the decode would be trivially bypassable, and that is the mistake this test exists to prevent. Double-encoding is unaffected:
%252e%252esingle-decodes to%2e%2e, which is not.., exactly as before.Verification
15,553 unit tests green (4 new); phpcs (full tree, CI settings) and phpstan clean.