Skip to content

feat(core): implement path validation and traversal checks in HttpCommand - #27476

Open
quartzmo wants to merge 8 commits into
googleapis:mainfrom
quartzmo:discovery-core-validation
Open

feat(core): implement path validation and traversal checks in HttpCommand#27476
quartzmo wants to merge 8 commits into
googleapis:mainfrom
quartzmo:discovery-core-validation

Conversation

@quartzmo

Copy link
Copy Markdown
Member

Implement dynamic runtime template parsing and validation inside HttpCommand to protect Discovery REST clients from path traversal and parameter injection exploits.

Specifically, this change:

  • Rejects query (?) and fragment (#) characters in path parameter values.
  • Rejects slashes (/) and dots (. or ..) in simple path variables (standard wildcards).
  • Validates path traversals in reserved path variables (+ or #, double wildcards) using a segment-boundary traversal validation algorithm.

In addition to the validation logic, this commit includes:

  • Ruby style modernization: cleaned up and auto-corrected string quote style to favor single quotes where appropriate.
  • Formatted long stub requests to follow style guidelines.

Note: If the canonical specification is updated to favor the simpler alternative, this implementation can be easily simplified to "Fail always if dots are found in a double-wildcard value" by replacing the segment-traversal logic with a simple check for any "." or ".." substring.

…mand

Implement dynamic runtime template parsing and validation inside HttpCommand
to protect Discovery REST clients from path traversal and parameter injection exploits.

Specifically, this change:
- Rejects query (?) and fragment (#) characters in path parameter values.
- Rejects slashes (/) and dots (. or ..) in simple path variables (standard wildcards).
- Validates path traversals in reserved path variables (+ or #, double wildcards)
  using a segment-boundary traversal validation algorithm.

In addition to the validation logic, this commit includes:
- Ruby style modernization: cleaned up and auto-corrected string quote style to favor single quotes where appropriate.
- Formatted long stub requests to follow style guidelines.

Note: If the canonical specification is updated to favor the simpler alternative,
this implementation can be easily simplified to "Fail always if dots are found in
a double-wildcard value" by replacing the segment-traversal logic with a simple
check for any "." or ".." substring.
@quartzmo
quartzmo force-pushed the discovery-core-validation branch from 66dff5d to c84404d Compare August 4, 2026 22:43
@quartzmo
quartzmo marked this pull request as ready for review August 4, 2026 23:55
@quartzmo
quartzmo requested a review from a team as a code owner August 4, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant