【BUG】Project Owner approval ignores database-scoped IAM conditions and allows cross-environment approval
Provide the Bytebase version you are using
3.23.0
Describe the bug
We use conditional IAM bindings to assign the Project Owner role to different groups based on database/environment scope.
For example:
- QA group is granted the Project Owner role only for FAT databases.
- Development group is granted the Project Owner role only for DEV databases.
The role assignment itself works correctly. Users only have Project Owner access to the databases matched by their IAM binding conditions.
We also configured an approval rule so that database changes in the FAT environment require approval from a Project Owner.
However, when a FAT change issue is created, both the QA group and the Development group can approve the issue.
The Development group should not be able to approve FAT database changes because its Project Owner role is scoped only to DEV databases.
It appears that during approval authorization, Bytebase checks whether the user has the Project Owner role, but does not evaluate whether the current database/environment matches the IAM binding condition associated with that role.
In other words, the IAM condition is correctly respected when assigning database access, but it appears to be ignored when determining whether a user is an eligible approver.
Steps to reproduce
Create two environments:
- dev
- fat
Create one project, for example:
- test-project
Create databases in both environments.
Assign both the DEV and FAT databases to the same project:
- test-project
Create two user groups:
- QA
- Development
In test-project, grant the QA group the Project Owner role with a condition that only matches FAT databases/environment.
In the same project, grant the Development group the Project Owner role with a condition that only matches DEV databases/environment.
Verify that the conditional Project Owner permissions work correctly within test-project:
- QA users have Project Owner access only to FAT databases.
- Development users have Project Owner access only to DEV databases.
Create an approval rule for FAT changes, for example:
resource.environment_id == "fat"
Configure the approval flow to require the Project Owner role.
Create a database change issue in test-project targeting a FAT database.
Open the approval issue as a user from the Development group.
Observe that the Development user is also considered an eligible Project Owner approver and can approve the FAT change, even though their Project Owner role in test-project is scoped only to DEV databases.
Expected behavior
When an approval flow requires the Project Owner role, Bytebase should evaluate the IAM binding condition against the actual target resource of the change.
For a FAT database change:
- A QA user whose Project Owner binding matches the FAT database/environment should be allowed to approve.
- A Development user whose Project Owner binding only matches DEV databases/environment should not be allowed to approve.
Approval authorization should respect the same database/environment-scoped IAM conditions that are used when determining Project Owner access.
Provide the database you are using
No response
Additional context
No response
Source: bytebase/bytebase