Output encoding; CSP; HTML sanitizer for rich text
XXE
Disable external entities in XML parser
SSRF
URL allow-list; block private IP ranges
Path traversal
Canonical path + base dir check
LDAP injection
Escape or use parameterized search
2. Implementing CORS Configuration
Example: Spring CORS
@BeanCorsConfigurationSource corsConfig() { var c = new CorsConfiguration(); c.setAllowedOrigins(List.of("https://app.acme.com")); c.setAllowedMethods(List.of("GET","POST","PUT","DELETE","PATCH")); c.setAllowedHeaders(List.of("Authorization","Content-Type","X-Correlation-Id")); c.setExposedHeaders(List.of("X-Correlation-Id")); c.setAllowCredentials(true); c.setMaxAge(3600L); var src = new UrlBasedCorsConfigurationSource(); src.registerCorsConfiguration("/**", c); return src;}
Warning: Never use * for origins when allowCredentials=true.