Details
- Group-based access control is only enforced at authorization time: Group restrictions on OIDC clients (e.g., "only the infrastructure team can access the CI/CD client") can be bypassed by anyone who obtained a refresh token before being removed from the group.
Related
GitHub issue #1390 reports a similar pattern: refresh tokens are not deleted when a session ends via the end-session endpoint. Same root cause (refresh token lifecycle detached from authorization state), different entry point.
Suggested Fix
Primary fix: Re-validate authorization state in createTokenFromRefreshToken
Add the following checks after the refresh token lookup (after line 495):
// Check 1: Verify user is not disabled
if storedRefreshToken.User.Disabled {
return CreatedTokens{}, &common.OidcInvalidRefreshTokenError{}
}
// Check 2: Verify UserAuthorizedOidcClient still exists
var authorizedClient model.UserAuthorizedOidcClient
err = tx.WithContext(ctx).
Where("user_id = ? AND client_id = ?", storedRefreshToken.UserID, input.ClientID).
First(&authorizedClient).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
// Authorization was revoked - delete this refresh token and reject
tx.Delete(&storedRefreshToken)
return CreatedTokens{}, &common.OidcInvalidRefreshTokenError{}
}
// Check 3: Re-verify group restrictions
if !IsUserGroupAllowedToAuthorize(storedRefreshToken.User, client) {
return CreatedTokens{}, &common.OidcAccessDeniedError{}
}
Secondary fix: Delete refresh tokens on authorization revocation
In RevokeAuthorizedClient, also delete all refresh tokens for the user-client pair:
// After deleting the authorized client record
err = tx.WithContext(ctx).
Where("user_id = ? AND client_id = ?", userID, clientID).
Delete(&model.OidcRefreshToken{}).Error
if err != nil {
return err
}
Both fixes should be applied together (defense in depth).
Self-Review
- Is this by-design? No. The revocation feature, the disabled flag, and group restrictions all exist to control access. The refresh flow bypassing all three is a bug, not a feature.
- Are there upstream bounds? No. Refresh tokens are stored independently. No FK cascade, no periodic cleanup, no validation of authorization state.
- Honest weaknesses:
- Variant 1 (revocation): The attacker must be the OIDC client operator (they need client credentials and existing refresh token). Userinfo endpoint does return 404 after revocation, which is a partial mitigation. But the id_token issued during refresh already contains all PII.
- All variants: Requires a pre-existing refresh token, so the access must have been legitimately granted at some point.
- Existing reports: Issue #1390 covers the related end-session case. No prior security reports for the revocation/disabled/group variants.
Koda Reef