Skip to content

fix: restrict CORS and guard scan endpoints by origin (#334) - #337

Open
rwinkelman wants to merge 5 commits into
msoedov:mainfrom
rwinkelman:fix/cors-origin-allowlist-334
Open

rwinkelman wants to merge 5 commits into
msoedov:mainfrom
rwinkelman:fix/cors-origin-allowlist-334

Conversation

@rwinkelman

Copy link
Copy Markdown
Contributor

Summary

  • Default CORS to an empty origin allowlist with allow_credentials=False instead of wildcard *
  • Add OriginGuardMiddleware so cross-origin browser POSTs to /stop, /scan-csv, /verify, and /scan are rejected unless same-origin or explicitly allowlisted
  • Configure origins via AGENTIC_SECURITY_CORS_ORIGINS or [server].cors_allow_origins in agentic_security.toml

Closes #334 (complements @DevamShah's branch — happy to close in favor of theirs if they open first).

Test plan

  • Unit tests for CORS allowlist + preflight behavior
  • Unit tests for origin guard (foreign origin blocked, same-origin + allowlist allowed, non-browser clients without Origin unchanged)

@rwinkelman

Copy link
Copy Markdown
Contributor Author

Opened this since #334 still has no PR from @DevamShah — happy to close/rebase if they land first.

@rwinkelman

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. Grooming pass — branch updated for merge readiness.

@rwinkelman
rwinkelman force-pushed the fix/cors-origin-allowlist-334 branch from 54519a1 to 7b9a699 Compare September 19, 2026 14:09
@rwinkelman

Copy link
Copy Markdown
Contributor Author

Grooming pass 2026-09-28: rebased onto current main to retrigger CI (prior failure looked like a runner pip uninstall babel PermissionError, not a patch defect).

Default to an empty allowlist, disable credentials, and block cross-origin
browser POSTs to /stop, /scan, /verify, and /scan-csv unless explicitly allowed.
Use None as the settings_var default so lru_cache can key the call, and
apply black-style wrapping CI expects.
@rwinkelman
rwinkelman force-pushed the fix/cors-origin-allowlist-334 branch from 7b9a699 to f4728b2 Compare September 28, 2026 10:02

This branch has not been deployed

No deployments
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.

CORS: allow_origins=["*"] exposes unauthenticated /scan, /scan-csv, /stop, /verify to any web origin

1 participant