Skip to content

fix: patch path traversal and missing HTTP timeouts - #1

Merged
princemuichkine merged 2 commits into
mainfrom
cursor/at-rest-security-review-24c8
Jun 30, 2026
Merged

fix: patch path traversal and missing HTTP timeouts#1
princemuichkine merged 2 commits into
mainfrom
cursor/at-rest-security-review-24c8

Conversation

@cursor

@cursor cursor Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Security Fixes

Addresses two vulnerabilities found during an automated security scan.

1. Path traversal via unencoded path parameters

Severity: Medium

All 17 service modules used str.replace() to interpolate user-supplied IDs into URL path templates without URL encoding. The requests library normalizes ../ sequences during URL preparation, so a crafted ID (e.g. ../../admin/settings) could redirect authenticated requests to unintended API endpoints — bypassing the SDK's "public routes only" design.

Fix: Added a _safe_path_param() helper in client_base.py that applies urllib.parse.quote(str(value), safe="") and updated all 40 path parameter interpolations across 17 service files to use it.

Before:

path = path.replace("{id}", str(id))

After:

path = path.replace("{id}", _safe_path_param(id))

2. HTTP client denial of service via missing request timeouts

Severity: Medium

The SDK's _request() method called session.request() without any timeout parameter. The requests library defaults to None (infinite wait), meaning every HTTP call could block indefinitely if the API server is slow or unresponsive — leading to worker thread exhaustion in consuming applications.

Fix: Added a configurable timeout constructor parameter (default 30s) to LomiClient that is passed to every session.request() call.

client = LomiClient(api_key="...", timeout=60)  # custom timeout
client = LomiClient(api_key="...")               # uses 30s default

Testing

  • Existing test suite passes (the one pre-existing failure in test_generated_surface.py is unrelated — it references a payment_intents attribute that doesn't exist on LomiClient)
  • Verified URL encoding: _safe_path_param("../../admin")..%2F..%2Fadmin
  • Verified timeout is set: LomiClient(api_key="test").timeout30
Open in Web View Automation 

cursoragent and others added 2 commits June 29, 2026 10:36
All service modules used str.replace() to interpolate user-supplied IDs
into URL path templates without URL encoding. The requests library
normalizes ../ sequences during URL preparation, so a crafted ID like
'../../admin/settings' could redirect requests to unintended API
endpoints with the merchant's API key attached.

Added _safe_path_param() in client_base.py using urllib.parse.quote()
with safe='' and updated all 40 path parameter interpolations across
17 service files to use it.

Co-authored-by: Babacar Diop <princemuichkine@users.noreply.github.com>
The SDK's _request() method called session.request() without any timeout
parameter, causing all HTTP calls to block indefinitely if the API server
is slow or unresponsive. This could exhaust worker threads in consuming
applications and halt payment processing.

Added a configurable 'timeout' constructor parameter (default 30s) that
is passed to every requests.Session.request() call.

Co-authored-by: Babacar Diop <princemuichkine@users.noreply.github.com>
@princemuichkine
princemuichkine marked this pull request as ready for review June 30, 2026 08:27
@princemuichkine
princemuichkine merged commit d22736c into main Jun 30, 2026
0 of 10 checks passed
@princemuichkine
princemuichkine deleted the cursor/at-rest-security-review-24c8 branch June 30, 2026 08:27
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.

2 participants