wasAsked.

How would you review a pull request that changes authentication and authorization in an ASP.NET Core application?

BrowserStack · Full Stack Developer · 3-4-years · technical

Published

Year not specified · .NET, ASP.NET Core, Authentication & Security

Community answers

Posted by wasAsked editorial collection

Review authentication changes as a security boundary. Verify credential and token validation, expiry, issuer, audience, signing algorithm, key rotation, revocation/logout behavior, rate limits, and safe error messages. Authorization must be enforced server-side on every protected resource. Check cookies for Secure, HttpOnly, SameSite, narrow Path/Domain, and CSRF defenses. Confirm return URLs are allow-listed, secrets are not logged, and user-controlled claims cannot grant roles or tenant access. Add negative tests for expired/tampered tokens, missing claims, cross-tenant IDs, replay, lockout, and privilege escalation. Also inspect dependency changes and deployment configuration; correct code with unsafe production settings is still vulnerable.

Backbencher Developer · · 0 likes

Authentication and authorization changes deserve a careful, checklist-driven review, because small mistakes expose data. Understand the intent - What problem does the change solve, which endpoints and roles are affected, and is there a threat model or design note? Ask for tests that show both allowed and denied cases. Authentication configuration - Token validation must stay strict: ValidateIssuer, ValidateAudience, ValidateLifetime, signing key validation, and a small ClockSkew. Look for anything set to false "temporarily". - Cookies: Secure, HttpOnly, SameSite, sensible expiry and sliding expiration; CSRF protection for cookie-authenticated state changes. - Default and challenge schemes are correct when several schemes exist. - No secrets, keys or test users committed in configuration. Authorization - New endpoints are protected by default: check for a fallback policy (RequireAuthenticatedUser) and that [AllowAnonymous] is used deliberately. - Policies check the right claims and roles; role names and claim types match what the identity provider actually issues. - Resource-based authorization: the code verifies that the user owns or may access the specific record and tenant, not just that they are logged in (look for IDOR risks such as /orders/{id} without an ownership check). - Authorization happens on the server for every path, including bulk operations, exports, file downloads, SignalR hubs and background-triggered actions. - Privilege changes (role assignment, impersonation) are restricted and audited. Failure behaviour - Failures return 401 or 403 (or 404 for hidden resources) without leaking details or stack traces. - Middleware order: UseAuthentication before UseAuthorization, both before endpoints. Tests and evidence - Integration tests for anonymous, wrong role, wrong tenant and correct user. - Negative tests for expired, tampered and wrong-audience tokens. - Logs do not contain tokens or passwords. Finally, check for dependency changes (auth libraries), migration impact on existing sessions, and a rollback plan. For high-risk changes, request a second reviewer with security experience.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics