Encode the userId path parameter in user API key methods - #1664
Encode the userId path parameter in user API key methods#1664devin-ai-integration[bot] wants to merge 3 commits into
Conversation
createUserApiKey and listUserApiKeys interpolated the userId argument directly into the request path without encodeURIComponent. Because the HTTP client builds the URL with new URL(path, baseURL), a userId containing ../ segments and a ? was normalized and query-split, letting the SDK's environment-key-authenticated request be redirected to an arbitrary API path (e.g. /organizations/org_.../api_keys). Wrap userId in encodeURIComponent, matching the SDK's established pattern (e.g. getUserConnectedAccount), so the argument stays confined to the user resource route. Add regression tests.
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 fixes a path-traversal vulnerability where
Confidence Score: 3/5The fix is correct for user-management.ts but the same path-traversal pattern remains live in multi-factor-auth.ts and feature-flags.ts, leaving the attack surface partially open. The fix is correct and complete within user-management.ts, but the identical unencoded userId interpolation pattern remains in multi-factor-auth.ts (createUserAuthFactor, listUserAuthFactors) and feature-flags.ts (listUserFeatureFlags), all callable with the SDK environment key. The partial fix reduces but does not eliminate the attack surface. src/multi-factor-auth/multi-factor-auth.ts (lines 171, 200, 207) and src/feature-flags/feature-flags.ts (lines 189, 196) need the same encodeURIComponent fix applied. Important Files Changed
Reviews (3): Last reviewed commit: "Encode userId in updateUser path" | Re-trigger Greptile |
Extend the encodeURIComponent fix to the other user-scoped endpoints that share the same raw-interpolation path-traversal primitive: getUser, sendVerificationEmail, verifyEmail, listSessions, deleteUser, and getUserIdentities. Add regression tests for getUser and deleteUser.
|
Good catch on the incomplete fix. The same raw Addressed in 088d805: all |
updateUser interpolated payload.userId raw into the PUT path, leaving the same path-traversal primitive open. Encode it and add a regression test.
|
Fixed the |
|
Confirmed the same unencoded pattern exists in Scoping note: SEC-2175 is specifically the user-management API-key methods, and this PR already extends the fix to cover all |
Summary
createUserApiKeyandlistUserApiKeysinterpolated theuserIdargument directly into the request path. This change URL-encodes theuserIdpath parameter, consistent with other methods.Please review before merging.