fix: scope getOrganization lookup to the authenticated session#108
Merged
Conversation
getOrganizationAction accepted a client-supplied organizationId and resolved it with the app's WorkOS API key, without verifying the caller's session was authenticated within that organization. Because the API key can read any organization in the environment, a caller could resolve an arbitrary organization's id and name by ID. Scope the lookup to the session: return null unless the caller is authenticated and the requested organizationId matches the session's org_id. The impersonation banner -- the only consumer -- already passes the session's own organization id, so legitimate behavior is unchanged. Adds regression tests for the cross-organization and unauthenticated cases.
Contributor
Greptile SummaryThis PR scopes organization lookup to the caller’s authenticated session. The main changes are:
Confidence Score: 4/5The change is narrowly scoped and covered by tests for authorized, unauthorized, unauthenticated, and not-found organization lookup paths. The implementation preserves the public action contract while preventing cross-organization lookups, and the tests exercise the relevant behavior boundaries described by the change.
What T-Rex did
Reviews (1): Last reviewed commit: "fix: scope getOrganization lookup to the..." | Re-trigger Greptile |
gjtorikian
approved these changes
Jun 24, 2026
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.
Summary
getOrganizationActionresolved a client-suppliedorganizationIdusing the app's WorkOS API key without checking that the caller's session was authenticated within that organization. Because the API key can read any organization in the environment, a caller could resolve an arbitrary organization'sid/nameby ID.This scopes the lookup to the current session: it returns
nullunless the caller is authenticated and the requestedorganizationIdmatches the session's organization.Behavior-preserving
The only consumer is the impersonation banner (
src/client/components/impersonation.tsx), which always passes the organization id from the caller's own session (useAuth()). Legitimate usage is unchanged; only cross-organization lookups — never an intended capability — now returnnull.Tests
nullwhen there is no authenticated sessionFull test suite green (236 tests);
oxlintandbuildclean.SemVer
Patch. The public
getOrganizationActionsignature is unchanged (OrganizationInfo | null) — callers already had to handlenull.