Date: 2026-08-09 Auditor: Automated security scan Scope: Full repository — code, configuration, Docker, dependencies
The codebase demonstrates strong security practices in several areas: all SQL queries use parameterized placeholders, credentials are loaded from environment variables (never hard-coded), the alerting system redacts sensitive keys, and the dashboard is strictly read-only. However, the audit identified 6 critical or high-severity findings that require remediation.
| Severity | Count | Status |
|---|---|---|
| Critical | 1 | Fixed |
| High | 5 | Fixed |
| Medium | 5 | Documented |
| Low | 6 | Documented |
- Files:
app/models/probability_model.py:463,app/models/calibration.py:242 - Risk:
pickle.load()executes arbitrary code embedded in the serialized file. If an attacker can replace a model.pklfile on disk, they achieve remote code execution. - Status: FIXED — Replaced with a
RestrictedUnpicklerthat whitelists onlynumpy,sklearn, andlightgbmclasses. All other classes are rejected.
- File:
Dockerfile - Risk: No
USERdirective. Any code execution vulnerability inside the container grants root-level access. - Status: FIXED — Added non-root
appuserwithUSER appuser.
- File: (missing)
- Risk:
COPY . .copies everything into the image including.env(if present on build host),.git/,tests/,data/*.db, and all development artifacts. - Status: FIXED — Created
.dockerignoreexcluding.git,.env*,data/,tests/,notebooks/,scripts/,__pycache__,*.pyc, development docs.
- File:
app/api/app.py,app/api/dependencies.py - Risk: All API endpoints are publicly accessible to anyone on the network. While the API is read-only, it exposes trading positions, P&L, risk limits, and audit trails.
- Status: FIXED — Added optional API key authentication via
POLY_API_KEYenvironment variable. When set, all requests must includeX-API-Keyheader. When unset (research mode), auth is bypassed.
- File:
requirements.txt:24-27 - Risk:
pytest,ruff,mypyare installed in the production image, expanding the attack surface unnecessarily. - Status: FIXED — Split into
requirements.txt(production only) andrequirements-dev.txt(development/testing). Dockerfile uses onlyrequirements.txt.
- File:
docker-compose.yml - Risk: No
read_only,cap_drop,security_opt, or resource limits. Services run with full capabilities and unlimited resources. - Status: FIXED — Added
read_only: true,cap_drop: [ALL],security_opt: [no-new-privileges:true], and CPU/memory limits.
- File:
app/api/app.py - Risk: Cross-origin requests are not restricted.
- Mitigation: API is server-side only; dashboard connects via internal Docker network. Consider adding explicit CORS if browser clients are added.
- File:
app/api/app.py - Risk: API vulnerable to denial-of-service without rate limiting.
- Mitigation: Low risk for internal/localhost deployment. Add
slowapiif exposed to untrusted networks.
- File:
Dockerfile - Risk: Build tools and pip cache bloat the final image.
- Mitigation: Addressed partially by removing dev dependencies. Full multi-stage build recommended for production.
- File:
requirements.txt - Risk: Different builds may install different versions.
- Mitigation: Use
pip-compileorpip freezeto generate locked requirements for reproducible builds.
- File:
pyproject.toml - Risk: Major version bumps could introduce breaking changes.
- Mitigation: Add upper bounds consistent with
requirements.txt.
- File:
Dockerfile:1—python:3.11-slim(no patch version) - Mitigation: Pin to specific digest for reproducible builds.
- Mitigation: Add
HEALTHCHECKfor orchestrator health monitoring.
- File:
.gitignore:2— only excludes.envliterally - Mitigation: Added
.env.*patterns (excluding.env.example).
- Mitigation: Added
*.pem,*.key,*.p12,*.pfxpatterns.
- Mitigation: Removed deprecated
version: "3.9"key.
- File:
docker-compose.yml:10-11, 34-35 - Mitigation: Consider binding to
127.0.0.1for local-only access.
| Area | Status |
|---|---|
| SQL injection | CLEAN — All queries use parameterized ? placeholders |
| Hard-coded secrets | CLEAN — No credentials found in source code |
| Credential logging | CLEAN — AlertDispatcher redacts sensitive keys |
exec()/eval() |
CLEAN — Not used anywhere |
| Private key handling | CLEAN — No wallet integration; credentials in env vars only |
| Dashboard exposure | CLEAN — Read-only, no credentials displayed |
.env.example |
CLEAN — All credential fields empty |
.gitignore |
CLEAN — .env excluded from version control |
| Circuit breaker events | CLEAN — Never log credentials or API keys |
| Audit event bus | CLEAN — Module docstring prohibits credential logging |
- Pin exact dependency versions with hashes for reproducible builds
- Add rate limiting (
slowapi) if API is exposed beyond localhost - Add CORS middleware if browser-based clients are added
- Consider full multi-stage Docker build for minimal production images
- Add HEALTHCHECK to Dockerfile for orchestrator integration
- Bind ports to 127.0.0.1 in docker-compose for local-only access
- Run container security scanning (Trivy, Snyk) in CI/CD pipeline
- Add pre-commit hooks for secret detection (e.g.,
detect-secrets)