List of firms willing and able to fix vulnerable code for you

As anyone in Web security will confirm, there’s no shortage of vulnerabilities in custom Web applications. On the average website, WhiteHat Security identifies at least dozens, more often hundreds, of custom Web application vulnerabilities per year. Any one of these vulnerabilities may lead to total or partial system compromise, user account takeover, data loss, fraud, and so on. When such a vulnerability is found, the next task is getting it fixed. The task of vulnerability remediation has proved to be a rather large challenge for many organizations.

Often an organization will want to fix their vulnerable code, but they’re development team is oversubscribed delivering revenue generating features. Diverting their attention is just not an option. Given the choice, the organization may prefer to pay for the problem to go away. In short, to pay someone to come in and fix their vulnerable code for them.

Generally speaking, penetration-testing, vulnerability assessment, source code reviews, etc. whether speaking of tools or service providers, only FIND the vulnerability, they don’t FIX the code. They provide guidance on HOW they recommend the issue is fixed, but not the code fix itself. That’s the organizations responsibility.

Fortunately there are an increasing number of firms who are ready and willing to perform vulnerability remediation services. They’ll actually show up and fix your code! I’ve been building a list of them (see below) because people ask me about this all the time.

It is very important that this list is NOT considered an official endorsement of any kind as I only have personal experience with a few. If you need a recommendation and/or an introduction, just send me an email directly and I’d happy to help out: jeremiah -at- whitehatsec.com.

  1. Accuvant
  2. AhnLab
  3. Aspect Security
  4. AsTech Consulting
  5. Asterisk Information Security
  6. BCC Risk Advisory
  7. Cigital
  8. Denim Group
  9. Foundstone
  10. Gotham Digital Science
  11. iSEC Partners
  12. KPMG (Australia)
  13. Security Compass

Clickjacking Prevention in Java

What is it and why should I care?
Clickjacking is a type of “Web framing” or “UI redressing” attack. In practice, that means:

1. Users (victims) are shown an innocuous, but enticing Web page (watching an online video is a good example)
2. Another Web page, which usually does something important (think “adding friends onto your social network”), is layered on top of the first page and set to be transparent
3. When users click on the Web page they see (the online video), they are actually clicking on the higher layered (framed) page that is transparent

This attack is clever, and there are some interesting specifics in its actual execution (for more detailed information, see the references at the end of this post). However, here I’m concerned only with preventing the attack.

What should I do about it?

There is still no perfect answer on how to prevent clickjacking, but things are getting better − especially as users upgrade to more modern browsers. Currently, prevention is based on a two-fold recommendation:

1. Use the X-Frame-Options HTTP header
2. Include framebusting code

The HTTP header is the more robust solution, although it requires a relatively modern browser. Fortunately, more users are slowly moving towards using modern browsers, so the situation is improving just because of that fact.

As for the framebusting recommendation, even though it is breakable, it should still be done. It certainly raises the bar against a successful attack. And while there are many options for framebusting code, I recommend a paper that the folks at Stanford put together on framebusting: http://seclab.stanford.edu/websec/framebusting/. In the paper, they have evaluated the current code in the wild, and then showed ways to break it. They have also proposed their own solution in the paper. Rather than including the code here, you can find it at the top of page 11 of the Stanford group’s PDF. The basic idea of their solution is to both:
1) use the style sheet to disable display for the entire body of the page, and
2) use Javascript to either enable the display if not framed, or to bust out of the frame if framed

Eventually this solution will probably be broken (if it’s not been broken already), but it appears to be the best solution that we have today.

Unfortunately, Clickjacking is a less-than-straightforward issue to resolve, but by combining a couple of different approaches you can overcome the problem with a fair amount of robustness.

Note: The Stanford approach does not adequately support IE in all instances – here’s a post explaining the solution.

References
­­­­­­­­­––––––––––––––––––––––––––––––––––––––
https://www.owasp.org/index.php/Clickjacking
http://seclab.stanford.edu/websec/framebusting/
http://michael-coates.blogspot.com/2010/08/x-frame-option-support-in-firefox.html
https://www.codemagi.com/blog/post/194

X-Frame-Options

What is it and why should I care?
X-Frame-Options (moving towards just Frame-Options in a draft spec – dropping the X-) is a new technology that allows an application to specify whether or not specific pages of the site can be framed. This is meant to help prevent the clickjacking problem.

The technology is implemented as an HTTP response header that is specified per-page. Browsers supporting the (X-)Frame-Options header will respect the declaration of the page, and then either allow or disallow the page to be framed, depending upon the specification.

What should I do about it?
Yet again, this is a very low-risk item that provides extra assurance. There are some limitations that may prevent the header from offering protection in every instance, but X-Frame-Options does NOT make you less safe. Instead, it gives you an additional layer of protection.

A page can specify 3 different options for how it wants to be framed (samples are in Java pseudo-code form):

Option 1: DENY
This option means the page can never be framed by any page, including a page with the same origin. A sample code snippet is below:

HttpServletResponse response …;

response.addHeader(“X-FRAME-OPTIONS”, “DENY”);

Option 2: SAMEORIGIN
This option means the page can be framed, but only by another page with the same origin. A sample code snippet is below:

HttpServletResponse response …;

response.addHeader(“X-FRAME-OPTIONS”, “SAMEORIGIN”);

Option 3: Allow-From
This option means the page can be framed, but only by the specified origin. A sample code snippet is below:

HttpServletResponse response …;

response.addHeader(“X-FRAME-OPTIONS”, “Allow-From https://some.othersite.com”);

As an additional help, the good folks at OWASP have put together a simple example J2EE filter for X-Frame-Options.

(X-)Frame-Options is a good additional layer of protection to prevent clickjacking on your site. While it won’t stop everything, it costs very little, and will help protect your users.

References
­­­­­­­­­­___________________________
https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
https://www.owasp.org/index.php/Clickjacking#Defending_with_response_headers
http://blogs.msdn.com/b/ieinternals/archive/2010/03/30/combating-clickjacking-with-x-frame-options.aspx
http://blog.mozilla.com/security/2010/09/08/x-frame-options/
http://lcamtuf.blogspot.com/2011/12/x-frame-options-or-solving-wrong.html
http://www.jtmelton.com/2012/02/03/year-of-security-for-java-week-5-clickjacking-prevention/
http://tools.ietf.org/html/draft-gondrom-frame-options

Hash Length Extension Attacks

It seems that many penetration testers rarely test cryptographic vulnerabilities. I’ve always been interested in cryptography, so I’ve made it a goal to understand how web application developers misuse crypto, and how to exploit the flaws that the misuse of cryptography create.

In January, I did some independent research on how to perform hash length extension attacks against poorly implemented message authentication codes (MACs). I found several good research papers and blog posts that discussed how these attacks work in a very general sense. However, there was not much information that specifically explained the details of a length extension attack. In this post, I’ll be explaining exactly what does happen.

Message Authentication Codes 101

Message authentication codes (MACs) are a way to verify the authenticity of a message. In the more naive implementation of a MAC, the server has a secret key that it concatenates with a message, and then hashes the combination with an algorithm, such as MD5 or SHA1. For example, consider an application that is designed to give an authorized user the ability to download specific files. The site might create a MAC for the filename like this:

def create_mac(key, fileName)
   return Digest::SHA1.hexdigest(key + fileName)
end

The resulting URL might look something like:

http://example.com/download?file=report.pdf&mac=563162c9c71a17367d44c165b84b85ab59d036f9

When the user sends the request to download a file, the following function is executed:

def verify_mac(key, fileName, userMac)
    validMac = create_mac(key, filename)
    if (validMac == userMac) do
        initiateDownload()
    else
        displayError()
    end
end

With this code, the server should only call initiateDownload if the user has not tampered with the filename… or so the theory goes. In reality, this method of creating a MAC leaves the site vulnerable to an attack where attackers can append their own content to the end of the file parameter.

Length Extension Attacks, The Simple Explanation

Cryptographic hash functions, such as MD5, SHA1, SHA2, etc., are based on a construct known as Merkle–Damgård. An interesting issue arises with this type of hash function: If you have a message that is concatenated with a secret and the resulting hash of the concatenated value (the MAC) – and you know only the length of that secret – you can add your own data to the message and calculate a value that will pass the MAC check without knowing the secret itself.

Example: message + padding + extension

Continuing the example from above, an extension attack against the hypothetical file download MAC would look like this:

http://example.com/download?file=report.pdf%80%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00
%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00
%00%A8/../../../../../../../etc/passwd&mac=ee40aa8ec0cfafb7e2ec4de20943b673968857a5

Length Extensions In Depth

To understand why this attack works, you first must understand what happens inside a hash function.

How Hash Algorithms Work

Hash functions work on blocks of data. As an example, 512 bits is the block length for MD5, SHA1 and SHA256. Most messages that are hashed will have a length that is not evenly divisible by a hash function block length. Thus, the message must be padded to match a multiple of the block length. Using the file download MAC example above, the message after padding would look like this (the ‘x’s represent the secret key):

xxxxxxxxxxxreport.pdf\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xA8

In SHA1, which is the algorithm being used in this example, a hash consists of a series of five integers. When displayed, these integers are usually in hexadecimal format and concatenated together. The initial value − aka, the registers − are set to this value when the algorithm is run: 67452301, EFCDAB89, 98BADCFE, 10325476, C3D2E1F0. Then, once the message has been padded, it is broken up into 512 bit blocks. The algorithm runs through these blocks, performing a series of calculations with the blocks to update the registers. Once these calculations are completed, the contents of the registers are the resulting hash of the message.

Calculating An Extension

The first step in calculating an extension is to create a new MAC. To do this, the contents we are extending the message with must be hashed: ‘/../../../../../../../etc/passwd’ in our example. However, when performing this hash, the initial registers must be overridden with the MAC from the origional message. You can think of this as making the SHA1 function start off at the state where the server’s hash function left off.

Attacker's MAC = SHA1(extension + padding) <- but with overridden registers

For this attack to work, the extension must be in its own block when it goes into the server’s hash function. The second step is to calculate enough padding so that key + message + padding == some multiple of 512 bits. In this example, the key is 11 characters long. Therefore, the padded message would look like this:

report.pdf\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xA8

The padded and extended message is then sent to the server, with the new MAC:

http://example.com/download?file=report.pdf%80%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00
%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00
%00%00%A8/../../../../../../../etc/passwd&mac=ee40aa8ec0cfafb7e2ec4de20943b673968857a5

Here is what the server hashes when it hashes the attacker’s hacked message: secret + message + padding to the next block + extension + padding to the end of that block. The result of the server’s hash will be ee40aa8ec0cfafb7e2ec4de20943b673968857a5, which provides the same result as hashing the extension while overriding the registers with the original MAC. This occurs because the attacker’s hashing operation essentially started off at the same state the server’s hash operation is at when the server has hashed half of the attack.

How To Run The Attack

For simplicity, in this example I revealed that the key length was 11 characters. In a real-world attack, where the attacker will not know the length of the key, he will need to determine the key length.

Continuing the example, let’s say that the vulnerable website returns different errors (HTTP response codes, error messages in a response body, etc.) when a MAC validation failed versus when the validation succeeded, but the file was not found. An attacker can then calculate multiple extensions, one for each possible key length, and send each extension to the server. When the server responds with an error indicating that the file was not found, then, conversely, a length extension vulnerability has been found, and the attacker is free to calculate new extensions aimed at gaining unauthorized access to sensitive files on the server.

How To Defend Against This Attack

The solution to this vulnerability is to use an algorithm known as HMAC. Instead of just hashing the key concatenated with the message, HMAC does something like this:

MAC = hash(key + hash(key + message))

How HMAC actually works is a bit more complicated, but you get the general idea. The important part is that because it is hashed into the message twice, the key is not vulnerable to the extension attack described in this post. HMAC was first published in 1996, and has since been implemented in just about every programming language’s standard library.

Summary

Though there are still some crazy people who write their own cryptographic algorithms, most people have gradually figured out that writing their own crypto is a bad idea. However, it is essential to do more than merely use publicly vetted crypto algorithms: You’ve must use those algorithms in the right way. Unless you thoroughly understand how the algorithms you use work – and know how to use them correctly – it is always safer to rely on professionally vetted, high-level libraries that will take care of the low-level stuff for you.

Beware the HTTP Path Parameter in Java

Please forgive the title, but today’s topic is something to be wary of if you write (or use) any access control / authorization type code in Web-based J2EE apps: HTTP URL path parameters. Many people are unfamiliar with HTTP URL path parameters (and they are uncommon), but they are something you should be aware of. A simple description of url path parameters can be found here. Essentially, path parameters are the bit of a url path that immediately follows a semi-colon (a semi-colon is the most popular path parameter delimiter). So, here’s an example of 2 urls, each with an http path parameter:

http://www.mysite.com/admin/UpdateUserServlet;jsessionid=OI24B9ASD7BSSD

http://www.mysite.com/admin/UpdateUserServlet;/user/HomeServlet

We’ve all probably seen the first example, where a jsessionid gets attached to our url, many times. However, take a look at the second example. Pay very close attention to what is being presented here: The request is going to the administrative UpdateUserServlet, but with a path parameter of /user/HomeServlet. Now, what problems could this create? Well, in most cases there are actually two issues that must be dealt with.

Issue 1 – The Server Product and Version

The first issue is how your servlet container/app server product and version handle certain request APIs. That’s because different products – and even versions – apparently deal with http path parameters in different ways. (I have yet to do the work that determines which servers and versions are affected, but you should do that in your own environment, as even configuration changes can apparently cause slightly differing behavior. These variations are caused by – read “blamed on” – a lack of clarity in the servlet spec regarding path parameters.)

This first problem can be observed when using certain API calls from the HttpServletRequest object, and then seeing how those APIs handle path parameters. Two of the affected methods are getContextPath() and getServletPath(), where there are variations between whether or not these calls actually strip out any path parameters depending on server product and version. Again, this is testing that you will need to do on your own. The alternative to testing is to make assumptions, and you’ll see below what can happen when those assumptions are wrong.

Issue 2 – Your Code

Here is where the actual security problem really shows up…when we use these APIs. One of the most common uses of the Request URL related APIs is for writing access control / authorization code. Many access control frameworks or internal codebases use a url mapping concept of some kind. These concepts vary widely in how they are implemented, but a simple example might be: Anything with “/admin/” in the path requires the admin role, or anything that ends in “UpdateServlet” requires the manager role. Let’s use the “ends with” example and walk through some code.

String uri = request.getRequestURI();   //note getRequestURI will always return the full path with path parameters but not request parameters
if (uri.endsWith(“UpdateServlet”)) {
//require the manager role here
} else {
//just require standard user role
}

Although this is a very trivial piece of code, it will be similar in spirit to what is in lots of access control code in j2ee apps. In this example the developer was expecting the user to send a request that looked like:

http://www.mysite.com/app/UserUpdateServlet

when they were trying to get to the update servlet. But what happens if the user sends a request like:

http://www.mysite.com/app/UserUpdateServlet;/app/UserReadServlet

THIS IS THE PROBLEM! Now that the app code has checked the URI, and sees that it ends with ReadServlet, and not UpdateServlet, the app code requires only the standard user role, and the access control check passes. However, the app server/container sees that the ACTUAL request is going to UserUpdateServlet, and allows the user to go there. Now we have an access control bypass issue! The user has been able to circumvent your “protection.”

DOH! Ok, now what…?

Fixing the Problem

There are several ways you can address this issue, and each way varies in difficulty and correctness.
1. You can whitelist all of your allowed requests and compare them to pre-determined acceptable urls, but that could become cumbersome with a very large app.
2. You can perform some cleansing (stripping) of the url path parameters, but that can be an issue if your app server allows various path parameter delimiters.
3. You can compare from the start of the URI or path, instead of checking the end. This would likely have the same limitations as the whitelist option.
4. You should definitely check your app server/container (on every upgrade, as well) to see what its actual behavior is regarding path parameters.
5. You may be able to perform your access control check at the beginning of a request handling piece of code, like a servlet, or action. That way, you know the code that is actually being executed, so it’s the url you should be verifying. However, this method lacks centralized control over your checking process.

There are certainly more options than those methods listed here, and you know best what will work in your code, but hopefully these five options will help as a starting point.

References

As an example of applicability, there was a relatively recent important bug in the Spring Security (formerly Acegi) project that was caused by the path parameter issue discussed here. More information can be found at the following 2 urls:

http://www.springsource.com/security/cve-2010-3700

http://seclists.org/fulldisclosure/2010/Oct/437

Session Cookie Secure Flag Java

What is it and why should I care?
Session cookies (or, to Java folks, the cookie containing the JSESSIONID) are the cookies used to perform session management for Web applications. These cookies hold the reference to the session identifier for a given user, and the same identifier is maintained server-side along with any session-scoped data related to that session id. Because cookies are transmitted on every request, they are the most common mechanism used for session management in Web applications.

The secure flag is an additional flag that you can set on a cookie to instruct the browser to send this cookie ONLY when on encrypted HTTPS transmissions (i.e. NEVER send the cookie on unencrypted HTTP transmissions). This ensures that your session cookie is not visible to an attacker in, for instance, a man-in-the-middle (MITM) attack. While a secure flag is not the complete solution to secure session management, it is an important step in providing the security required.

What should I do about it?
The resolution here is quite simple. You must add the secure flag to your session cookie (and preferably to all cookies, because any requests to your site should be HTTPS, if possible).

Here’s an example of how a session cookie might look without the secure flag:

Cookie: jsessionid=AS348AF929FK219CKA9FK3B79870H;

And now, how the same session cookie would look with the secure flag:

Cookie: jsessionid=AS348AF929FK219CKA9FK3B79870H; secure;

Not much to it. Obviously, you can do this manually, but if you’re working in a Java Servlet 3.0 or newer environment, a simple configuration setting in the web.xml will take care of this for you. You should add the snippet below to your web.xml.

<session-config>
<cookie-config>
<secure>true</secure>
</cookie-config>
</session-config>

As you can see, resolving this issue is quite simple. It should be on everyone’s //TODO list.

References
———–
http://blog.mozilla.com/webappsec/2011/03/31/enabling-browser-security-in-web-applications/

http://michael-coates.blogspot.com/2011/03/enabling-browser-security-in-web.html

https://www.owasp.org/index.php/SecureFlag

Error Handling in Java web.xml

What is it and why should I care?

Error or exception handling is an important, but often ignored, part of any application. And although there’s a lot to be said on the topic I’m going to cover only a few of the most critical cases in J2EE Web applications.

Essentially, one of the biggest worries about exception handling is that you don’t actually handle the exception. Instead, your code − or the code of some 3rd party library you’re using − allows an exception to bubble up. Once the exception reaches the boundary of your application and enters the container, the specific container/application server you are using determines what semantics are applied in handling the exception. Often times, by default, a standard error page is applied and the exception stack trace is printed on the screen in all its glory. This is definitely a problem, because it gives attackers a lot of information about the system, and can lead to further attacks.

What should I do about it?
Handling this issue is fairly straightforward. The basic advice is to provide error handlers for at least java.lang.Throwable (catches any Java exceptions or errors), and provide more specific handlers for individual exceptions and http error codes (the most common being 404 and 500).

An example snippet that can be applied to the web.xml is below:

<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>

Note: error.jsp page should be generic and provide a canned response message of a type that contains no detail that could help an attacker fingerprint the app in any way.

There’s a lot more to know and do in regard to handling exceptions in your application. However, from a security perspective, catching Throwables and the specified error codes provides much of the protection you need.

References
———–

http://software-security.sans.org/blog/2010/08/11/security-misconfigurations-java-webxml-files

http://www.jtmelton.com/2010/06/02/the-owasp-top-ten-and-esapi-part-7-information-leakage-and-improper-error-handling/

5% of websites have had at least 1 SQL Injection vulnerability without needing to login

During RSA Dave Aitel, CEO of Immunity, asked me a statistics question relating to website security. Dave asked, “What percentage of websites is WhiteHat seeing as vulnerable to SQL Injection — without needing to authenticate?” That last detail is important, especially in the era of mass blast SQL Injection worms and prolific bad-guy-scanner-use searching for victims of opportunity.

I didn’t have the number off the top of my head, would have to look it up in the WhiteHat Sentinel database to be certain, but my first impression was it’s probably around 5%. I thought so was because we’re currently tracking about 14% of all websites having had at least one SQL Injection vulnerability (slide 13). Restricting to non-auth would obviously drag the number down.

To Dave’s surprise, 5% was what he is measuring as well, as was as one other he asked. I asked WhiteHat Security’s resident data scientist, Bill Coffman, to provide the real figures.To first understand our data scope, WhiteHat Sentinel is used to perform continuous vulnerability assessments on thousands of publicly facing websites. 500+ companies in all, large and small, and across industries such as financial services, retail, healthcare, energy, etc. The large majority our vulnerability assessment are conducted in a logged-in state.

Fortunately, we offer a service line named Baseline Edition (BE), which does not authenticate. BE is generally for customers who only require a “baseline” level of testing comprehensiveness, usually deployed broadly across their entire website portfolio. So, Bill restricted our data set to only a BE covered websites, which ended up encompassing many hundreds.

Of all BE websites, created under WhiteHat Sentinel before March 2011, yielded 5%. That is, 5% of websites have had at least 1 SQL Injection vulnerability without needing to login!

We restricted the sampling to a year back to ensure the websites had all their scans properly configured and had enough time to complete over a long enough period. Newer sites are not in a stable state to be statistically representative.

There is one potential caveat in the data, which we can’t properly account for that is likely to move the percentage up. Just because an assessment is conducted in a logged-in state does not mean the URL that’s vulnerable to SQL Injection can’t be exploited while NOT logged-in — an authentication / authorization issue, which should up on our statistics report top ten.

So, those are our numbers. If you are in the website vulnerability assessment business, what are yours?

 

 

Tips for NOT getting Hacked on the Web

Following my TEDxMaui presentation, a great many every day people have been emailing, Facebook’ing, and Tweet’ing me asking for tips on how to keep themselves safe online. Safe from malicious software attacks, safe from their online account getting taken over, and safe from their PC getting hacked. This post is for them.

No one wants to end up like the guy on Flickr who had five years worth of photos deleted, like the woman whose personal email box was hacked and held for ransom, like the thousands on Facebook whose accounts have been taken over and friends scammed for cash thinking they are helping you out of a jam when really some miscreant is assuming your identity. Perhaps worst of all like the people whose computers were hacked into and an intruder quietly flipped on their video camera to record their most intimate moments and proceeded to toy with their lives.

Poor economic conditions being what they are, perhaps having your online bank account liquidated by organized criminals may not be all that bad relative to these poor people — even with no guarantee you’ll get your hard earned money back. The reality is all these things and more are painfully common and go largely undetected.

Don’t be fooled for a second into thinking antivirus companies are going to save you, nor a corporation’s generic we-take-security-very-seriously-we-promise-policy, and certainly not law enforcement. These guys get hacked just like everyone else and are completely overwhelmed by billions of dollars lost every year due to online fraud already. They are very unlikely to understand, help, or even investigate your particular situation.

The undisputable fact is you, and you alone, are the best defense against getting hacked and getting taken advantage of. Keep in mind that getting hacked is not act of nature like a flood, earthquake, or tsunami. Getting hacked can be avoided. The steps to do exactly I’m going to share with you are simple, won’t cost you a dime, are sometimes a little unconventional, but they are most definitely effective. These are the same things security pros do to protect themselves. There is no reason why you can’t use them too!

 

Must-Have Software

 

1) Upgrade Microsoft Windows or Mac OS X

Outdated software is the enemy of online safety and security. Fortunately this process is easy and you should do this right now, even before reading the rest of this article.

If you use Microsoft Windows…

Fire up your Internet Explorer web browser and visit Microsoft Update. Just follow the instructions on the screen to update your system with the latest software. Next download and install Microsoft Security Essentials, which is their free antivirus software package.

If you use Mac OS X…

All you have to do is click the Apple logo in the top left of your screen, select “Software Update…”, and then follow along.

 

2) Install a modern Web browser. Better yet, pick two!

You do know what a Web browser is right? Not everyone does. A Web browser is the software you use to surf the Web and visit websites like Facebook, Gmail, and Amazon. Chrome, Firefox, and Internet Explorer are all solid and speedy Web browsers. The choice between them is largely personal preference.

If you already use one of these browsers, great, just make sure you are running the very latest version. Nothing brings a smile to a malicious hackers face like a victim with an ancient browser, such as Internet Explorer 6. It’s like a professional car thief walking up to a car without any anti-theft devices installed, gone in sixty seconds.

If you are a Windows and Internet Explorer user, and you performed step 1, you are all set. If you use Chrome, click the wrench in one of the browser windows and select “About Google Chrome.” If you need to update, the “Update Now” button will allow you to click it. For Firefox, it’s the same process as Chrome. Go to the “About Firefox” window, and if you need to update a button to press will be there.

Next, install a different browser from the recommended list, because you’ll need two for the safest browsing experience.

 

3) Install ad blocking extensions

If you’ve chosen Chrome or Firefox as one of your Web browsers, you are going to absolutely love ad blocking extensions like Adblock and Adblock Plus. These extensions allows you to surf the Web without ads, which also has a powerful benefit of increasing security and privacy automatically.

Malicious software often infects computers through viewing or clicking of online advertisements. When you actually want to see ads, don’t worry, it is really easy to turn on and off when you want.

For extra privacy, consider installing either Disconnect or Ghostery extensions. Essentially all online advertisements are “trackers,” which stalk you around the Web profiling your online habits, but not all “trackers” are advertisements. Disconnect and Ghostery block these invisible trackers and aid in protecting your online privacy.

 

Online Street Smarts

Think of the Web like an inner city. There are some really great places to visit, enjoy nice meals, and hang out with friends. However, as in any inner city with over one billion people, there will be some shady characters lurking around trying to scam and rob you. You have to keep your guard up. The problem is the digital world makes it tough to see and therefore avoid dangerous street corners. I’ll show you how.

 

4) Your weekend browser and your commuter browser

Many people drive one car every day to work and keep a nicer one in the garage ready for the weekends or a night on the town. Your two browsers should be used the same way. Choose one, your commuter browser, for every day surfing. Read news, play games, watch YouTube, whatever. Just don’t login to anything you consider really important! That is what the other browser is for.

When you bank, upload photos, check your WebMail, trade stock, or buy anything — fire up your weekend browser. This is the browser you protect by going directly to a website, typing the address into the location bar or using a bookmark, and nowhere else. Close it down when you are done.

Then if anything, or anyone, attacks your commuter browser when you are exploring the Web, it is no problem because you’ve never done anything important with it. You don’t take your weekend car down to a bad part of town right?

 

5) Be careful of what you download and paranoid of what you install

After going through all the trouble of making sure you have the latest software, and compartmentalized your risk with two browsers, don’t go and install something evil that will ruin everything. Downloads are like narcotics peddled by drug dealer. Just say no! They might make you feel good temporarily, but long term the effects are deadly.

The bad guys are extremely clever too. They actually disguise their “product” as antivirus software to help protect your computer. HAH! The also might say you need to install a special codec or something to watch the latest celebrity sex tape. Don’t fall for that. Go to YouTube, Break, or some other major video sharing site instead. Email attachments also need to be treated with paranoia, especially from people you know, because they might not have been as cautious as you.

 

6) Make your passwords hard to guess

You wouldn’t have the same key for your home, car, office, safe, etc. For the same reason you shouldn’t use the same password for all your online accounts. Pick passwords that are hard to guess, not found in the dictionary, six characters or more in length, and sprinkle in a number or special character for good measure. Something like: y77Vj6t or JX0r21b

Anything more than having two or three passwords like this gets to hard to remember, so you have a choice to make.

a) Write down your password on a piece of paper

Use a small sheet of paper that fits in your wallet or maybe index cards locked in a desk drawer. It is much easier and safer for people to protect physical paper than data on a computer. Keep two copies around just in case one is lost. Unfortunately storing passwords on paper is not terribly convenient, so you might consider a password manager instead…

b) Use a password manager

Password managers, like LassPass or 1Password, are software that stores your passwords in a safe place on and encrypts the data. Not as secure as writing them down, but that’s the trade-off you make. The password managers that are built into the Web browsers are not terribly safe or secure, at least not nearly as much as their desktop cousins.

 

7) BACKUP! Your computer, blog, email, photos — everything

Sh*t happens. Technology is imperfect, we all make mistakes, computers crash, and bad guys sometimes get lucky.  Hope for the best, but prepare for the worst. Keep copies of your photos, email, blog posts and other treasured digital possessions on a CD/DVD, thumb drive, or even local hard drive. Disk space is way cheap these days so there is no reason not to make the investment.

If you are an Apple fan like me the Time Capsule (DSL Router / Backup device) and MobileMe are excellent choices. There are also several other solid and inexpensive online backup providers including Mozy, Backblaze, and Dropbox. One cannot stress the importance of backups. Should disaster strike, you be really glad that you took the time.

 

Summary

That’s it! You have your survival kit of everything you need to keep your information safe. The cyber criminals out there on the Internet mean business. They are in it for the money, your money. They pride themselves on being well informed and ahead of the curve, which is exactly what is needed to NOT become a victim to online fraud and other nastiness. Being just a little bit safer and secure than the rest of the masses doing little to nothing to protect themselves makes all the difference.

Session Fixation Prevention in Java

What is it and why should I care?
Session fixation, by most definitions, is a subclass of session hijacking. The most common basic flow is:

Step 1. Attacker gets a valid session ID from an application
Step 2. Attacker forces the victim to use that same session ID
Step 3. Attacker now knows the session ID that the victim is using and can gain access to the victim’s account

Step 2, which requires forcing the session ID on the victim, is the only real work the attacker needs to do. And even this action on the attacker’s part is often performed by simply sending the victim a link to a website with the session ID attached to the URL.

Obviously, one user being able to take over another user’s account is a serious issue, so…

What should I do about it?
Fortunately, resolving session fixation is usually fairly simple. The basic advice is:

Invalidate the user session once a successful login has occurred.

The usual basic flow to handle session fixation prevention looks like:

1. User enters correct credentials
2. System successfully authenticates user
3. Any existing session information that needs to be retained is moved to temporary location
4. Session is invalidated (HttpSession#invalidate())
5. New session is created (new session ID)
6. Any temporary data is restored to new session
7. User goes to successful login landing page using new session ID

A useful snippet of code is available from the ESAPI project that shows how to change the session identifier:

http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/reference/DefaultHTTPUtilities.java (look at the changeSessionIdentifier method)

There are other activities that you also can perform to provide additional assurance against session fixation. A number are listed below:

1. Check for session fixation if a user tries to login using a session ID that has been specifically invalidated (requires maintaining this list in some type of LRU cache)

2. Check for session fixation if a user tries to use an existing session ID already in use from another IP address (requires maintaining this data in some type of map)

3. If you notice these types of obvious malicious behavior, consider using something like AppSensor to protect your app, and to be aware of the attack

As you can see, session fixation is a serious issue, but has a pretty simple solution. Your best bet if possible is to include an appropriate solution in some “enterprise” framework (like ESAPI) so this solution applies evenly to all your applications.

References
———–
https://www.owasp.org/index.php/Session_fixation

http://www.acros.si/papers/session_fixation.pdf

http://cwe.mitre.org/data/definitions/384.html

http://projects.webappsec.org/w/page/13246960/Session%20Fixation