fix(19.6.1-04): refuse code-declared role capture and wrap Administrators Runs

- Roles create and update refuse a submitted code that code-declared grants attach to
- compileActionExtensions wraps contributed Administrators Runs with guardOutranked
- Prove both holes on Postgres; keep the boot smoke callable with a superuser principal

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-22 13:29:38 +02:00
parent 422bd1e01f
commit 068adaabf9
5 changed files with 143 additions and 3 deletions

View File

@@ -155,13 +155,31 @@ func (rolesAdmin) AdminSetPermissionValues(_ context.Context, field string, reco
return nil
}
// FormBeforeCreate refuses a code another role uses. A role created here is
// never a system role: is_system is not fillable.
// refuseCodeDeclaredCode refuses a submitted code that code-declared grants
// (pact.Permission.Roles) attach to when it is not the stored code (empty
// on create). A role never becomes a code-declared system role through this
// screen, including when the editor is a superuser (D-16).
func (c rolesAdmin) refuseCodeDeclaredCode(submitted, stored string) error {
if submitted == stored {
return nil
}
if len(c.registry().rolePermissions(submitted)) > 0 {
return &ValidationError{Details: map[string]any{"code": []string{rolesLang + "code_locked"}}}
}
return nil
}
// FormBeforeCreate refuses a code another role uses and a code that
// code-declared grants attach to. A role created here is never a system
// role: is_system is not fillable, and a code-declared code is refused.
func (c rolesAdmin) FormBeforeCreate(ctx context.Context, model any) error {
role, err := asRole(model)
if err != nil {
return err
}
if err := c.refuseCodeDeclaredCode(role.Code, ""); err != nil {
return err
}
return c.checkCode(ctx, role)
}
@@ -184,6 +202,9 @@ func (c rolesAdmin) FormBeforeUpdate(ctx context.Context, model any) error {
if c.systemRole(stored.IsSystem, stored.Code) && role.Code != stored.Code {
return &ValidationError{Details: map[string]any{"code": []string{rolesLang + "code_locked"}}}
}
if err := c.refuseCodeDeclaredCode(role.Code, stored.Code); err != nil {
return err
}
return c.checkCode(ctx, role)
}