Cross-origin requests are allowed from every web site with *
What it finds
response.setHeader("Access-Control-Allow-Origin", "*"), allowedOrigins("*") and @CrossOrigin(origins = "*"), and the same with origin patterns, let scripts of every web site read the responses of this one in the visitor's browser (CWE-942). Naming the origins that need access keeps other sites out.
From the rule's source, any_origin_allowed.rs.
class Cors { void headers(javax.servlet.http.HttpServletResponse response) { response.setHeader("Access-Control-Allow-Origin", "*");tx0 reports: every web site may read these responses response.setHeader("Access-Control-Allow-Origin", "https://example.com"); } @CrossOrigin(origins = "*")tx0 reports: every web site may read these responses void open() {}} 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/java:any-origin-allowed" = "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/java:any-origin-allowed] reason="..."tx0 explain tx0/java:any-origin-allowed shows the same in the terminal. Found a false positive? Report it.