CORS open to every origin
CORS open to every origin. Allows any website to call this (cors()).
This is how the comment reads inline, under the flagged line.
Why it matters
A wildcard origin lets any page in a user's browser read these responses. With credentials it's an account takeover path.
What to do
List the origins that need access.
Examples
app.use(cors());
app.use(cors({ origin: ["https://app.example.com"] }));What it catches
It reads a pattern on each line, aware of strings and comments. Languages: Any file. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
app.use(cors());
res.setHeader("Access-Control-Allow-Origin", "*");Left alone
app.use(cors({ origin: allowed }));Research
CORS open to every origin. Any site can call the API from a user's browser.
- skill: improve
- owner's notes
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"cors-wildcard"
],
"severity": {
"cors-wildcard": "low"
}
}
}