Implement the following plan:
Security Review: OWASP Top 10 - Critical Findings and Fixes
Context
Full security review of the secman codebase against OWASP Top 10 categories. The codebase has strong security foundations overall (HttpOnly cookies, parameterized queries, comprehensive security headers, RBAC). This plan covers only the critical/high-severity issues that warrant code changes.
Overall Assessment: STRONG with 4 actionable findings
The codebase demonstrates mature security practices. No SQL injection, no XSS vectors in React (no unsafe HTML rendering), no command injection, proper BCrypt password hashing, comprehensive CSP/HSTS/security headers, and well-implemented OAuth with state CSRF protection. The findings below are the only items that rise to the level of "critical changes necessary."
Finding 1: /memory management endpoint exposed without authentication
OWASP Category: A01 Broken Access Control / A05 Security Misconfiguration
Severity: MEDIUM-HIGH
File: src/backendng/src/main/kotlin/com/secman/controller/MemoryController.kt
Config: src/backendng/src/main/resources/application.yml (line ~336: sensitive: false)
Problem: The Micronaut management endpoint at GET /memory is configured with sensitive: false, making it accessible to unauthenticated users. It exposes JVM heap metrics (used/max/free/total memory). While not directly exploitable, it enables infrastructure fingerprinting for targeted DoS attacks and resource monitoring to detect when the system is under load.
Fix: Change sensitive: false to sensitive: true in application.yml. This makes Micronaut require authentication for the endpoint.
Finding 2: Hardcoded encryption defaults in EncryptedStringConverter
OWASP Category: A02 Cryptographic Failures
Severity: HIGH
File: src/backendng/src/main/kotlin/com/secman/util/EncryptedStringConverter.kt
Problem: The converter falls back to hardcoded defaults when environment variables are not set:
- DEFAULT_PASSWORD = "SecManDefaultEncryptionPassword2024"
- DEFAULT_SALT = "5c0744940b5c369b"
Anyone with source code access can decrypt all encrypted database fields (SMTP passwords, API keys) if the production deployment does not override these. The fallback silently succeeds with no log warning that defaults are in use.
Fix: Log a CRITICAL warning at startup when defaults are being used, and fail-fast in production environments. Check for env var MICRONAUT_ENVIRONMENTS containing "prod" and throw IllegalStateException if encryption secrets are not configured.
Finding 3 (ACCEPTED RISK): User enumeration via /api/aws-account-sharing/users
Reviewed and accepted. User list is not considered sensitive in this enterprise context. No code change.
Finding 4 (ACCEPTED RISK): /api/reqdl is intentionally public
Reviewed and confirmed intentional for external stakeholder access. No code change.
Non-Critical Observations (no code changes needed, just awareness)
| Item | Category | Notes |
|---|
| CSP unsafe-inline | A03 Injection | Required for Astro framework. Migration path documented in SecurityHeadersFilter.kt. Low real risk. |
| Default admin password | A07 Auth Failures | Only created when DB has zero users. Log warning is prominent. Acceptable for bootstrap. |
| JWT default secret in application.yml | A02 Crypto | Placeholder clearly labeled, must be overridden via JWT_SECRET env var. Standard pattern. |
| e.message in error responses | A09 Logging | ~30 locations return exception messages. All are controlled exceptions with safe messages. |
| Cookie secure=false default | A05 Misconfig | Documented as dev-only. Production requires SECMAN_AUTH_COOKIE_SECURE=true. |
| Alignment token-based anonymous endpoints | A01 Access Control | Token acts as capability-based auth. Appropriate for email-linked review workflows. |
| In-memory login rate limiting | A07 Auth Failures | ConcurrentHashMap-based, lost on restart. Acceptable for current deployment scale. |
Verification
After applying fixes:
./gradlew :backendng:compileKotlin - must pass
- Test /memory endpoint without auth - should return 401
- Test /memory endpoint with admin auth - should return heap metrics
- Verify EncryptedStringConverter logs warning in dev, throws in prod env
Files to Modify
src/backendng/src/main/resources/application.yml - change memory endpoint sensitive: false to sensitive: true
src/backendng/src/main/kotlin/com/secman/util/EncryptedStringConverter.kt - add startup warning + prod fail-fast
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/flake/.claude/projects/-Users-flake-sources-misc-secman/f1a231d5-e275-4d20-95cd-2686951c041c.jsonl