Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53a659f

Browse files
committed
security: use specific RBAC permissions instead of wildcard for license import
Replace wildcard permissions with least-privilege approach:- Only grant ActionCreate and ActionRead on ResourceLicense- Removes unnecessary access to all other resources- Follows principle of least privilege- Reduces attack surface if code is refactoredThe license import operation only needs to:1. Read existing licenses (ActionRead)2. Create new license (ActionCreate)No other permissions are required, so wildcard was unnecessarily broad.
1 parent5fba46c commit53a659f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎enterprise/coderd/licenses.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func ImportLicenseFromFile(ctx context.Context, db database.Store, licenseKeys m
394394
}
395395

396396
// Check if any licenses already exist
397-
// Use a subject withwildcard permissions for this system startup operation
397+
// Use a subject withspecific license permissions for this system startup operation
398398
// nolint:gocritic // This is a system operation during startup before any users exist
399399
systemCtx:=dbauthz.As(ctx, rbac.Subject{
400400
ID:uuid.Nil.String(),
@@ -403,7 +403,7 @@ func ImportLicenseFromFile(ctx context.Context, db database.Store, licenseKeys m
403403
Identifier: rbac.RoleIdentifier{Name:"license-import"},
404404
DisplayName:"License Import",
405405
Site:rbac.Permissions(map[string][]policy.Action{
406-
rbac.ResourceWildcard.Type: {policy.WildcardSymbol},
406+
rbac.ResourceLicense.Type: {policy.ActionCreate,policy.ActionRead},
407407
}),
408408
},
409409
}),
@@ -452,7 +452,7 @@ func ImportLicenseFromFile(ctx context.Context, db database.Store, licenseKeys m
452452
}
453453

454454
// Insert the license into the database
455-
// Use the same system context withwildcard permissions
455+
// Use the same system context withspecific license permissions
456456
// nolint:gocritic // This is a system operation during startup before any users exist
457457
dl,err:=db.InsertLicense(systemCtx, database.InsertLicenseParams{
458458
UploadedAt:dbtime.Now(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp