Skip to content

fix(api_core): improve rest path validation - #17753

Merged
daniel-sanche merged 32 commits into
mainfrom
fix_rest
Aug 17, 2026
Merged

fix(api_core): improve rest path validation#17753
daniel-sanche merged 32 commits into
mainfrom
fix_rest

Conversation

@daniel-sanche

Copy link
Copy Markdown
Contributor

Context: b/532254612

@daniel-sanche
daniel-sanche requested a review from a team as a code ownerJuly 17, 2026 00:06

@gemini-code-assistgemini-code-assistBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces path traversal validation and percent-encoding for variables within path templates in google/api_core/path_template.py, along with corresponding unit tests. The feedback highlights a potential security bypass in _extract_and_validate_wildcards where path traversal sequences (like projects/..) could bypass validation if the value does not match the sub-template or if the template is single-segment. It is recommended to apply _validate_multi_segment_value to these edge cases and add tests to verify that these bypasses are successfully blocked.

Comment threadpackages/google-api-core/google/api_core/path_template.py Outdated
Comment threadpackages/google-api-core/tests/unit/test_path_template.py
@daniel-sanchedaniel-sanche changed the title fix: improve rest path validationfix(api_core): improve rest path validationJul 17, 2026

@chalmerlowechalmerlowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and suggestions.

Comment threadpackages/google-api-core/google/api_core/path_template.py Outdated
Comment threadpackages/google-api-core/google/api_core/path_template.py Outdated
Comment threadpackages/google-api-core/google/api_core/path_template.py Outdated
Comment threadpackages/google-api-core/google/api_core/path_template.py Outdated
Comment threadpackages/google-api-core/tests/unit/test_path_template.py Outdated
Comment threadpackages/google-api-core/tests/unit/test_path_template.py Outdated
@daniel-sanche
daniel-sanche marked this pull request as draft July 22, 2026 18:49
@daniel-sanche

Copy link
Copy Markdown
ContributorAuthor

Converting this to draft, because it sounds like there are still some cross-language discussions happening

@daniel-sanchedaniel-sanche changed the title fix(api_core): improve rest path validation[DRAFT] fix(api_core): improve rest path validationJul 22, 2026
@daniel-sanchedaniel-sanche changed the title [DRAFT] fix(api_core): improve rest path validationfix(api_core): improve rest path validationAug 14, 2026
@daniel-sanche
daniel-sanche marked this pull request as ready for review August 14, 2026 23:09

@hebaalazzehhebaalazzeh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chalmerlowechalmerlowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daniel-sanche
daniel-sanche merged commit 63bfb96 into mainAug 17, 2026
44 checks passed
@daniel-sanche
daniel-sanche deleted the fix_rest branch August 17, 2026 23:02
@release-pleaserelease-pleaseBot mentioned this pull request Aug 17, 2026
Sign up for freeto 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.

3 participants

@daniel-sanche@chalmerlowe@hebaalazzeh