Repository navigation
fix(gateway): escape path params and validate before vault access - #44
Merged
Merged
Conversation
Escape each path value once to prevent credentialed endpoint traversal. Reject missing or invalid segments and record denied attempts. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reject query placeholders before loading registry actions. Validate URLs before vault access to avoid refresh side effects. Keep invalid base URLs separate from agent input errors. Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Plan
Security fix found while reviewing #43.
buildURLput agent-controlled params into path templates without escaping.Impact before this fix:
{"repo": "../../admin/users"}or values with?or#. That reached other endpoints on the SaaS host with the vault-injected credential attached.{owner}, could be substituted again, depending on map iteration order.What changed
buildURLscans the template once, left to right. Each placeholder is replaced once, never re-scanned.Values are escaped with
url.PathEscapeas single path segments.Rejected with 400
bad_requestand a receipt:.and..;Large integers keep their exact text.
After building, the final URL must keep the base URL's scheme and host.
Templates with a placeholder after
?fail at registry load, andbuildURLrejects them too.PathEscapeis wrong for query values.URL building now runs right after the action lookup, before any vault access. Bad params never trigger an OAuth refresh. An invalid
base_urlis an operator error: 500internal, with a receipt.README and
docs/registry.mdsay path params are escaped as single segments.Validation
go build ./...: passedgo vet ./...: passedgo test -race ./...: passedsemgrep --config auto --error --quiet internal/gateway internal/registry: passed, no findingsTests cover:
%2e%2e(sent as%252e%252e), checked on the raw request line at the upstream;Review
Reviewed by a second model (Claude Opus 5.5). Approved. Its 2 minors (query placeholders, check order) are fixed here. The third, the same old code in unused
internal/proxy, goes away in the dead-code cleanup PR.Compatibility
A custom connector that passed slashes inside one param must move the separators into its template. No shipped connector does this.