Skip to content

fix: URI-encode path parameters in API client request URLs (#1157) - #1240

Open
euniceamoni wants to merge 4 commits into
solutions-plug:mainfrom
euniceamoni:fix/path-parameters-are-interpolated-into-request-ur
Open

fix: URI-encode path parameters in API client request URLs (#1157)#1240
euniceamoni wants to merge 4 commits into
solutions-plug:mainfrom
euniceamoni:fix/path-parameters-are-interpolated-into-request-ur

Conversation

@euniceamoni

@euniceamoni euniceamoni commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1157. Six API endpoints in client.ts interpolated caller-supplied values directly into URL path segments without encodeURIComponent(). Values containing /, ?, or # would corrupt the request path and could be exploited as a path-manipulation / request-smuggling vector against the backend router.

Changes

frontend/src/lib/api/client.ts — wrapped all path-segment interpolations with encodeURIComponent():

  • getBlockchainMarketmarketId
  • getUserBetsuser
  • getOracleResultmarketId
  • getTransactionStatustxHash
  • resolveMarketmarketId
  • emailPreviewtemplateName

frontend/src/lib/api/__tests__/client.test.ts — added URI encoding of path parameters (#1157) describe block with 7 tests covering all 6 affected endpoints plus a regression guard for plain values.

Testing

Tests: 59 passed, 59 total

All tests pass including the 7 new URI encoding tests. cd frontend && npm run build completes with zero warnings.

Acceptance Criteria

  • All path-segment values are URI-encoded before being interpolated into request URLs
  • Values containing special characters (/, ?, #) no longer corrupt the resulting request path
  • A test passes a value containing a slash and asserts the request path is correctly encoded

PR Checklist

PII (email address) was being sent as a URL query parameter on
GET /api/v1/newsletter/gdpr/export, exposing it to server access
logs, browser history, and proxy logs.

Changes:
- frontend: newsletterGdprExport now uses POST with body: { email }
  instead of GET with params: { email } (client.ts)
- backend: added NewsletterExportBody struct, changed handler extractor
  from Query to Json, updated utoipa path attribute to post,
  updated route registration from get() to post() (handlers.rs, main.rs)
- tests: updated it.each entry to expect POST; added new test in
  'GDPR export (solutions-plug#1156)' describe block asserting email is in the
  request body and absent from the URL

Fixes solutions-plug#1156
Update openapi.yaml /api/v1/newsletter/gdpr/export from GET with
query parameter to POST with requestBody (EmailRequest schema), matching
the handler change in handlers.rs.

Update SPEC_ROUTES in openapi_contract_test.rs from GET to POST to
keep the contract test in sync with the spec and runtime router.
…-plug#1157)

Wrap all path-segment interpolations with encodeURIComponent() to
prevent path corruption and request-smuggling when values contain
special characters (/, ?, #).

Affected endpoints: getBlockchainMarket, getUserBets, getOracleResult,
getTransactionStatus, resolveMarket, emailPreview.

Add URI encoding test block (7 tests) covering all 6 endpoints and
asserting that slash-containing values produce correctly encoded paths.
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@euniceamoni Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[Bug] Path parameters are interpolated into request URLs without URI encoding

1 participant