-
Notifications
You must be signed in to change notification settings - Fork 48
Bug RHOAIENG-46523: Allow colon in RBAC subject names (system:authenticated) #543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bug RHOAIENG-46523: Allow colon in RBAC subject names (system:authenticated) #543
Conversation
…icated) Fix workspace permission grants for groups/users with colons in their names. The UI now correctly allows granting permissions to system:authenticated and other valid RBAC subjects. Root cause: Permission validation incorrectly used isValidKubernetesName() which only accepts DNS-1123 labels (lowercase alphanumeric and hyphens). RBAC subjects are NOT Kubernetes resource names - they're identity references that legitimately contain colons. Changes: - Added isValidRBACSubject() in middleware.go to validate RBAC subjects - Accepts colons, dots, uppercase, email addresses (all valid RBAC subjects) - Max length 253 chars (DNS subdomain limit) - Rejects control characters for security - Updated AddProjectPermission() to use isValidRBACSubject() - Updated tests to validate system:authenticated and similar subjects Valid RBAC subjects now accepted: - system:authenticated (all authenticated users) - system:unauthenticated (anonymous access) - system:serviceaccount:namespace:name (service accounts) - user@domain.com (email addresses) Issue: https://issues.redhat.com/browse/RHOAIENG-46523 Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR correctly fixes a critical validation bug that prevented granting workspace permissions to valid RBAC subjects containing colons (e.g., Overall Assessment: ✅ APPROVED - This is a well-implemented fix with good security practices and comprehensive test coverage. Issues by Severity🚫 Blocker IssuesNone - No blocking issues found. 🔴 Critical IssuesNone - No critical issues found. 🟡 Major Issues1. Unicode Normalization Missing Location: While the function rejects control characters (ASCII 0-31, 127), it doesn't handle potentially dangerous Unicode characters that could cause security issues:
Recommendation: Consider adding Unicode normalization and checking for potentially dangerous Unicode sequences, especially if RBAC subjects are displayed in the UI or logs. Example: func isValidRBACSubject(name string) bool {
if len(name) == 0 || len(name) > 253 {
return false
}
// Reject control characters and dangerous Unicode
for _, r := range name {
// ASCII control characters
if r < 32 || r == 127 {
return false
}
// Zero-width characters
if r == '\u200B' || r == '\u200C' || r == '\u200D' || r == '\uFEFF' {
return false
}
// Bi-directional override (homograph attacks)
if r == '\u202E' || r == '\u202D' {
return false
}
}
return true
}Priority: Medium (security hardening, not immediate vulnerability) 🔵 Minor Issues1. Error Message Could Be More Specific Location: c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid subject name format"})The error message is generic. Consider making it more helpful by indicating what makes a valid RBAC subject: c.JSON(http.StatusBadRequest, gin.H{
"error": "Invalid subject name: must be 1-253 characters without control characters"
})Priority: Low (usability improvement) 2. Missing Test Coverage for Edge Cases Location: Current tests are good but could be enhanced with:
Priority: Low (nice-to-have) 3. Documentation Comment Could Reference Kubernetes RBAC Spec Location: The function comment is excellent, but consider adding a reference to the Kubernetes documentation for maintainability: // isValidRBACSubject validates RBAC subject identifiers (user/group names in RoleBindings)
// RBAC subjects can contain colons (e.g., system:authenticated, system:serviceaccount:ns:name)
// Unlike Kubernetes resource names, RBAC subjects follow a different format (RFC 1123 subdomain)
// See: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#referring-to-subjects
// Returns false if:
// - name is empty (prevents empty string injection)
// - name exceeds 253 characters (max length for DNS subdomain)
// - name contains control characters (prevents injection attacks)Priority: Low (documentation improvement) Positive Highlights✅ Excellent Root Cause Analysis - The PR description clearly explains why the old validation was incorrect and what RBAC subjects actually are. ✅ Security-First Approach - Explicit control character rejection prevents injection attacks (newlines, tabs, null bytes). ✅ Comprehensive Test Coverage - Tests cover all the new valid cases ( ✅ Correct Validation Logic - The 253-character limit matches RFC 1123 subdomain specifications (same as Kubernetes uses internally for RBAC subjects). ✅ No Breaking Changes - The change relaxes validation (allows more valid inputs), so existing valid subjects continue to work. ✅ Follows Project Standards - Implementation follows the error handling patterns from
✅ Good Separation of Concerns - Validation logic in RecommendationsPrioritized Action ItemsBefore Merge (Optional):
Post-Merge (Nice-to-have):
Security Analysis✅ Authentication Pattern: Not applicable - this is a validation function, not an authentication endpoint ✅ Input Validation: Excellent
✅ Error Handling: Follows established patterns
✅ RBAC Integration: Correctly validates subjects used in RoleBindings
Code Quality ChecklistBased on CLAUDE.md standards:
Final VerdictStatus: ✅ APPROVED WITH MINOR SUGGESTIONS This is a solid fix that correctly addresses the root cause. The implementation is secure, well-tested, and follows project standards. The suggested improvements are optional enhancements that can be addressed in follow-up PRs if desired. Recommendation: Merge after addressing Unicode hardening (Major issue #1) if RBAC subjects are displayed in user-facing contexts, otherwise merge as-is. Review performed by Claude Code with comprehensive analysis of:
🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
Description
Fixes workspace permission grants for groups/users with colons in their names. The UI now correctly allows granting permissions to
system:authenticatedand other valid RBAC subjects.Root Cause
Permission validation incorrectly used
isValidKubernetesName()which only accepts DNS-1123 labels (lowercase alphanumeric and hyphens). RBAC subjects are NOT Kubernetes resource names - they're identity references that legitimately contain colons.Changes
isValidRBACSubject()inmiddleware.goto validate RBAC subjectsAddProjectPermission()inpermissions.goto useisValidRBACSubject()permissions_test.goto validatesystem:authenticatedand similar subjectsValid RBAC Subjects Now Accepted
system:authenticated(all authenticated users)system:unauthenticated(anonymous access)system:serviceaccount:namespace:name(service accounts)user@domain.com(email addresses)Testing
Security Considerations
Files Changed
components/backend/handlers/middleware.go(line 51-70)components/backend/handlers/permissions.go(line 160-163)components/backend/handlers/permissions_test.go(line 738-787)Issue
https://issues.redhat.com/browse/RHOAIENG-46523