Skip to content

Claude/audit repository lup yn#24

Merged
Frostbite1536 merged 7 commits intomainfrom
claude/audit-repository-LupYN
Mar 11, 2026
Merged

Claude/audit repository lup yn#24
Frostbite1536 merged 7 commits intomainfrom
claude/audit-repository-LupYN

Conversation

@Frostbite1536
Copy link
Owner

No description provided.

claude added 7 commits March 10, 2026 22:12
Thorough audit covering authentication, JWT, CORS, data parsing,
floating-point precision, dependency management, and API security.
Identifies 5 high, 8 medium, and 6 low severity findings with
specific remediation recommendations.

https://claude.ai/code/session_016BuMfGe7JFazCAYJZKmors
Adds HDR-1 (medium severity): the FastAPI app has no middleware
for standard security headers like X-Frame-Options,
X-Content-Type-Options, and Strict-Transport-Security.

https://claude.ai/code/session_016BuMfGe7JFazCAYJZKmors
HIGH severity fixes:
- Add 10 MB upload size limit to prevent OOM in trade_service.py
- Use Numeric(18,8) columns instead of Float for money fields in trade model
- Fix cumulative PnL drift by using Decimal accumulation in pnl.py
- Generate random ephemeral SECRET_KEY in dev mode instead of using
  predictable default (production still requires explicit env var)

MEDIUM severity fixes:
- Add SecurityHeadersMiddleware (X-Content-Type-Options, X-Frame-Options,
  Referrer-Policy, HSTS, X-XSS-Protection, Permissions-Policy)
- Add rate limiter key eviction (bounded at 10k keys) with docs noting
  single-process limitation
- Restrict CORS allow_methods/allow_headers to actual values used
- Increase minimum password length from 6 to 8 characters
- Fix Manifold _get_user_id: handle missing 'id' in API response
  gracefully instead of uncaught KeyError
- Add logging to Kalshi normalize_trade parse errors instead of silent
  swallowing
- Add Pydantic field constraints (ge/le/min_length/max_length) to
  TradeBase schema
- Require authentication on /trades/providers endpoint

LOW severity fixes:
- Unify infinity cap to shared INF_CAP constant (999999.99) across
  trade_loader.py and metrics.py
- Extract USDC_DECIMALS constant in limitless.py and trade_loader.py
- Clear Kalshi private key from memory after fetch_trades completes
- Remove Polymarket wallet address from log messages

All 370 non-mcp tests pass (6 pre-existing mcp import failures unchanged).

https://claude.ai/code/session_016BuMfGe7JFazCAYJZKmors
- ARCHITECTURE.md: Add Security Architecture section with rate limiting,
  security headers, CORS, auth, upload protection, credential handling,
  and numeric precision invariants. Update PnL, trade loader, and
  FastAPI sections with new security/precision details.
- README.md: Note security headers and auth on all endpoints.
- TUTORIAL.md: Fix endpoint names (signup not register), update password
  requirement to 8 chars, note 10 MB upload limit, note providers
  endpoint now requires auth, add SECRET_KEY production guidance.
- INSTALL.md: Add SECRET_KEY env var documentation with generation
  command, explain dev vs production behavior.
- .env.example: Replace hardcoded SECRET_KEY with commented-out
  placeholder and generation instructions.
- SECURITY_AUDIT.md: Mark all 20 findings as resolved with details
  of each fix. Update executive summary with resolution status.

https://claude.ai/code/session_016BuMfGe7JFazCAYJZKmors
New files:
- CLAUDE.md: Coding agent guide with invariants, conventions, and quick reference
- CONTRIBUTING.md: Contributor guide with setup, code standards, and PR process
- CHANGELOG.md: v1.0.0 changelog documenting all features and security work
- Makefile: Common commands (test, lint, fmt, serve, mcp, gui, clean)
- Dockerfile + docker-compose.yml: Multi-stage build for API and MCP servers
- .github/workflows/ci.yml: GitHub Actions CI (test on 3.9-3.12, lint)
- .flake8: Flake8 configuration (line-length 100, per-file ignores)
- .claude/settings.json: SessionStart hook for auto-installing deps
- data/samples/: Sample trade data for all 4 providers
- tests/api/: 40 FastAPI integration tests (auth, trades, security, isolation)
- prediction_analyzer/py.typed + prediction_mcp/py.typed: PEP 561 markers

Modified files:
- pyproject.toml: Add cryptography to core deps, fix author/URLs, add
  black/mypy/pytest config, add dev deps (pytest-asyncio, httpx, mypy, stubs)
- prediction_analyzer/__init__.py: Fix author placeholder
- prediction_mcp/server.py: Add MCP resources (3 dynamic resources exposing
  session state) and prompts (3 templates: analyze_portfolio, compare_periods,
  daily_report)
- ARCHITECTURE.md: Document new MCP resources and prompts
- .gitignore: Add charts_output/ and .mypy_cache/

Bug fixes found during testing:
- auth_service.py: JWT 'sub' claim now encoded as string per RFC 7519
  (PyJWT >=2.9 enforces this). decode_token parses it back to int.
- trades.py: JSON export uses default=str to handle Decimal from Numeric columns

All 612 tests pass (572 existing + 40 new API tests).

https://claude.ai/code/session_016BuMfGe7JFazCAYJZKmors
- Run black formatter on all 110 source files
- Make CI conditionally skip mcp extra on Python 3.9 (mcp requires >=3.10)
- Skip MCP tests on Python 3.9 in CI matrix

https://claude.ai/code/session_016BuMfGe7JFazCAYJZKmors
@Frostbite1536 Frostbite1536 merged commit 9910d24 into main Mar 11, 2026
1 of 5 checks passed
@Frostbite1536 Frostbite1536 deleted the claude/audit-repository-LupYN branch March 17, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants