<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Safer Code - Secure Coding In C \ C++ And More.. &#187; Java</title>
	<atom:link href="http://www.safercode.com/blog/category/java/feed" rel="self" type="application/rss+xml" />
	<link>http://www.safercode.com/blog</link>
	<description>Making Your Code Faster, Stronger, Safer…</description>
	<lastBuildDate>Tue, 05 Jan 2010 07:59:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Improper Variable Initialization</title>
		<link>http://www.safercode.com/blog/2009/01/13/improper-variable-initialization.html</link>
		<comments>http://www.safercode.com/blog/2009/01/13/improper-variable-initialization.html#comments</comments>
		<pubDate>Tue, 13 Jan 2009 05:21:08 +0000</pubDate>
		<dc:creator>Amit Goel</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Efficiency]]></category>
		<category><![CDATA[initialization]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[variable declaration]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.safercode.com/blog/?p=28</guid>
		<description><![CDATA[<!-- Powered by Shantz WP Prefix Suffix. Tech Blog: http://tech.shantanugoel.com/ Secure Programming Blog: http://www.safercode.com/blog/ Blog: http://blog.shantanugoel.com/ -->Except for few good C programmers, others generally tend to ignore variable initialization or I should rather say “proper variable initialization”. Generally seen, the variable declaration itself is not done with a good thinking. Improper local variable initialization might not be good for the working of the program but improper global variable initialization might get [...]]]></description>
			<content:encoded><![CDATA[<!-- Powered by Shantz WP Prefix Suffix. Tech Blog: http://tech.shantanugoel.com/ Secure Programming Blog: http://www.safercode.com/blog/ Blog: http://blog.shantanugoel.com/ --><p style='border:thin dotted black; padding:3mm;background-color: rgb(250,150,250);'><strong><a href="http://feedproxy.google.com/SaferCode" rel="alternate" type="application/rss+xml">Subscribe To Our Feed</a> | <a href="http://twitter.com/safercode" rel="nofollow">Follow Us On Twitter</a> | <a href="http://feedburner.google.com/fb/a/mailverify?uri=safercode" rel="nofollow" target="_blank">Get Updates on Email</a></strong></p>
<p>Except for few good C programmers, others generally tend to ignore variable initialization or I should rather say “proper variable initialization”. Generally seen, the variable declaration itself is not done with a good thinking. Improper local variable initialization might not be good for the working of the program but improper global variable initialization might get your software or system hacked.</p>
<p>The uninitialized variable or a wrongly initialized variable might lead a program to change its normal course of flow from the intended one. For example: If a variable “index” is being used for array navigation and is left uninitialized, it might contain a garbage value which can lead to array index out of bounds error. or if the variable “index” is initialized wrongly to –1, it might lead to serious flaw in code flow. Even if an integer value is being initialized to ‘0’, it might lead to a security check bypass because for some programs, even a ‘0’ is considered a valid value.</p>
<p>Lets take an example of a code piece.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"> <span style="color: #993333;">int</span> isMachineRunning <span style="color: #339933;">=</span> GetMachineStatus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #993333;">int</span> state <span style="color: #339933;">=</span> GetUserState<span style="color: #009900;">&#40;</span>isMachineRunning<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #993333;">int</span> userid <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>state<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	userid <span style="color: #339933;">=</span> ExtractUserID<span style="color: #009900;">&#40;</span>state<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* do stuff */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>uid <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	DoAdminThings<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-28"></span><br />
Now, in the above example, userId is initialized to &#8216;0&#8242;. and adminUserID is also equal to &#8216;0&#8242;. Consider that the GetUserState() function somehow failed to get the state of user then, the If condition check might fail resulting in failure to obtain a valid user id. This, In turn, will still lead to admin access as we have wrongly initialized the userid variable to &#8216;0&#8242; which is equal to admin user id. Let&#8217;s consider another example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">char</span> str<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">20</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
strcat<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;hello world&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This might seem innocent enough, but str was not initialized, so it contains random memory. As a result, str[0] might not contain the null terminator, so the copy might start at an offset other than 0. The consequences can vary, depending on the underlying memory. If a null terminator is found before str[8], then some bytes of random garbage will be printed before the &#8220;hello world&#8221; string. The memory might contain sensitive information from previous uses, such as a password stored in a buffer. In this example, it might not be a big deal, but consider what could happen if large amounts of memory are printed out before the null terminator is found. If a null terminator isn&#8217;t found before str[8], then a buffer overflow could occur, since strcat will first look for the null terminator, then copy 12 bytes starting with that location. Alternately, a buffer over-read might occur if a null terminator isn&#8217;t found before the end of the memory segment is reached, leading to a segmentation fault and crash. I hope that the above mentioned examples are goos enough to emphasize on the correct initialization of variables and yes, that each and every needs to be initialized.</p>
<p>The four mandatory steps to follow for correct variable declaration is :</p>
<ol>
<li>Explicitly initialize all variable or data stores with the correct and expected values either at the first usage or during declaration as a must rule.</li>
<li>Properly do input validation to make sure that the variable usage in the first statement itself is initialized to expected value.</li>
<li>Avoid race conditions during initialization routine.</li>
<li>Definitely run some static analysis tool on your code to make sure that it raises all sorts of warnings or errors to warn you before you publish your code.</li>
</ol>
<p>Once you follow the above mentioned checklist, I am sure that you’ll face least of problems or issues with variable initializations.
<p style='border:thin dotted black; padding:3mm;background-color: rgb(250,150,250);'>© <a href="http://www.safercode.com/blog/">Safer Code</a> | <a href="http://www.safercode.com/blog/2009/01/13/improper-variable-initialization.html">Improper Variable Initialization</a></p>



Share and Enjoy:


	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2009%2F01%2F13%2Fimproper-variable-initialization.html&amp;title=Improper%20Variable%20Initialization&amp;bodytext=Except%20for%20few%20good%20C%20programmers%2C%20others%20generally%20tend%20to%20ignore%20variable%20initialization%20or%20I%20should%20rather%20say%20%E2%80%9Cproper%20variable%20initialization%E2%80%9D.%20Generally%20seen%2C%20the%20variable%20declaration%20itself%20is%20not%20done%20with%20a%20good%20thinking.%20Improper%20local%20v" title="Digg"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2009%2F01%2F13%2Fimproper-variable-initialization.html&amp;title=Improper%20Variable%20Initialization&amp;notes=Except%20for%20few%20good%20C%20programmers%2C%20others%20generally%20tend%20to%20ignore%20variable%20initialization%20or%20I%20should%20rather%20say%20%E2%80%9Cproper%20variable%20initialization%E2%80%9D.%20Generally%20seen%2C%20the%20variable%20declaration%20itself%20is%20not%20done%20with%20a%20good%20thinking.%20Improper%20local%20v" title="del.icio.us"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2009%2F01%2F13%2Fimproper-variable-initialization.html&amp;t=Improper%20Variable%20Initialization" title="Facebook"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2009%2F01%2F13%2Fimproper-variable-initialization.html&amp;title=Improper%20Variable%20Initialization" title="StumbleUpon"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2009%2F01%2F13%2Fimproper-variable-initialization.html&amp;title=Improper%20Variable%20Initialization" title="Reddit"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2009%2F01%2F13%2Fimproper-variable-initialization.html&amp;partner=sociable" title="Print this article!"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.safercode.com/blog/tag/buffer-overflow" title="buffer overflow" rel="tag nofollow">buffer overflow</a>, <a href="http://www.safercode.com/blog/tag/c" title="C" rel="tag nofollow">C</a>, <a href="http://www.safercode.com/blog/tag/efficiency" title="Efficiency" rel="tag nofollow">Efficiency</a>, <a href="http://www.safercode.com/blog/tag/initialization" title="initialization" rel="tag nofollow">initialization</a>, <a href="http://www.safercode.com/blog/tag/languages" title="Languages" rel="tag nofollow">Languages</a>, <a href="http://www.safercode.com/blog/tag/security" title="Security" rel="tag nofollow">Security</a>, <a href="http://www.safercode.com/blog/tag/variable-declaration" title="variable declaration" rel="tag nofollow">variable declaration</a>, <a href="http://www.safercode.com/blog/tag/variables" title="variables" rel="tag nofollow">variables</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.safercode.com/blog/2008/10/14/and-so-it-begins.html" title="And So It Begins&#8230; (October 14, 2008)">And So It Begins&#8230;</a> (0)</li>
	<li><a href="http://www.safercode.com/blog/2009/06/10/de-bugging-code-before-check-in.html" title="&#8220;De-Bugging&#8221; Code before Check-in (June 10, 2009)">&#8220;De-Bugging&#8221; Code before Check-in</a> (0)</li>
	<li><a href="http://www.safercode.com/blog/2008/10/21/validating-untrusted-integer-inputs.html" title="Validating Untrusted Integer Inputs (October 21, 2008)">Validating Untrusted Integer Inputs</a> (6)</li>
	<li><a href="http://www.safercode.com/blog/2009/02/10/predicting-the-rand-and-using-cryptographic-random-numbers.html" title="Predicting the rand() and using Cryptographic Random Numbers (February 10, 2009)">Predicting the rand() and using Cryptographic Random Numbers</a> (7)</li>
	<li><a href="http://www.safercode.com/blog/2008/11/11/validating-untrusted-string-inputs.html" title="Validating Untrusted String Inputs (November 11, 2008)">Validating Untrusted String Inputs</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.safercode.com/blog/2009/01/13/improper-variable-initialization.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Enum Pattern in Java &lt; 1.5</title>
		<link>http://www.safercode.com/blog/2008/12/16/using-enum-pattern-in-java-15.html</link>
		<comments>http://www.safercode.com/blog/2008/12/16/using-enum-pattern-in-java-15.html#comments</comments>
		<pubDate>Tue, 16 Dec 2008 15:56:03 +0000</pubDate>
		<dc:creator>Amit Goel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[bytecode]]></category>
		<category><![CDATA[Concepts]]></category>
		<category><![CDATA[Efficiency]]></category>
		<category><![CDATA[efficient code]]></category>
		<category><![CDATA[input validation]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[reverse engineering]]></category>
		<category><![CDATA[Safety]]></category>
		<category><![CDATA[untrusted inputs]]></category>

		<guid isPermaLink="false">http://www.safercode.com/blog/?p=27</guid>
		<description><![CDATA[<!-- Powered by Shantz WP Prefix Suffix. Tech Blog: http://tech.shantanugoel.com/ Secure Programming Blog: http://www.safercode.com/blog/ Blog: http://blog.shantanugoel.com/ -->Alright!!! Let&#8217;s get started. This is one of many subjects which always overwhelms me. Why so? Ofcourse, the reasons can not be explained here but then, the reason should be the least of your worries.
Okay, if you know enough about this, then please post your knowledge tips as comments because your comments might help towards [...]]]></description>
			<content:encoded><![CDATA[<!-- Powered by Shantz WP Prefix Suffix. Tech Blog: http://tech.shantanugoel.com/ Secure Programming Blog: http://www.safercode.com/blog/ Blog: http://blog.shantanugoel.com/ --><p style='border:thin dotted black; padding:3mm;background-color: rgb(250,150,250);'><strong><a href="http://feedproxy.google.com/SaferCode" rel="alternate" type="application/rss+xml">Subscribe To Our Feed</a> | <a href="http://twitter.com/safercode" rel="nofollow">Follow Us On Twitter</a> | <a href="http://feedburner.google.com/fb/a/mailverify?uri=safercode" rel="nofollow" target="_blank">Get Updates on Email</a></strong></p>
<p>Alright!!! Let&#8217;s get started. This is one of many subjects which always overwhelms me. Why so? Ofcourse, the reasons can not be explained here but then, the reason should be the least of your worries.</p>
<p>Okay, if you know enough about this, then please post your knowledge tips as comments because your comments might help towards my unexplained reasons.</p>
<p>You may find similar information on other websites but then, it&#8217;s a wild world and I am not intending to infringe any copyrights.</p>
<p>Now to begin with, let&#8217;s first understand how to evaluate the performance of java code and protect the java code from tainted objects. We&#8217;ve already talked about Tainted Object Propagation in my previous post in context with databases. now, it is in context with application code.</p>
<p>I&#8217;ll explain this with an example of enum pattern.</p>
<p>We can have enums in Java in two ways. <span id="more-27"></span><br />
1) Either we have &#8220;public static final&#8221; constants declared.</p>
<div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UsingConstants <span style="color: #009900;">&#123;</span>  
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> CONST_1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1234</span> <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> CONST_2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> CONST_3 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> value <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> UsingConstants<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> param<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       value <span style="color: #339933;">=</span> param <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p>2) Implement the enum pattern.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UsingEnumPattern <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> UsingEnumPattern CONST_1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UsingEnumPattern<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1234</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> UsingEnumPattern CONST_2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UsingEnumPattern<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> UsingEnumPattern CONST_3 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UsingEnumPattern<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> value <span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> UsingEnumPattern<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> param<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       value <span style="color: #339933;">=</span> param <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> getValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">return</span> value<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To evaluate the performance and understand the details of these two different implementations, have a look at the user code given below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserCode <span style="color: #009900;">&#123;</span>  
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initializeSomethingUsingConstants<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> param<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> param<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initializeSomethingUsingEnumPattern<span style="color: #009900;">&#40;</span>UsingEnumPattern param<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        UsingEnumPattern i <span style="color: #339933;">=</span> UsingEnumPattern.<span style="color: #006633;">CONST_1</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> UsingEnumPattern.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> callMethods<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  
        initializeSomethingUsingConstants<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1111</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// I can pass any integer here</span>
        initializeSomethingUsingEnumPattern<span style="color: #009900;">&#40;</span>UsingEnumPattern.<span style="color: #006633;">CONST_1</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// only defined enums can be passed.</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, We&#8217;ll deduce the following two things from this example:</p>
<p>a) The first example, UsingConstants, has defnitely got faster execution time as it has got only few bytecode instructions to execute.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #cc66cc;">0</span><span style="color: #339933;">:</span>   aload_0
    <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span>   invokespecial   #<span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Method java/lang/Object.&quot;&amp;lt;init&amp;gt;&quot;:()V</span>
    <span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span>   aload_0
    <span style="color: #cc66cc;">5</span><span style="color: #339933;">:</span>   iload_1
    <span style="color: #cc66cc;">6</span><span style="color: #339933;">:</span>   putfield        #<span style="color: #cc66cc;">19</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Field value:I</span>
       <span style="color: #cc66cc;">9</span><span style="color: #339933;">:</span>   <span style="color: #000000; font-weight: bold;">return</span></pre></div></div>

<p>   where as the second example, UsingEnumPattern has about 16 instructions to execute. 16 to create statics and 6 for initialization.</p>
<div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
      <span style="color: #cc66cc;">0</span><span style="color: #339933;">:</span>   <span style="color: #000000; font-weight: bold;">new</span>     #<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//class com/nds/epg/network/IPConfigErrorCodeA</span>
      <span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span>   dup
      <span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span>   sipush  <span style="color: #cc66cc;">1234</span>
      <span style="color: #cc66cc;">7</span><span style="color: #339933;">:</span>   invokespecial   #<span style="color: #cc66cc;">14</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Method &quot;&amp;lt;init&amp;gt;&quot;:(I)V</span>
      <span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span>  putstatic       #<span style="color: #cc66cc;">18</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Field CONST_1:LUsingEnumPattern;</span>
      <span style="color: #cc66cc;">13</span><span style="color: #339933;">:</span>  <span style="color: #000000; font-weight: bold;">new</span>     #<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//class UsingEnumPattern</span>
      <span style="color: #cc66cc;">16</span><span style="color: #339933;">:</span>  dup
      <span style="color: #cc66cc;">17</span><span style="color: #339933;">:</span>  iconst_1
      <span style="color: #cc66cc;">18</span><span style="color: #339933;">:</span>  invokespecial   #<span style="color: #cc66cc;">14</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Method &quot;&amp;lt;init&amp;gt;&quot;:(I)V</span>
      <span style="color: #cc66cc;">21</span><span style="color: #339933;">:</span>  putstatic       #<span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Field CONST_2:LUsingEnumPattern;</span>
      <span style="color: #cc66cc;">24</span><span style="color: #339933;">:</span>  <span style="color: #000000; font-weight: bold;">new</span>     #<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//class UsingEnumPattern</span>
      <span style="color: #cc66cc;">27</span><span style="color: #339933;">:</span>  dup
      <span style="color: #cc66cc;">28</span><span style="color: #339933;">:</span>  iconst_1
      <span style="color: #cc66cc;">29</span><span style="color: #339933;">:</span>  invokespecial   #<span style="color: #cc66cc;">14</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Method &quot;&amp;lt;init&amp;gt;&quot;:(I)V</span>
      <span style="color: #cc66cc;">32</span><span style="color: #339933;">:</span>  putstatic       #<span style="color: #cc66cc;">22</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Field CONST_3:LUsingEnumPattern;</span>
      <span style="color: #cc66cc;">35</span><span style="color: #339933;">:</span>  <span style="color: #000000; font-weight: bold;">return</span>
&nbsp;
      <span style="color: #cc66cc;">0</span><span style="color: #339933;">:</span>   aload_0
      <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span>   invokespecial   #<span style="color: #cc66cc;">26</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Method java/lang/Object.&quot;&amp;lt;init&amp;gt;&quot;:()V</span>
      <span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span>   aload_0
      <span style="color: #cc66cc;">5</span><span style="color: #339933;">:</span>   iload_1
      <span style="color: #cc66cc;">6</span><span style="color: #339933;">:</span>   putfield        #<span style="color: #cc66cc;">28</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Field value:I</span>
      <span style="color: #cc66cc;">9</span><span style="color: #339933;">:</span>   <span style="color: #000000; font-weight: bold;">return</span></pre></div></div>

</div>
<p>and as per user code, constant evaluation will bve faster as it will using the &#8217;sipush&#8217; instruction as compared to &#8216;getstatic&#8217; instruction in case of enum pattern.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">/*
   public void initializeSomethingUsingConstants();
      0:   sipush  1234
      3:   istore_1
      4:   return
&nbsp;
   public void initializeSomethingUsingEnumPattern();
      0:   getstatic       #18; //Field UsingEnumPattern.CONST_1:LUsingEnumPattern;
      3:   astore_1
      4:   return
*/</span></pre></div></div>

<p>So, to summarize, if you are very much worried just about performance then definitely, using constants makes it a perfect sense.</p>
<p>b) Now, lets look at the problem of using constants. get a bit paranoid and think that people are just waiting to break your code. it is easily possible as while using constants, any integer value can be passed to the user method instead of the constant values, which is enough to break your code. Now, to protect this, you&#8217;ll have to write conditions for every possible value the program expects and handles the correct error conditions for every incorrect value. Now, won&#8217;t this increase your code size resulting in a lot of execution overhead.</p>
<p>Whereas, if you use second example, incorrect values cannot be passed at all and your code will be safe from attackers. and you need not write any extra guard conditions resulting in keeping your code size to minimum.</p>
<p>Alright!! By now, most of you would be thinking that how this post relate to bytecode reverse engineering but then, I just needed a starting point to explain a problem before getting into injecting malicious content in your bytecode to break what you consider secure.</p>
<p>In my next post, i&#8217;ll evaluate these bytecodes more and then, later on, we&#8217;ll talk about contaminating bytecodes to make the code malfunction. All my posts will consider the aspect of code performance vs. code safety amd I am not sure whether these thoughts of mine will make any sense but I do need a place to vent out. <img src='http://www.safercode.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p style='border:thin dotted black; padding:3mm;background-color: rgb(250,150,250);'>© <a href="http://www.safercode.com/blog/">Safer Code</a> | <a href="http://www.safercode.com/blog/2008/12/16/using-enum-pattern-in-java-15.html">Using Enum Pattern in Java < 1.5</a></p>



Share and Enjoy:


	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F16%2Fusing-enum-pattern-in-java-15.html&amp;title=Using%20Enum%20Pattern%20in%20Java%20%3C%201.5&amp;bodytext=Alright%21%21%21%20Let%27s%20get%20started.%20This%20is%20one%20of%20many%20subjects%20which%20always%20overwhelms%20me.%20Why%20so%3F%20Ofcourse%2C%20the%20reasons%20can%20not%20be%20explained%20here%20but%20then%2C%20the%20reason%20should%20be%20the%20least%20of%20your%20worries.%0D%0A%0D%0AOkay%2C%20if%20you%20know%20enough%20about%20this%2C%20then%20plea" title="Digg"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F16%2Fusing-enum-pattern-in-java-15.html&amp;title=Using%20Enum%20Pattern%20in%20Java%20%3C%201.5&amp;notes=Alright%21%21%21%20Let%27s%20get%20started.%20This%20is%20one%20of%20many%20subjects%20which%20always%20overwhelms%20me.%20Why%20so%3F%20Ofcourse%2C%20the%20reasons%20can%20not%20be%20explained%20here%20but%20then%2C%20the%20reason%20should%20be%20the%20least%20of%20your%20worries.%0D%0A%0D%0AOkay%2C%20if%20you%20know%20enough%20about%20this%2C%20then%20plea" title="del.icio.us"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F16%2Fusing-enum-pattern-in-java-15.html&amp;t=Using%20Enum%20Pattern%20in%20Java%20%3C%201.5" title="Facebook"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F16%2Fusing-enum-pattern-in-java-15.html&amp;title=Using%20Enum%20Pattern%20in%20Java%20%3C%201.5" title="StumbleUpon"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F16%2Fusing-enum-pattern-in-java-15.html&amp;title=Using%20Enum%20Pattern%20in%20Java%20%3C%201.5" title="Reddit"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F16%2Fusing-enum-pattern-in-java-15.html&amp;partner=sociable" title="Print this article!"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.safercode.com/blog/tag/bytecode" title="bytecode" rel="tag nofollow">bytecode</a>, <a href="http://www.safercode.com/blog/tag/concepts" title="Concepts" rel="tag nofollow">Concepts</a>, <a href="http://www.safercode.com/blog/tag/efficiency" title="Efficiency" rel="tag nofollow">Efficiency</a>, <a href="http://www.safercode.com/blog/tag/efficient-code" title="efficient code" rel="tag nofollow">efficient code</a>, <a href="http://www.safercode.com/blog/tag/input-validation" title="input validation" rel="tag nofollow">input validation</a>, <a href="http://www.safercode.com/blog/tag/java" title="Java" rel="tag nofollow">Java</a>, <a href="http://www.safercode.com/blog/tag/pattern" title="pattern" rel="tag nofollow">pattern</a>, <a href="http://www.safercode.com/blog/tag/reverse-engineering" title="reverse engineering" rel="tag nofollow">reverse engineering</a>, <a href="http://www.safercode.com/blog/tag/safety" title="Safety" rel="tag nofollow">Safety</a>, <a href="http://www.safercode.com/blog/tag/security" title="Security" rel="tag nofollow">Security</a>, <a href="http://www.safercode.com/blog/tag/untrusted-inputs" title="untrusted inputs" rel="tag nofollow">untrusted inputs</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.safercode.com/blog/2008/10/14/and-so-it-begins.html" title="And So It Begins&#8230; (October 14, 2008)">And So It Begins&#8230;</a> (0)</li>
	<li><a href="http://www.safercode.com/blog/2008/11/18/all-input-is-evil.html" title="All Input is Evil (November 18, 2008)">All Input is Evil</a> (3)</li>
	<li><a href="http://www.safercode.com/blog/2008/10/21/validating-untrusted-integer-inputs.html" title="Validating Untrusted Integer Inputs (October 21, 2008)">Validating Untrusted Integer Inputs</a> (6)</li>
	<li><a href="http://www.safercode.com/blog/2009/02/10/predicting-the-rand-and-using-cryptographic-random-numbers.html" title="Predicting the rand() and using Cryptographic Random Numbers (February 10, 2009)">Predicting the rand() and using Cryptographic Random Numbers</a> (7)</li>
	<li><a href="http://www.safercode.com/blog/2008/12/08/tainted-object-propagation.html" title="Tainted Object Propagation (December 8, 2008)">Tainted Object Propagation</a> (5)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.safercode.com/blog/2008/12/16/using-enum-pattern-in-java-15.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tainted Object Propagation</title>
		<link>http://www.safercode.com/blog/2008/12/08/tainted-object-propagation.html</link>
		<comments>http://www.safercode.com/blog/2008/12/08/tainted-object-propagation.html#comments</comments>
		<pubDate>Mon, 08 Dec 2008 16:24:59 +0000</pubDate>
		<dc:creator>Amit Goel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[database input]]></category>
		<category><![CDATA[Queries]]></category>
		<category><![CDATA[SQL Injection]]></category>
		<category><![CDATA[Taint]]></category>
		<category><![CDATA[Tainted Object]]></category>

		<guid isPermaLink="false">http://www.safercode.com/blog/?p=26</guid>
		<description><![CDATA[<!-- Powered by Shantz WP Prefix Suffix. Tech Blog: http://tech.shantanugoel.com/ Secure Programming Blog: http://www.safercode.com/blog/ Blog: http://blog.shantanugoel.com/ -->Basically, Tainted Object Propagation is the term defined for using incorrect or invalid inputs to get more than required information from the system and in some cases, taking control of the system. Although this technique is much widely used to misuse web applications and database oriented applications, but this holds true for any API publisher [...]]]></description>
			<content:encoded><![CDATA[<!-- Powered by Shantz WP Prefix Suffix. Tech Blog: http://tech.shantanugoel.com/ Secure Programming Blog: http://www.safercode.com/blog/ Blog: http://blog.shantanugoel.com/ --><p style='border:thin dotted black; padding:3mm;background-color: rgb(250,150,250);'><strong><a href="http://feedproxy.google.com/SaferCode" rel="alternate" type="application/rss+xml">Subscribe To Our Feed</a> | <a href="http://twitter.com/safercode" rel="nofollow">Follow Us On Twitter</a> | <a href="http://feedburner.google.com/fb/a/mailverify?uri=safercode" rel="nofollow" target="_blank">Get Updates on Email</a></strong></p>
<p>Basically, <b><u>Tainted Object Propagation</u></b> is the term defined for using incorrect or invalid inputs to get more than required information from the system and in some cases, taking control of the system. Although this technique is much widely used to misuse web applications and database oriented applications, but this holds true for any API publisher who exposes his API&#8217;s to third party application writers.</p>
<p>Again, just like previous post, Let&#8217;s start with an example. </p>
<p>Consider that a web page or an application takes an input &#8220;userName&#8221; and the application executes the following query to find that particular user.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">HttpServletRequest request <span style="color: #339933;">=</span> ...<span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> userName <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Connection</span> con <span style="color: #339933;">=</span> ...
<span style="color: #003399;">String</span> query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM Users &quot;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; WHERE name = ’&quot;</span> <span style="color: #339933;">+</span> userName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;’&quot;</span><span style="color: #339933;">;</span>
con.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, this is the usual code written by programmers to get the particular from the database. Now, if an attacker gets the control of the userName field, he can set it to <b><i> &#8216;OR 1=1; </i></b> This query allows the user to circumvent user name check and returns all the users from the database. In this case, the input variable &#8220;userName&#8221; is considered as <b><u>Tainted Object</u></b>.</p>
<p><span id="more-26"></span><br />
Lets take another example,</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;total_price&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25.00&quot;</span><span style="color: #339933;">&gt;</span></pre></div></div>

<p>A web form contains hidden fields to pass some information to the server which is not visible to the user. Now, HTTP pages are stateless. Unlike regular fields, hidden fields cannot be modified directly by typing values into an HTML form. However, since the hidden field is part of the page source, saving the HTML page, editing the hidden field value, and reloading the page will cause the Web application to receive the newly updated value of the hidden field.</p>
<p>Following is the classification of various attacks:</p>
<li>Inject malicious data intoWeb applications. Common methods used include:
<ul><b>Parameter tampering:</b> pass specially crafted malicious values in fields of HTML forms.</ul>
<ul><b>URL manipulation:</b> use specially crafted parameters to be submitted to the Web application as part of the URL.</ul>
<ul><b>Hidden field manipulation:</b> set hidden fields of HTML forms in Web pages to malicious values.</ul>
<ul><b>HTTP header tampering:</b> manipulate parts of HTTP requests sent to the application.</ul>
<ul><b>Cookie poisoning:</b> place malicious data in cookies, small files sent to Web-based applications.  </ul>
</li>
<li>Manipulate applications using malicious data. Common methods used include:
<ul><b>SQL injection:</b> pass input containing SQL commands to a database server for execution.</ul>
<ul><b>Cross-site scripting:</b> exploit applications that output unchecked input verbatim to trick the user into executing malicious scripts.</ul>
<ul><b>HTTP response splitting:</b> exploit applications that output input verbatim to perform Web page defacements or Web cache poisoning attacks.</ul>
<ul><b>Path traversal:</b> exploit unchecked user input to control which files are accessed on the server.</ul>
<ul><b>Command injection:</b> exploit user input to execute shell commands.</ul>
</li>
<p>Now, I&#8217;ll describe how to <b>&#8220;UnTaint&#8221;</b> your objects.</p>
<p>In order to track tainted inputs, we must specify following three things:</p>
<li>
<b>Source:</b> This is the originator of the tainted object. For example: the input fields or variables.</li>
<li><b>Derivatives:</b> Derivatives are the strings formed using &#8220;Source&#8221; strings to execute some instructions or perform some actions in the code. Derivative strings should also be marked as tainted.</li>
<li><b>Sinks:</b> A sink is a method that consumes input or derivative of user input. This includes methods that execute some form of code (such as a script or SQL query), or methods that output data (such presenting a new HTML page). Tainted strings must be prevented from being used as parameters to sinks.</li>
</li>
<p>To track the taintedness of strings, we associated a taint flag with every string. This taint flag is set when a string is returned by a source method. We propagate this taint flag to strings that are derived from tainted strings through operations such as concatenation, case conversion etc.</p>
<p>To &#8220;Untaint&#8221;, we need to have mechanism in place which will subject every input for taint verification and then, untaint it. For example: a tainted string that is passed through a regular expression match, or been tested for the presence of a particular character is not tainted anymore. Note that, here we need to trust the programmer to have performed a meaningful check that accounts for all cases that might be exploitable in an attack. It is entirely possible that the programmer wrote a faulty input validation routine that lets through user-input strings with malicious content in them. <img src='http://www.safercode.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If we find any tainted object using these algorithms, then two things can be done. Either <i>raise a TaintException</i> or <i>Abandon that particular taint session</i>. The weakest option is to let tainted data be used as an argument to a sink, but make a full log of the arguments, the sink, and the path the tainted data took from source to sink. This seems insecure, but is useful when auditing, doing penetration testing, debugging, or if used in a honeypot.</p>
<p>The best way to find most of the taint problems and the code vulnerablity is use of static analyzer tools. These tools identify the possibility of any input field being maliciously utilized and raise a warning to fix that error. The algorithms by which most of these static analyzer tools work use the above mentioned methodology. Some of the java static analyzer tools work on the bytecode level to prevent bytecode contamination also. </p>
<p>But even after this, you may find some taint issues coming your way. In this case, no one can defeat the strictest of code reviews. More strict the code review and reviewer, less the code is prone to attackers. </p>
<p>There is a lot of information available on the net about Taint object problem. I have used the resources available on the net itself to make myself aware of the gory details and if you are interested, search details on the net <img src='http://www.safercode.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . By going through the details, even you should be able to build you own static analyzer tool. </p>
<p style='border:thin dotted black; padding:3mm;background-color: rgb(250,150,250);'>© <a href="http://www.safercode.com/blog/">Safer Code</a> | <a href="http://www.safercode.com/blog/2008/12/08/tainted-object-propagation.html">Tainted Object Propagation</a></p>



Share and Enjoy:


	<a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F08%2Ftainted-object-propagation.html&amp;title=Tainted%20Object%20Propagation&amp;bodytext=Basically%2C%20Tainted%20Object%20Propagation%20is%20the%20term%20defined%20for%20using%20incorrect%20or%20invalid%20inputs%20to%20get%20more%20than%20required%20information%20from%20the%20system%20and%20in%20some%20cases%2C%20taking%20control%20of%20the%20system.%20Although%20this%20technique%20is%20much%20widely%20used%20to%20misu" title="Digg"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F08%2Ftainted-object-propagation.html&amp;title=Tainted%20Object%20Propagation&amp;notes=Basically%2C%20Tainted%20Object%20Propagation%20is%20the%20term%20defined%20for%20using%20incorrect%20or%20invalid%20inputs%20to%20get%20more%20than%20required%20information%20from%20the%20system%20and%20in%20some%20cases%2C%20taking%20control%20of%20the%20system.%20Although%20this%20technique%20is%20much%20widely%20used%20to%20misu" title="del.icio.us"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F08%2Ftainted-object-propagation.html&amp;t=Tainted%20Object%20Propagation" title="Facebook"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F08%2Ftainted-object-propagation.html&amp;title=Tainted%20Object%20Propagation" title="StumbleUpon"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F08%2Ftainted-object-propagation.html&amp;title=Tainted%20Object%20Propagation" title="Reddit"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow" target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.safercode.com%2Fblog%2F2008%2F12%2F08%2Ftainted-object-propagation.html&amp;partner=sociable" title="Print this article!"><img src="http://www.safercode.com/blog/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.safercode.com/blog/tag/database" title="Database" rel="tag nofollow">Database</a>, <a href="http://www.safercode.com/blog/tag/database-input" title="database input" rel="tag nofollow">database input</a>, <a href="http://www.safercode.com/blog/tag/java" title="Java" rel="tag nofollow">Java</a>, <a href="http://www.safercode.com/blog/tag/queries" title="Queries" rel="tag nofollow">Queries</a>, <a href="http://www.safercode.com/blog/tag/security" title="Security" rel="tag nofollow">Security</a>, <a href="http://www.safercode.com/blog/tag/sql-injection" title="SQL Injection" rel="tag nofollow">SQL Injection</a>, <a href="http://www.safercode.com/blog/tag/taint" title="Taint" rel="tag nofollow">Taint</a>, <a href="http://www.safercode.com/blog/tag/tainted-object" title="Tainted Object" rel="tag nofollow">Tainted Object</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.safercode.com/blog/2008/12/16/using-enum-pattern-in-java-15.html" title="Using Enum Pattern in Java < 1.5 (December 16, 2008)">Using Enum Pattern in Java < 1.5</a> (1)</li>
	<li><a href="http://www.safercode.com/blog/2008/10/14/and-so-it-begins.html" title="And So It Begins&#8230; (October 14, 2008)">And So It Begins&#8230;</a> (0)</li>
	<li><a href="http://www.safercode.com/blog/2008/10/21/validating-untrusted-integer-inputs.html" title="Validating Untrusted Integer Inputs (October 21, 2008)">Validating Untrusted Integer Inputs</a> (6)</li>
	<li><a href="http://www.safercode.com/blog/2009/02/10/predicting-the-rand-and-using-cryptographic-random-numbers.html" title="Predicting the rand() and using Cryptographic Random Numbers (February 10, 2009)">Predicting the rand() and using Cryptographic Random Numbers</a> (7)</li>
	<li><a href="http://www.safercode.com/blog/2008/10/14/int-main-vs-void-main.html" title="int main() vs void main() (October 14, 2008)">int main() vs void main()</a> (22)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.safercode.com/blog/2008/12/08/tainted-object-propagation.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
