Difference between revisions of "Improper cleanup on thrown exception"

From OWASP
Jump to: navigation, search
(Examples)
(Reverting to last version not containing links to s1.shard.jp)
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
{{Template:SecureSoftware}}
 +
{{Template:Vulnerability}}
  
 +
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''
  
{{Template:SecureSoftware}}
+
[[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]]
  
==Overview==
+
==Description==
  
 
Causing a change in flow, due to an exception, can often leave the code in a bad state.
 
Causing a change in flow, due to an exception, can often leave the code in a bad state.
  
==Consequences ==
+
'''Consequences'''
  
* Implementation: The code could be left in a bad state.
+
* Implementation: The code could be left in a bad state.
  
==Exposure period ==
+
'''Exposure period'''
  
* Implementation: Many logic errors can lead to this condition.  
+
* Implementation: Many logic errors can lead to this condition.  
  
==Platform ==
+
'''Platform'''
  
* Languages: Java, C, C# or any language which can throw an exception.
+
* Languages: Java, C, C# or any language which can throw an exception.
 +
* Operating platforms: Any
  
* Operating platforms: Any
+
'''Required resources'''
 
+
==Required resources ==
+
  
 
Any
 
Any
  
==Severity ==
+
'''Severity'''
  
 
Medium
 
Medium
  
==Likelihood   of exploit ==
+
'''Likelihood of exploit'''
  
 
Medium
 
Medium
  
==Avoidance and mitigation ==
+
Often, when functions or loops become complicated, some level of cleanup in the beginning to the end is needed. Often, since exceptions can disturb the flow of the code, one can leave a code block in a bad state.
  
* Implementation: If one breaks from a loop or function by throwing an exception, make sure that cleanup happens or that you should exit the program. Use throwing exceptions sparsely.
 
  
==Discussion ==
 
  
Often, when functions or loops become complicated, some level of cleanup in the beginning to the end is needed. Often, since exceptions can disturb the flow of the code, one can leave a code block in a bad state.
+
==Risk Factors==
 +
 
 +
TBD
  
==Examples ==
+
==Examples==
  
 
In C++/Java:
 
In C++/Java:
Line 72: Line 74:
 
In this case, you may leave a thread locked accidentally.
 
In this case, you may leave a thread locked accidentally.
  
==Related problems ==
 
  
Not available.
+
==Related [[Attacks]]==
  
==Categories ==
+
* [[Attack 1]]
 +
* [[Attack 2]]
  
[[Category:Vulnerability]]
 
  
[[Category:General Logic Errors]]
+
==Related [[Vulnerabilities]]==
 +
 
 +
* [[Vulnerability 1]]
 +
* [[Vulnerabiltiy 2]]
 +
 
 +
 
 +
==Related [[Controls]]==
 +
 
 +
* Implementation: If one breaks from a loop or function by throwing an exception, make sure that cleanup happens or that you should exit the program. Use throwing exceptions sparsely.
 +
 
 +
==Related [[Technical Impacts]]==
 +
 
 +
* [[Technical Impact 1]]
 +
* [[Technical Impact 2]]
 +
 
 +
 
 +
==References==
 +
 
 +
TBD
 +
 
 +
 
 +
__NOTOC__
 +
 
 +
 
 +
[[Category:OWASP ASDR Project]]
 +
[[Category:Vulnerability]]
 +
[[Category:Error Handling Vulnerability]]
 +
[[Category:General Logic Error Vulnerability]]
 +
[[Category:OWASP_CLASP_Project]]

Latest revision as of 07:50, 3 June 2009

This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.


Last revision (mm/dd/yy): 06/3/2009

Vulnerabilities Table of Contents

Description

Causing a change in flow, due to an exception, can often leave the code in a bad state.

Consequences

  • Implementation: The code could be left in a bad state.

Exposure period

  • Implementation: Many logic errors can lead to this condition.

Platform

  • Languages: Java, C, C# or any language which can throw an exception.
  • Operating platforms: Any

Required resources

Any

Severity

Medium

Likelihood of exploit

Medium

Often, when functions or loops become complicated, some level of cleanup in the beginning to the end is needed. Often, since exceptions can disturb the flow of the code, one can leave a code block in a bad state.


Risk Factors

TBD

Examples

In C++/Java:

public class foo {
  public static final void main( String args[] ) {
        boolean returnValue;
        returnValue=doStuff();
  }
  public static final boolean doStuff( ) {
        boolean threadLock;
        boolean truthvalue=true;

        try {
                while(//check some condition){
                        threadLock=true;
                        //do some stuff to truthvalue
                        threadLock=false;
                }
        } catch (Exception e){
                System.err.println("You did something bad");
                        if (something) return truthvalue;
        }
        return  truthvalue;
  }
}

In this case, you may leave a thread locked accidentally.


Related Attacks


Related Vulnerabilities


Related Controls

  • Implementation: If one breaks from a loop or function by throwing an exception, make sure that cleanup happens or that you should exit the program. Use throwing exceptions sparsely.

Related Technical Impacts


References

TBD