-
Notifications
You must be signed in to change notification settings - Fork 5
Address code review findings from PR #213: security, authorization, and data consistency #214
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
Address code review findings from PR #213: security, authorization, and data consistency #214
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
…tion Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
|
@copilot Please also look to resolve CodeQL autofix security suggestions |
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
Resolved CodeQL security issues in commits 2730d42 and a1fa7b6: Information Disclosure Fixes:
Logging Infrastructure Improvements:
All CodeQL autofix suggestions have been addressed. |
Co-authored-by: indcoder <2099300+indcoder@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses 33 critical security vulnerabilities, authorization bypasses, and data consistency issues from code review PR #213 and CodeQL analysis. The changes span security hardening, authentication enforcement, cryptographic improvements, and frontend/backend alignment.
Changes:
- Security hardening: Replaced
System.RandomwithRandomNumberGeneratorfor PIN generation, removed bearer token logging, restricted JWT claims logging to development only, and sanitized exception messages to prevent information disclosure - Authorization enforcement: Added authentication checks to
LookupByPinandApproveRegistrationendpoints, enforced Auth0Subject-based user resolution (preventing client-controlled UserId attacks), and added.RequireAuthorization()to all user/registration listing endpoints - Data consistency: Aligned frontend
RegistrationStatusenum with backend (0=Pending, 1=Approved, 2=Rejected, 3=Waitlisted, 4=Cancelled), fixed ProfileApi name parsing to split into FirstName/LastName, updated 10 test files with correct resource name "userprofile-api", and documented required database migrations in MIGRATION_FIXES_NEEDED.md
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| services/Visage.Services.Eventing/Program.cs | Added cryptographic PIN generation, authentication to LookupByPin, role check to ApproveRegistration, generic exception messages |
| Visage.Services.UserProfile/Program.cs | Restricted JWT claims logging to development, removed Authorization header from HTTP logging, changed EnsureCreatedAsync to MigrateAsync, enforced Auth0Subject-based user lookup, added RequireAuthorization to endpoints |
| Visage.Services.UserProfile/ProfileApi.cs | Removed JWT payload logging, sanitized bearer token logging, fixed name parsing to split into FirstName/LastName with internationalization notes |
| Visage.FrontEnd/Visage.FrontEnd.Shared/Pages/Home.razor | Simplified ternary operator for RSVP message assignment |
| Visage.FrontEnd/Visage.FrontEnd.Shared/Models/EventRegistration.cs | Aligned RegistrationStatus enum with backend values and documentation |
| Visage.FrontEnd/Visage.FrontEnd.Shared/Models/User.cs | Updated GovtId comment to clarify privacy-preserving behavior |
| tests/Visage.Test.Aspire/QUICKSTART.md | Fixed TUnit command syntax with proper -- separator |
| tests/Visage.Test.Aspire/TestAssemblyHooks.cs | Updated resource name from "registrations-api" to "userprofile-api" |
| tests/Visage.Test.Aspire/HealthEndpointTests.cs | Updated resource name references in health endpoint tests |
| tests/Visage.Test.Aspire/RegistrationDbTests.cs | Updated resource name references for consistency |
| tests/Visage.Test.Aspire/SocialProfileLinkingTests.cs | Updated resource name references for social profile tests |
| tests/Visage.Test.Aspire/SocialProfileDisconnectTests.cs | Updated resource name references for disconnect tests |
| tests/Visage.Test.Aspire/RegistrantCurationSocialFieldsTests.cs | Updated resource name references for curation tests |
| tests/Visage.Test.Aspire/FrontEndHomeTests.cs | Updated resource name references for frontend integration tests |
| tests/Visage.Test.Aspire/DraftSaveTests.cs | Updated resource name references for draft save tests |
| tests/Visage.Test.Aspire/DraftRetrievalTests.cs | Updated resource name references for draft retrieval tests |
| tests/Visage.Test.Aspire/DraftDeletionTests.cs | Updated resource name references for draft deletion tests |
| MIGRATION_FIXES_NEEDED.md | Comprehensive documentation of required database schema fixes for Auth0Subject columns and cross-service coupling |
| if (nameParts.Length > 0) | ||
| { | ||
| user.FirstName = nameParts[0]; | ||
| user.LastName = nameParts.Length > 1 ? nameParts[1] : user.LastName; |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name parsing logic has a subtle issue. When dto.Name has only one part (e.g., "John"), line 463 sets user.LastName = user.LastName (preserving the old value). This is correct behavior. However, when a user provides a single-name update, it's unclear whether this should preserve the existing last name or clear it.
Consider the edge case: if the user previously had "John Doe" and now updates to just "Jane", the result would be "Jane Doe" rather than "Jane" with no last name. This may or may not be the intended behavior depending on business requirements.
If the intent is to fully replace the name when provided, consider clearing the last name when only one part is provided, or document that single-name updates preserve the existing last name.
| user.LastName = nameParts.Length > 1 ? nameParts[1] : user.LastName; | |
| user.LastName = nameParts.Length > 1 ? nameParts[1] : string.Empty; |
| { | ||
| var token = parts[1]; | ||
| try | ||
| logger.LogDebug("Authorization Header: {AuthHeader}", authHeader.ToString()); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Authorization header is still being logged in full at line 42 with authHeader.ToString(). While this is now restricted to development environment, it still exposes the full bearer token in development logs. Consider logging only the presence of the header (e.g., "Authorization header present") or just the "Bearer " prefix without the actual token value, consistent with the approach at line 350.
| logger.LogDebug("Authorization Header: {AuthHeader}", authHeader.ToString()); | |
| logger.LogDebug("Authorization header present on request"); |
Description
Addresses critical security vulnerabilities, authorization bypasses, and frontend/backend inconsistencies identified in code reviews for PR #213, including CodeQL autofix security suggestions.
Security Fixes (Critical)
Authorization & Authentication
ApproveRegistrationnow requiresVisageAdminrole (was unauthenticated)LookupByPinrequires authenticated user (was open endpoint)UserIdfrom authenticatedAuth0Subject, not client-controlled input.RequireAuthorization()guards to all user listing endpointsCryptographic & Logging
System.RandomwithRandomNumberGenerator.GetInt32()for PIN generationCodeQL Information Disclosure Fixes
ScheduleEventendpoint - returns generic error instead ofex.MessageConsole.WriteLinewithILoggerin database initialization for proper log managementenvironment.IsDevelopment()checkInvalidOperationExceptionto prevent stack trace leakageFrontend/Backend Alignment
Pending=0, Approved=1, Rejected=2, Waitlisted=3, Cancelled=4)[Required]attribute (users provide full ID for validation; only last 4 digits persisted for privacy)dto.NameintoFirstName/LastNamecorrectly"registrations-api"to"userprofile-api"Code Quality
EnsureCreatedAsync()withMigrateAsync()(with multi-instance deployment notes)--separator before--treenode-filter)Database Schema Issues (Requires Dev Environment)
Three migration fixes documented in
MIGRATION_FIXES_NEEDED.md(requires EF Core tools):Eventtable from UserProfile database (cross-service coupling)Auth0Subjectcolumn toUserstable (nvarchar(255), NOT NULL)Auth0Subjectcolumn toEventRegistrationstable (nvarchar(255), NOT NULL)Summary: 33 issues resolved (26 original code review findings + 7 CodeQL security issues)
Files changed: 18 (3 services, 10 tests, 3 frontend, 2 docs)
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.