Tuesday, 24 March 2009

More on Annotations...

In addition to their other capabilities, Fortify Java Annotations can be used to identify new vulnerabilities in code. For example, the following code writes sensitive user information to a log file, but Fortify SCA cannot report a warning out-of-the-box because it has no knowledge of the sensitivity of the data in question.

 

String query = "Select credentialA, keyB, elementC from userTable where userid = ?"; PreparedStatement pstmt = connection.prepareStatement(query); pstmt.setInt(1, userid); ResultSet results = pstmt.executeQuery();  // extract data from the ResultSet while (results.next()) {   String credentialA = results.getString(1);   int keyB =  results.getInt(2);   Blob elementC = results.getBlob(3); 	   String stringBlobRepresenation = new String(elementC.getBytes(1, (int) elementC.length()));   logger.info("Retrieved info for user " + userid + ": " + stringBlobRepresenation); } 

This code snippet queries the application’s database using Java Prepared statements to retrieve information about the user userid. The userTable table contains a sensitive column elementC that must never be handled in an insecure way. As part of the debugging effort, a developer has insecurely logged elementC to disk, thus compromising the sensitive information it contains.

By adding the @FortifyPrivate annotation to the code above, a developer can tell Fortify that elementC is sensitive and allow Fortify SCA to identify dangerous uses of this variable.

String query = "Select credentialA, keyB, elementC from userTable where userid = ?"; PreparedStatement pstmt = connection.prepareStatement(query); pstmt.setInt(1, userid); ResultSet results = pstmt.executeQuery();  // extract data from the ResultSet while (results.next()) {   String credentialA = results.getString(1);   int keyB =  results.getInt(2);   @FortifyPrivate Blob elementC = results.getBlob(3); 	   String stringBlobRepresenation = new String(elementC.getBytes(1, (int) elementC.length()));   logger.info("Retrieved info for user " + userid + ": " + stringBlobRepresenation); } 

Fortify SCA now reports the privacy violation that occurs when elementC is logged.

As we mentioned in a previous post, Fortify 360 2.0 and the Q1-2009 update to the Fortify Secure Coding Rulepacks now recognize the following Fortify Java Annotations:

  • Dataflow: Source, Sink, Passthrough, and Validation
  • Field and Variable: Password, NotPassword, Private, NotPrivate, NonNegative, NonZero
  • Other: Dangerous Class, Method, Field, and Variable and CheckReturnValue

A detailed sample that demonstrates the full capabilities of Fortify Java Annotations is available with supported versions of Fortify 360 and through the Premium Content section of the Customer Portal.

Technorati Tags:

Posted by jcarter at 11:55 AM in Fortify

Saturday, 21 March 2009

Look Who's Reading

Who's reading this blog? The author(s) of Conficker, apparently. Here's the story.

 

Conficker's creators have a Ron Rivest fetish. Conflicker uses RC4, RSA, and MD-6 (details here) all of which are the work of Professor Ron Rivest. Last month we blogged about bugs in SHA-3 reference implementations (MD-6 included). This month Conficker C incorporated the MD-6 fix that Ron's group submitted to NIST.

 

Anyway, hello Conficker crew. F*** you very much for your attention.

Technorati Tags:

Posted by bchess at 1:02 PM in Random

Thursday, 12 March 2009

A Few Words about Crypto

Recently, there has been a lot of talk and speculation regarding various cryptographic algorithms that are still widely used. Some security experts suggest banning a number of them; while others argue that some of these algorithms are still secure enough to be used for the time being. No wonder developers remain confused about the choice of which crypto to use in their code.

In order to clarify things, the Fortify Security Research Group (SRG) performed a thorough investigation of the subject. As a result, we came up with a set of guidelines that will be published later this week in the form of a Crypto Manifesto and is available immediately to Fortify customers through the Premium Content area of the Customer Portal. These guidelines cover four of the most critical topics: hash functions, encryption and encoding functions, encryption keys, and pseudo-random number generators (PRNGs). All of the guidelines will be enforced through the most recent version of the Fortify Secure Coding Rulepacks, which were released on February 27th, 2009.

The table below summarizes our guidelines on the usage of crypto in security sensitive contexts:

Avoid Use
Cryptographic Hashes MD2, MD4, MD5, SHA-1 RIPEMD-160, SHA-224, SHA-256, SHA-384, SHA-512
Encryption and Encoding RC2, RC4, DES 3DES, AES
Symmetric Keys (AES) < 128 bits >= 128 bits
Public Keys (RSA) < 1024 bits >= 2048 bits with OAEP padding
Pseudo-Random Number Generators (PRNGs) Statistical PRNGs Cryptographic PRNGs

When it comes to computing hashes on security sensitive data such as passwords, certificates, or any other kinds of digital security credentials where collision and pre-image resistance are important, MD2, MD4, MD5, and SHA-1 are no longer recommended. Collisions have been found in MD2 as early as 1997, while attacks on MD4, MD5, and SHA-1 were demonstrated in 2005. Furthermore, a much more recent research project showed at the end of December 2008 that it is possible to mount a man-in-the-middle attack on Secure Sockets Layer (SSL) via creating rogue certificates issued by rogue Certification Authorities (CAs), only with the help of a homegrown array of machines. Combine this work with Dan Kaminsky's Domain Name System (DNS) problems, and you got yourselves virtually undetectable phishing attacks on the internet.

Similarly to hashing algorithms, a number of encryption algorithms have recently been broken: RC2, RC4, and DES. Worse yet, base64 encoding is mistakenly thought of by many as an encryption scheme. It is important to point out that base64 encoding is useful when there is a need to transmit binary data over a communication channel that is designed to transmit character data. However considering that its character space is only of size 64, the scheme does not provide the same security guarantees as strong cryptographic encryption algorithms, and therefore should not be used for protecting secrets.

In addition to choosing the right encryption algorithm to protect sensitive data, it is important to generate appropriate keys to use with these schemes. Considering that hardware has been getting faster and faster in recent years, choosing appropriate encryption key lengths is becoming increasingly important as the rate at which attackers can make guesses grows. The National Institute of Standards and Technology (NIST) suggests using symmetric keys (particularly, AES keys) of no less than 128 bits in length and RSA keys of no less than 1024 bits, moving towards using 2048-bit keys by 2013. In the case of RSA keys, it is also important to choose the right padding scheme, which can prevent a number of attacks that potentially work against RSA without padding. Public-Key Cryptography Standard (PKCS) #1 v.2.1 recommends the use of Optimal Asymmetric Encryption Padding (OAEP) for new applications.

As for the pseudo-random number generators, when unpredictability is critical, which is the case in security-sensitive contexts, it is important to use strong cryptographic rather than statistical PRNGs. Unlike cryptographic PRNGs, statistical PRNGs produce highly predictable output, which makes it trivial for an attacker to guess the values they generate. However, statistical PRNGs are acceptable when predictability is not a concern - for example, for generating a random order in which images are displayed in a slideshow.

Technorati Tags:

Posted by yoneil at 3:28 PM in Research

Fortify Java Annotations

Fortify Java Annotations allow developers to give Fortify SCA hints about how their code works, which can prevent both false positives or false negatives. Like custom rules, annotations work by augmenting Fortify's model of the program with additional information and allow for more accurate analysis.

Consider the following code, which loads a password prompt for a login screen, logs it, and returns the loaded string to its caller.

 

private String loadPasswordLabel() {   String passwordLabel = props.getProperty("passwordLabel");    logger.info("Password label loaded: " + passwordLabel); // false positive!   return passwordLabel; } 

A rule built into the Fortify Secure Coding Rulepacks causes Fortify SCA to guess that the contents of the variable passwordLabel are sensitive because its name contains the string 'password', which causes Fortify SCA to report a false positive privacy violation issue when the variable is written to the log.

The code below demonstrates how Fortify Java Annotations can be used to eliminate this false positive:

 

private String loadPasswordLabel() {   @FortifyNotPassword String passwordLabel = props.getProperty("passwordLabel");    logger.info("Password label loaded: " + passwordLabel); // no issue reported   return passwordLabel; } 

The @FortifyNotPassword annotation informs Fortify SCA that the variable to which it is applied does not contain a password.

As of Fortify 360 2.0 and the Q1-2009 update to the Fortify Secure Coding Rulepacks, Fortify SCA recognizes the following Fortify Java Annotations:

  • Dataflow: Source, Sink, Passthrough, and Validation
  • Field and Variable: Password, NotPassword, Private, NotPrivate, NonNegative, NonZero
  • Other: Dangerous Class, Method, Field, and Variable and CheckReturnValue

A detailed sample that demonstrates the full capabilities of Fortify Java Annotations is available with supported versions of Fortify 360 and through the Premium Content section of the Customer Portal.

Technorati Tags:

Posted by jcarter at 12:06 PM in Fortify

Friday, 6 March 2009

The Security Fig Tree

Gunnar Peterson just posted an insightful response to a comment on a webcast that he and I (mostly he) did on SOA a while back. Most importantly, Gunnar reiterates the point that there's a big divide between most of the set folks with software knowledge and the set with security knowledge. Technology is great, and we're learning more and more ways to leverage it to productive ends, but arming the people responsible for building secure software with the right know-how is critical.
Posted by jwest at 4:37 PM in Research

Wednesday, 4 March 2009

BSIMM

I've spent the last few months running around with Gary McGraw and Sammy Migues talking to organizations that represent the leading edge of software security. We talked to top software vendors, financial services companies, and technology companies. It's been fascinating for many reasons, not the least of which is how similar the leader's approaches are considering how different their businesses are. The result of these interviews is a new study we announced today called the Building Security In Maturity Model (BSIMM). BSIMM has it's own Web site. Take a look.

The meat of BSIMM is a set of real-world software security activities, all of which we observed in one or more of the organizations we studied. We've organized the activities so that you can determine where you stand with your software security initiative and how you can best evolve an initiative over time. Until now, the great majority of the published work in our field has been either small-scale (shown to works for one program or one programming team), or unproven (a bunch of good ideas that might or might not work outside the group that created them.) To my knowledge, this is the first real study of the software security practices across a range of successful organizations.

So far we've seen a warm reaction from the press and analysts. See this piece in the Wall Street Journal. But the best reactions have been from the participants. People have been really excited to see the results and learn about how they compare to their peers. We hope BSIMM will improve ties among the community of people who lead asoftware security initiative in their organization. We plan to continue adding new organizations to the model, so if you're interested, please drop me a line.

Posted by bchess at 5:09 PM in Research