fix(api): drop permissive CORS allowed_origin_fn (origin reflection) #156
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/BUNYIP-124-cors-origin-reflection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The actix Cors builder registered an
allowed_origin_fnthat returned true for anyhttp://localhost*host (astarts_withprefix match, so attacker-controlledhttp://localhost.attacker.comalso matched) and for any origin ending in.{BUNYIP_WEB_ORIGIN host}(a bareends_with, so any*.{apex}subdomain matched). actix evaluates this closure in addition to the explicit.allowed_origin()entries, so the permissive closure overrode the tight CORS_ORIGIN allow-list. Combined with.supports_credentials(), an allowedCookierequest header, and.expose_headers(SET_COOKIE), this reflected credentialed CORS to untrusted origins.Remove the
allowed_origin_fn(and the now-unusedcors_domainderivation) so only the explicit, comma-separated CORS_ORIGIN entries are echoed back with credentials and everything else gets no Access-Control-Allow-Origin, matching the CORS policy (no wildcards, explicit list). Local dev already enumerateshttp://localhost:4400in CORS_ORIGIN, so dev is unaffected.#BUNYIP-124