Skip to content

Fix/cors configurable secure - #61

Merged
HC-ONLINE merged 4 commits into
mainfrom
fix/cors-configurable-secure
Sep 6, 2026
Merged

Fix/cors configurable secure#61
HC-ONLINE merged 4 commits into
mainfrom
fix/cors-configurable-secure

Conversation

@HC-ONLINE

Copy link
Copy Markdown
Owner

fix: configurable and secure CORS defaults

Description

Replaces hardcoded CORS configuration (allow_credentials=True, allow_methods=[""], allow_headers=[""]) with configurable fields via config.yaml and environment variables. Defaults are now secure by default.

Changes

Security:
cors_origins: default changed from [""] to [] (no cross-origin = secure)
cors_allow_credentials: default False (was hardcoded True)
cors_allow_methods: default ["GET","POST","PUT","DELETE","PATCH"] (was ["
"])
cors_allow_headers: default ["Authorization","Content-Type","X-API-Key"] (was ["*"])

Files modified:

src/ciberwebscan/config/models.py 4 new CORS fields in APIConfig + 4 validators
src/ciberwebscan/api/app.py:78-89 Middleware reads from config instead of hardcoded
docs/CONFIGURATION.md API section rewritten with CORS fields
docs/API.md CORS section, env vars, auth examples
examples/profiles/bugbounty.yaml CORS example with explicit domain
examples/profiles/pentest.yaml CORS example with explicit domain

Testing

ruff check + ruff format pass
Config loads CORS fields correctly from YAML
Env vars CIBERWEBSCAN_API_CORS_* work as expected
curl tests: allowed origin → 200 + CORS headers, disallowed origin → 400 "Disallowed CORS origin"

Notes

Backward-compatible: users with existing cors_origins: ["*"] in their config keep working
Default change only affects users without a config.yaml (the most insecure case currently)
No existing tests broken

@HC-ONLINE
HC-ONLINE merged commit 1a12697 into main Sep 6, 2026
3 checks passed
@HC-ONLINE
HC-ONLINE deleted the fix/cors-configurable-secure branch September 6, 2026 15:52
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.

1 participant