Cross-origin requests are allowed from every origin
What it finds
Allowing every origin lets any web site read the responses of this one in its visitors' browsers, with their cookies if credentials are allowed too. Reported are CORS(app) from flask_cors without origins, CORSMiddleware and CORS given "*" as allow_origins or origins, the Django settings CORS_ALLOW_ALL_ORIGINS = True and CORS_ORIGIN_ALLOW_ALL = True, and a header Access-Control-Allow-Origin set to "*".
From the rule's source, cors_any_origin.rs.
from flask_cors import CORSfrom fastapi.middleware.cors import CORSMiddleware CORS(app)tx0 reports: CORS(app) without origins lets every origin read the responsesCORS(app, origins=["https://example.com"])app.add_middleware(CORSMiddleware, allow_origins=["*"])tx0 reports: every origin may read the responsesCORS_ALLOW_ALL_ORIGINS = Truetx0 reports: this setting lets every origin read the responsesresponse.headers["Access-Control-Allow-Origin"] = "*"tx0 reports: this header lets every origin read the response Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:cors-any-origin" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:cors-any-origin] reason="..."tx0 explain tx0/python:cors-any-origin shows the same in the terminal. Found a false positive? Report it.