543
on the local file system and the method setInputFile must be called to set the name of the input file
to be read in the default directory. The method readInputFile will create the FileReader object and
will read the contents of the file. If the method setInputFile is not called prior to calling the method
readInputFile then the File object will remain null when initializing the FileReader object. A Java
RuntimeException will be raised, and an error message will be output to the user.
Example Language: Java (Bad)
public class InputFileRead {
private File readFile = null;
private FileReader reader = null;
private String inputFilePath = null;
private final String DEFAULT_FILE_PATH = "c:\\somedirectory\\";
public InputFileRead() {
inputFilePath = DEFAULT_FILE_PATH;
}
public void setInputFile(String inputFile) {
/* Assume appropriate validation / encoding is used and privileges / permissions are preserved */
}
public void readInputFile() {
try {
reader = new FileReader(readFile);
...
} catch (RuntimeException rex) {
System.err.println("Error: Cannot open input file in the directory " + inputFilePath);
System.err.println("Input file has not been set, call setInputFile method before calling readInputFile");
} catch (FileNotFoundException ex) {...}
}
}
However, the error message output to the user contains information regarding the default directory
on the local file system. This information can be exploited and may lead to unauthorized access
or use of the system. Any Java RuntimeExceptions that are handled should not expose sensitive
information to the user.
Observed Examples
Reference Description
CVE-2004-1581 chain: product does not protect against direct request of an include file,
leading to resultant path disclosure when the include file does not successfully
execute.
https://www.cve.org/CVERecord?id=CVE-2004-1581
CVE-2004-1579 Single "'" inserted into SQL query leads to invalid SQL query execution,
triggering full path disclosure. Possibly resultant from more general SQL
injection issue.
https://www.cve.org/CVERecord?id=CVE-2004-1579
CVE-2005-0459 chain: product does not protect against direct request of a library file, leading to
resultant path disclosure when the file does not successfully execute.
https://www.cve.org/CVERecord?id=CVE-2005-0459
CVE-2005-0443 invalid parameter triggers a failure to find an include file, leading to infoleak in
error message.
https://www.cve.org/CVERecord?id=CVE-2005-0443
CVE-2005-0433 Various invalid requests lead to information leak in verbose error messages
describing the failure to instantiate a class, open a configuration file, or execute
an undefined function.
https://www.cve.org/CVERecord?id=CVE-2005-0433
CVE-2004-1101 Improper handling of filename request with trailing "/" causes multiple
consequences, including information leak in Visual Basic error message.
https://www.cve.org/CVERecord?id=CVE-2004-1101
Functional Areas
CWE Version 4.14
CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer
CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer