multilingual-absa / docs /SECURITY.md
Aryan Mishra
Refactor dashboard to native Streamlit UI
dbd4e8b
|
Raw
History Blame Contribute Delete
2.92 kB

A newer version of the Gradio SDK is available: 6.26.0

Upgrade

Security Analysis β€” Multilingual ABSA

Current State

Area Status Notes
JWT Authentication ❌ Not implemented No auth layer
OAuth ❌ Not implemented No SSO
HTTPS ❌ Not enforced Expects reverse proxy to terminate TLS
Input Validation βœ… Partial Pydantic validation present; no server-side max_length
SQL Injection βœ… Protected SQLAlchemy ORM parameterized queries
XSS βœ… Protected Streamlit dashboard; no raw HTML rendering, user input via native widgets
CSRF ❌ Not implemented No CSRF middleware; CORS "*" mitigates partially
Secrets Management ⚠️ Manual .env gitignored; Docker Compose has hardcoded dev creds
Rate Limiting ❌ Not implemented No throttling on any endpoint
File Upload Security ⚠️ Partial Extension validation; no size limit; temp files not cleaned on success
Authorization ❌ None No role-based or API-key access control
CORS ⚠️ Permissive allow_origins=["*"]

Risks & Recommendations

Critical

  1. Missing authentication β€” All endpoints are publicly accessible

    • Fix: Add FastAPI middleware for API key validation
    • Fix: Integrate OAuth2/OIDC for multi-user scenarios
  2. No rate limiting β€” /batch endpoint can be abused (10K rows per request)

    • Fix: Add slowapi or custom rate-limiting middleware
    • Fix: Implement per-IP request quotas

High

  1. Temp file leak β€” Batch CSV saved via NamedTemporaryFile(delete=False) but os.unlink() only called on validation error, not on success

    • Fix: Add try/finally block to ensure cleanup
  2. CORS all origins β€” "*" allows any website to call the API

    • Fix: Restrict to known dashboard domains
  3. No server-side text length limit β€” ReviewInput.text accepts arbitrary length

    • Fix: Add StringConstraints(max_length=512) to Pydantic model

Medium

  1. No file size limit on batch uploads β€” Only row count limit (10K)

    • Fix: Add file-size check (e.g., 50MB max)
  2. Hardcoded credentials in docker-compose.yml β€” absa_user/absa_pass

    • Fix: Use environment variables or Docker secrets
  3. CSRF β€” No protection; token-based auth (when implemented) would mitigate

Low

  1. Weak health check β€” Returns "db": "connected" without actually pinging DB

    • Fix: Add actual DB ping to /health endpoint
  2. No request logging β€” No structured logging or audit trail

Configuration Checklist

  • Set ENABLE_METRICS to false if Prometheus not needed
  • Set LOG_LEVEL to WARNING in production
  • Use strong, random passwords for PostgreSQL
  • Run API behind TLS-terminating reverse proxy (Railway does this automatically)
  • Keep .env out of version control (already in .gitignore)
  • Rotate secrets regularly