Repository navigation
fix(dms): prevent URL path injection in DMS client - #405
Merged
Merged
Conversation
Validate all ID and path parameters before they are interpolated into request URLs to block path traversal and query-injection attacks.
I559656
commented
Oct 16, 2026
NicoleMGomes
approved these changes
Oct 17, 2026
Contributor
|
Thank you! |
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.
Description
The DMS client was interpolating caller-supplied
repository_id,repo_id,config_id,object_id, andpathvalues directly into request URLs without any encoding or validation (CWE-88 / OWASP A03:2021 Injection). An application that forwards user input into these parameters could be used as a confused deputy — dot-segment traversal (../) or query-metacharacter injection (?,#) would redirect the authenticated request (carrying the app's OAuth token) to unintended DMS endpoints, including the Admin API.Two module-level helpers are added to
dms/client.py:_validate_idrejects any ID containing URL path metacharacters via an allowlist ([A-Za-z0-9_-]+, covering both UUID and MongoDB ObjectId formats);_safe_cmis_pathsplits CMIS browse paths on/, rejects./..segments, and percent-encodes each remaining segment. Both are applied at every URL construction site before string interpolation.Related Issue
Closes #<issue_number>
Type of Change
How to Test
uv run pytest tests/dms/unit/test_client_admin.py tests/dms/unit/test_client_cmis.py -q— all 156 tests should pass including the 68 new injection regression tests.python -c "from sap_cloud_sdk.dms.client import DMSClient; DMSClient._browser_url('../../../rest/v2')"— should raiseValueError.python -c "from sap_cloud_sdk.dms.client import DMSClient; print(DMSClient._browser_url('repo1', 'docs/q3'))"— should print/browser/repo1/root/docs/q3.python -c "from sap_cloud_sdk.dms.client import DMSClient; print(DMSClient._browser_url('repo1', 'docs/file name.pdf'))"— should print/browser/repo1/root/docs/file%20name.pdf.Checklist