fix(permissions): remove permissions granted by org membership#1206
fix(permissions): remove permissions granted by org membership#1206waleedlatif1 merged 2 commits intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR implements a critical security fix that addresses a vulnerability where organization membership granted excessive cross-functional permissions to workspaces. Previously, being an admin of ANY organization would allow users to gain admin access to workspaces owned by ANY member of that organization, creating unintended cross-workspace access that violated the principle of least privilege.
The core changes involve:
-
Permission Model Restructuring: Removed the vulnerable
isOrganizationAdminForWorkspacefunction fromlib/permissions/utils.tsand simplifiedhasWorkspaceAdminAccessto only check workspace ownership or direct admin permissions -
Function Relocation: Moved
isOrganizationOwnerOrAdminfrom the general permissions utilities tolib/billing/core/organization.tsto properly scope it within billing operations rather than general workspace access control -
Workspace Access Isolation: Updated
getManageableWorkspacesto only return workspaces that users directly own or have been explicitly granted admin permissions to, removing any organization-based access paths -
Import Path Updates: Consolidated organization billing imports and updated routes like
api/billing/route.tsandapi/usage-limits/route.tsto use the reorganized billing modules -
Logging Standardization: Replaced numerous
console.errorcalls across the codebase with structured logging usingcreateLogger, improving observability and debugging capabilities throughout the application
The security fix ensures that workspace permissions are now purely workspace-centric, with users only having access to workspaces they own or have been explicitly invited to, regardless of their organization membership status. This decoupling creates clearer security boundaries and prevents the unauthorized access scenarios described in issue #995.
Confidence score: 5/5
- This PR successfully addresses a critical security vulnerability with well-tested changes that properly isolate workspace permissions
- Score reflects comprehensive permission model restructuring with extensive test coverage and clear security improvements
- No files require special attention as the changes follow established patterns and include proper error handling
31 files reviewed, no comments
* fix(permissions): remove cross-functional permissions granted by org membership * code hygiene
…udioai#1206) * fix(permissions): remove cross-functional permissions granted by org membership * code hygiene
Summary
remove cross-functional permissions granted by org membership. previously, we coupled org membership with permissions access, but we've decoupled them to keep all permissions at the workspace-level. this ensures that users only have access to workspaces and workplaces they own or have been invited to, irregardless of their organization membership
patches #995
Type of Change
Testing
unit tests, tested manually
Checklist