Skip to content

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

Draft
quartzmo wants to merge 1 commit into
googleapis:mainfrom
quartzmo:discovery-core-validation
Draft

feat(core): implement path validation and traversal checks in HttpCommand#27476
quartzmo wants to merge 1 commit 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.
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