← Java / Spring · Contents

JAVA-059 / Intermediate

Permissive CORS (* with credentials)

A05:2021 Security Misconfiguration · CWE-942 Permissive Cross-domain Policy

Why is this a problem?

Arbitrary sites can read logged-in users' responses.

How to fix it

java
registry.addMapping("/api/**").allowedOrigins("https://app.example.com").allowCredentials(true);

Further reading