Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This noncompliant code example logs the exception and wraps it in an unchecked a more general exception before re-throwing it.

...

While this exception is less likely to leak useful information than previous noncompliant code examples, it still reveals that the specified file cannot be read. More specifically, the program reacts differently to nonexistent file paths than it does to valid ones, and an attacker can still infer sensitive information about the file system from this program's behavior. Failure to restrict user input leaves the system vulnerable to a brute force attack in which the attacker discovers valid file names with repeated by issuing queries that collectively cover the space of possible file names; queries that result in the sanitized message exclude the requested file, the remaining possibilities represent the actual . Filenames that cause the program to return the sanitized exception indicate nonexistent files, filenames that don't, reveal existing files.

Compliant Solution (Canonicalization)

...

Compliant solutions must ensure that security exceptions such as java.security.AccessControlException and java.lang.SecurityException continue to be logged and sanitized appropriately. See rule ERR07-J. Prevent exceptions while logging data for additional information. The MyExceptionReporter class from rule ERR00-J. Do not suppress or ignore checked exceptions demonstrates an acceptable approach for this logging and sanitization.

For scalablity, the switch statement should be replaced with some sort of mapping from integers to valid file names, or at least an enum type representing valid files.

Risk Assessment

Exceptions may inadvertently reveal sensitive information unless care is taken to limit the information disclosure.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0d6051d094ae6a54-6cfa5487-45c84136-870fb3b6-777be35b37257bfc2204f20f"><ac:plain-text-body><![CDATA[

[[MITRE 2009

AA. Bibliography#MITRE 09]]

[CWE ID 209

http://cwe.mitre.org/data/definitions/209.html] "Information Exposure Through an Error Message"

]]></ac:plain-text-body></ac:structured-macro>

 

CWE ID 600 "Uncaught Exception in Servlet"

 

CWE ID 497 "Exposure of System Data to an Unauthorized Control Sphere"

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2ae5916e81151a19-022d1c24-447b4c19-b1c9b77c-683d94a06f44afbb28cf2928"><ac:plain-text-body><![CDATA[

[[Gong 2003

AA. Bibliography#Gong 03]]

9.1 Security Exceptions

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="86d058d833b71eca-2c5d597f-454447ed-9e5fb3c4-68f6419f40ebdd058b38d4e5"><ac:plain-text-body><![CDATA[

[[SCG 2007

AA. Bibliography#SCG 07]]

Guideline 3-4 Purge sensitive information from exceptions

]]></ac:plain-text-body></ac:structured-macro>

...