mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
7.3 KiB
7.3 KiB
Deep Review Categories Reference
File-by-file review checklist for Phase 2. For each file in scope (or top ~20 most
security-relevant files when reviewing "all"), read the file and check each applicable category.
Category A: Authentication & Authorization
- Every controller action has either
[Authorize](class or method level) or[AllowAnonymous]explicitly. - No IDOR: when accessing resources by ID, verify the handler checks that the caller owns or is authorized to access that resource.
- JWT validation settings are strict: issuer, audience, lifetime, algorithm all validated.
- Token acquisition uses correct flow: app tokens for backend-to-backend, OBO only where user context is needed.
- No
[AllowAnonymous]on endpoints that modify sensitive state without alternative authentication (e.g., OTP verification first). - Multiple auth scheme verification: If the project uses multiple auth schemes (e.g., Azure AD + custom JWT), verify correct scheme is applied per endpoint. No scheme confusion between internal and client-facing endpoints.
- JWT
alg:nonerejection: VerifyTokenValidationParametersdoes NOT allowalg:none. All schemes must validate the signing algorithm (ValidateIssuerSigningKey = true). - HMAC signing key minimum length: If using HMAC-SHA256 for JWT signing, the key must be at least 256 bits (32 bytes). Check options validation.
- Structured error responses on auth failure:
OnChallenge(401) andOnForbidden(403) events should return structured JSON error responses, not default HTML/empty responses.
Category B: Input Validation
- All DTOs accepted by handlers have corresponding FluentValidation validators registered.
- Route parameters are validated for format before use (e.g., GUID format, positive integers).
- File uploads are validated for content type, size, and extension (not just extension).
- No unvalidated user input flows into file paths, URLs, SQL, commands, or log messages.
- Phone numbers, emails, and other PII are validated and normalized before processing.
Category C: Error Handling & Information Leakage
- All expected errors use a structured error type -- never return raw exception details to clients.
- Exception filters catch known exception types and return only safe error payloads.
- Unknown exceptions are wrapped as generic 500 errors without stack traces or internal details.
- Error messages returned to clients do not reveal internal architecture, database schema, or file paths.
- Catch blocks never silently swallow exceptions -- they must log or rethrow.
Category D: Cryptography & Secrets
- OTP/MFA codes use
RandomNumberGenerator(notSystem.Random). - Hash comparison uses constant-time comparison to prevent timing attacks.
- Hash storage uses a secure algorithm (SHA-256 minimum; bcrypt/Argon2 for passwords).
- No secrets, connection strings, or API keys appear in source code or
appsettings.jsoncommitted to git. - Options validation (
ValidateOnStart()) is configured to reject placeholder secrets in production.
Category E: Data Protection & PII
- Sensitive fields (phone numbers, etc.) are masked before returning to unauthenticated callers.
- PII (names, addresses, phone numbers, emails) is not logged in full -- use masking.
- Sensitive internal fields (hash values, internal IDs) are excluded from API responses.
- Blob/file storage SAS URLs have appropriate expiry times and permissions (read-only, short-lived).
- Audit logs do not contain raw PII that violates data protection requirements.
Category F: Concurrency & State Safety
- Database state mutations use optimistic concurrency (ETags, row versions, or equivalent).
- Concurrency exceptions are caught and retried appropriately in handlers.
- Multi-step validation flows (OTP, MFA) handle concurrent attempts correctly.
- Counter increments (e.g., wrong attempt counts) are atomic or protected against race conditions.
- Scheduled/delayed operations do not race with in-progress workflows.
Category G: CancellationToken Propagation
- Every
asyncmethod in the call chain acceptsCancellationToken cancellationToken = default. - The token is passed to every awaited call: HTTP calls, DB queries, blob operations, queue sends.
- The controller passes
HttpContext.RequestAbortedto handlers. - Missing propagation is a DoS vector (abandoned requests hold resources).
Category H: HTTP Client Security
- HttpClient instances have timeouts configured (not infinite).
- Delegating handlers do not log tokens or authorization headers.
- SSL/TLS validation is not disabled (
ServerCertificateCustomValidationCallbackreturning true). - Retry policies do not retry on authentication failures (401/403).
- External API clients have adequate timeout and error handling even without resilience middleware.
- Standard resilience handler: Verify
AddStandardResilienceHandler()or equivalent resilience pipeline is configured on named HttpClients. - Retry-After header respect: Retry policies should honor
Retry-Afterheaders from downstream APIs to avoid cascading failures. - DNS refresh: Verify
SocketsHttpHandler.PooledConnectionLifetimeis set (recommended 2-5 min) to handle DNS changes.
Category I: Configuration Security
- CORS policy does not use
AllowAnyOrigin()in production. - Swagger UI is disabled in production (or restricted to authorized users).
- Health check endpoints do not expose sensitive information.
X-Powered-ByandServerheaders are removed.- HTTPS redirection and HSTS are configured for production.
Category J: Logging & Monitoring Security
- Authentication events are logged (both success and failure) for audit trail.
- Authorization failures are logged with sufficient context (user, endpoint, reason).
- Input validation failures are logged (not just returned as 400 responses).
- Structured logging used throughout -- no string interpolation in log method calls (use message templates).
- Sensitive data (passwords, tokens, PII, hash values) is NEVER logged at any log level.
- Correlation IDs are included in all error log entries for traceability.
- Log output is not accessible to API clients (no endpoint returns log data).
Category K: Output Encoding & Response Security
- No internal file paths, class names, or assembly names leak in API responses (check error messages, headers).
- Razor templates are verified for
@Html.Raw()usage -- must be justified and input-sanitized. TypeNameHandling.Noneverified for Newtonsoft.Json serialization (prevents type injection).Content-Typeheaders are explicitly set on all responses (no browser MIME-sniffing).- Response sanitization logic handles malformed input gracefully (no crashes on invalid JSON/data).
Category L: Supply Chain & Build Security
Directory.Build.propsexists with NuGet audit settings (NuGetAudit,NuGetAuditMode,NuGetAuditLevel).- Package versions are pinned (no floating versions like
Version="1.*"). AnalysisLevelandAnalysisModeare set tolatest-Recommended/Recommendedin build configuration.- Security analyzers included in packages (SecurityCodeScan, SonarAnalyzer.CSharp, or Meziantou.Analyzer).
- No known-vulnerable version ranges in
.csprojfiles (check Newtonsoft.Json >= 13.0.1, Microsoft.Identity.Web >= 2.x, System.Text.Json >= 8.0.5).