The CORS policy lets every website read the responses
What it finds
Access-Control-Allow-Origin: * lets scripts on every website read the responses of the server. For a public, unauthenticated API that is intended; for anything that relies on the user's network position or on credentials other than cookies, it hands the data to any site the user visits.
Reported are the header set to "*" with setHeader, header, set or append, the header given as "*" in an object literal, and the cors middleware configured with origin: "*".
From the rule's source, cors_any_origin.rs.
import cors from "cors";export function setup(app: { use(m: unknown): void }, res: { setHeader(n: string, v: string): void }) { app.use(cors({ origin: "*" }));tx0 reports: lets every website read the responses app.use(cors({ origin: "https://app.example.org" })); res.setHeader("Access-Control-Allow-Origin", "*");tx0 reports: lets every website read the responses res.setHeader("Access-Control-Allow-Origin", "https://app.example.org"); return { headers: { "Access-Control-Allow-Origin": "*" } };tx0 reports: lets every website read the responses} 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/ts: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/ts:cors-any-origin] reason="..."tx0 explain tx0/ts:cors-any-origin shows the same in the terminal. Found a false positive? Report it.