Repository navigation
Adopt security hardening from PR #17 - #19
Merged
Merged
Conversation
Extracts the reviewable, self-contained hardening from PR #17 and reconciles it with the fixes already on main from PR #18. The rest of PR #17 (bollinger_evolver/, frontend/, stage_*.md docs) is not included. Agent API: - Reject API keys passed via query string; headers only. Query keys leak into access logs, browser history, and proxy diagnostics - Replace wildcard CORS with an explicit origin allowlist - Refuse to start with a missing, weak, or short (<16 char) master key - Bind 127.0.0.1 by default instead of 0.0.0.0; publish the container port on 127.0.0.1 only and pass --api-host explicitly in compose - Stop echoing internal exception text in 500 responses - Leave /api/v1/health unauthenticated (liveness + timestamp only) so container healthchecks work; every other endpoint still requires auth - Close the listening socket on stop() Deployment safety (fail closed instead of pretending): - StrategyDeployer no longer auto-approves when no approval callback is set; it fails the deployment and says so - Deployment notes now state plainly that shadow trading and gradual rollout are not executed, instead of implying a pipeline that does not run; total_phases reflects reality - AdaptiveOptimizer no longer auto-approves purely on improvement % - RollbackManager defaults to enabled=False / require_confirmation=True, and refuses to run without a deploy callback rather than reporting a rollback that never restored the strategy file - New rollback_require_confirmation setting so operators who opt into auto_rollback_enabled still get unattended rollback Reconciliation notes: PR #17 predates PR #18, so applying it verbatim would have reverted the read-permission gate, the rate limiter, the real rollback endpoint, and the deployer/rollback-manager injection. Those are kept, and tests/test_api_hardening.py pins them so a future merge cannot silently drop them again. Tests: 232 passed (was 210 on main). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracts the reviewable, self-contained security hardening from #17 (contributed by @jehonathanBao) and reconciles it with the fixes already on main from #18.
The rest of #17 —
bollinger_evolver/(212 files),frontend/(85 files), and 66stage_*.mdprocess documents — is not included here. See the review notes on #17 for why.Agent API
default-keyand the placeholder keys are rejected by name.127.0.0.1by default instead of0.0.0.0; publish the container port on127.0.0.1only and pass--api-hostexplicitly in compose./api/v1/healthunauthenticated (returns only liveness + timestamp) so container healthchecks work; every other endpoint still requires auth.stop().Deployment safety — fail closed instead of pretending
StrategyDeployerno longer auto-approves when no approval callback is set; it fails the deployment and says why.total_phasesreflects reality.AdaptiveOptimizerno longer auto-approves purely on improvement percentage.RollbackManagerdefaults toenabled=False/require_confirmation=True, and refuses to run without a deploy callback rather than reporting a rollback that never restored the strategy file.rollback_require_confirmationsetting so operators who explicitly opt intoauto_rollback_enabledstill get unattended rollback; the dataclass default stays fail-closed for anyone constructingRollbackConfig()bare.Reconciliation
PR #17 predates #18, so applying it verbatim would have reverted four things now on main: the read-permission gate on GET endpoints, the rate limiter, the real rollback endpoint, and the deployer/rollback-manager injection into
AdaptiveOptimizer. Those are kept.tests/test_api_hardening.pyis new and pins those invariants — a write-only key cannot read, read endpoints are rate limited, the rollback endpoint delegates to the deployer and reports failure honestly, and the rollback manager never claims success without a deploy callback. A future merge cannot silently drop them again.Test plan
python3 -m pytest tests/ -q→ 232 passed (210 on main; +14 from Add mock-first GA pipeline, safety gates, and custom strategy abstraction #17's tests, +8 new regression tests)ga.json.exampledocker-compose.adaptive.ymlandga.json.exampleparse cleanly🤖 Generated with Claude Code