| name | cwe-200-information-exposure |
| description | Use this skill when you need to remediate CWE-200 (Information Exposure) vulnerabilities in Java code. Triggers on SAST findings, security reviews, or when fixing information exposure issues. |
| version | 1.0.0 |
| license | MIT |
| tags | ["security","java","cwe-200","remediation","sast"] |
CWE-200 Information Exposure
Description
Information Exposure
Reference:
https://cwe.mitre.org/data/definitions/200.html
OWASP Category: A01:2021 – Broken Access Control
Vulnerable Pattern
❌ Example 1: Vulnerable Pattern
@ExceptionHandler(Exception.class)
public ResponseEntity<?> handleException(Exception e) {
e.printStackTrace();
return ResponseEntity.status(500).body(e.getMessage());
}
Why it's vulnerable: This pattern is vulnerable to Information Exposure
Deterministic Fix
✅ Secure Implementation: Secure Implementation
@ExceptionHandler(Exception.class)
public ResponseEntity<?> handleException(Exception e) {
String errorId = UUID.randomUUID().toString();
log.error("Error ID {}: {}", errorId, e.getMessage(), e);
return ResponseEntity.status(500)
.body(Map.of("error", "Internal error", "errorId", errorId));
}
Why it's secure: Implements proper protection against Information Exposure
Detection Pattern
Look for these patterns in your codebase:
grep -rn "printStackTrace\\|getMessage.*body\\|e.toString" --include="*.java"
Remediation Steps
-
Return generic error messages to users
-
Log detailed errors internally with correlation IDs
-
Disable debug mode in production
-
Review error responses for information leakage
Key Imports
import java.util.UUID;
Verification
After remediation:
-
Run SAST scanner to confirm vulnerability is resolved
-
Review all instances of the vulnerable pattern
-
Add unit tests that verify the secure implementation
-
Check for similar patterns in related code
Trigger Examples
Fix CWE-200 vulnerability
Resolve Information Exposure issue
Secure this Java code against information exposure
SAST reports CWE-200
Common Vulnerable Locations
| Controller | *Controller.java | User input handling |
| Service | *Service.java | Business logic |
| Repository | *Repository.java | Data access |
References
Source: Generated by Java CWE Security Skills Generator
Last Updated: 2026-03-07