Fix predefined-role permission escalation - #1601
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughPredefined roles now reject permission additions and removals. Custom roles continue to allow permission changes. Assignee changes remain allowed for both role types. Four AMP role display names were updated. ChangesRole permission authorization
AMP role display names
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR blocks unauthorized permission changes to predefined roles and corrects default-role recognition while preserving intended membership management; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Purpose
AddRolePermissions/RemoveRolePermissionslet a caller holding onlyrole:updatemodify a predefined system role's permission set (e.g. rewrite "Agent Manager Admin"), even thoughUpdateRole/DeleteRolealready blocked touching predefined roles. Separately, the bootstrap-seeded default roles were never recognized as predefined at all, so this gap applied to real default roles in every deployment.Goals
Approach
validatePredefinedRolecheck toAddRolePermissionsandRemoveRolePermissionsincontrollers/identity_controller.go, right after the ownership check, mirroringUpdateRole/DeleteRoleexactly.AddRoleAssignees/RemoveRoleAssigneesuntouched, no predefined-role check added there.amp-thunder-bootstrap.yaml: the four default roles were seeded asadmin,developer,ai-lead,platform-engineer, which don't matchconstants.IsPredefinedRole's expected strings. Renamed toAgent Manager Admin,Developer,AI Lead,Platform Engineer, keeping the stableidfields unchanged.User stories
As an org admin, a predefined role's permission set can't be changed by anyone through the API, mine included, so its meaning stays fixed and predictable. As a delegated user with only
role:update, I can still manage custom roles and assign people to any role, but I can no longer silently expand what a predefined role like "Agent Manager Admin" grants.Release note
N/A
Documentation
N/A
Training
N/A
Certification
N/A
Marketing
N/A
Automation tests
identity_controller_test.go:TestAddRolePermissions_PredefinedRoleRejected/TestRemoveRolePermissions_PredefinedRoleRejectedconfirm a predefined role's permissions can't be changed (400).TestAddRolePermissions_CustomRoleAllowed/TestRemoveRolePermissions_CustomRoleAllowedconfirm custom roles are unaffected.TestAddRoleAssignees_PredefinedRoleAllowed/TestRemoveRoleAssignees_PredefinedRoleAllowedpin that assigning users to a predefined role still works.go build,go vet, and the full unit suite all pass.None added.
Security checks
Samples
N/A
Related PRs
N/A
Migrations (if applicable)
N/A
Test environment
macOS (Darwin), local Docker-based agent-manager-service and Thunder instance, Go 1.25.
Learning
N/A
Summary by CodeRabbit
Bug Fixes
Improvements