Propagating the content of exceptions without performing explicit filtering is often associated with information leakage. An attacker may craft input parameters such that underlying structures and mechanisms may get exposed inadvertently.
...
Noncompliant Code Example
This example demonstrates code that accepts a file name as an input argument on which operations are to be performed. An attacker can gain insights on the underlying file system structure by repeatedly passing different paths to fictitious files. When a file is not found, the FileInputStream
constructor throws a FileNotFoundException
. Other risks such as revelation of the user's home directory and thus as a result the user name also manifest themselves.
...
Code Block | ||
---|---|---|
| ||
import java.io.FileInputStream; import java.io.FileNotFoundException; class exception { public static void main(String[] args) { try { FileInputStream dis = new FileInputStream("c:\\" + args[1]); } catch(FileNotFoundException fnf) { System.out.println("Error: Operation could not be performed"); } //sanitized message } } |
...
Risk Assessment
TODO
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
SEC00-J | ?? | ?? | ?? | P?? | L?? |
Automated Detection
TODO
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
(h2. Ref)erences
Secure coding in Java http://java.sun.com/security/seccodeguide.html