Encode caller-supplied path parameters in legacy modules - #1662
Conversation
The hand-written legacy modules interpolate caller-supplied identifiers (user IDs, invitation tokens, MFA factor IDs, organization IDs, external IDs, role/permission slugs) directly into URL path templates without encoding. HttpClient.getResourceURL then resolves the result with the WHATWG URL parser, which honors ../ dot-segments and ?/# metacharacters. An integrator that forwards an attacker-influenced identifier into one of these methods could have its API-key-authenticated request retargeted to an arbitrary same-verb WorkOS endpoint. Wrap each interpolated path parameter in a shared encodePathParameter helper, matching the encodeURIComponent pattern already used by the auto-generated modules. The helper preserves ':' so existing RBAC slugs (e.g. users:read) keep their wire format.
Original prompt from Linear User
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR prevents caller-supplied identifiers from changing legacy SDK request paths. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "Reject dot-only path segments in encodeP..." | Re-trigger Greptile |
encodeURIComponent leaves '.' and '..' unchanged, and the WHATWG URL
parser removes them as relative path segments. For a non-terminal
template such as /feature-flags/${slug}/enable a slug of '..' still
climbs and retargets the request (e.g. to /enable). Percent-encoding the
dots does not help because the parser also treats the %2e forms as dot
segments. Fail closed: throw for '.' and '..', which are never valid
WorkOS identifiers.
Summary
The hand-written legacy SDK modules (User Management, MFA, SSO, Organizations, Organization Domains) interpolated caller-supplied identifiers directly into request paths. This change URL-encodes those path parameters, consistent with the generated modules.
Please review before merging.