Skip to content

Video: “Ten Commandments of IT-Security for Web 2.0 Startups”

In December, Claus Overbeck of RedTeam Pentesting held the invited talk “Ten Commandments of IT-Security for Web 2.0 Startups” at the HackFwd Build 0.4. The talk was recorded on video, and is now available via the HackFwd Blog. HackFwd is led by Lars Hinrichs, the people behind it describe themselves as

experienced tech entrepreneurs looking to support and invest in Europe’s most passionate geeks. We’re a pre-seed investment company designed to enable great people to launch great ideas. Our start-up and support process accelerates the route to beta, profitability, and success.

(From the HackFwd homepage)

If you like, go watch Ten Commandments of IT-Security for Web 2.0 Startups now.

The slides are available at RedTeam Pentesting’s publications webpage.

Tagged , , ,

Netzwerk Recherche Annual Conference 2010

The Netzwerk Recherche Annual Conference 2010 in Hamburg at the NDR is over and it was a great event. Although the hottest topic was the outside temperature of over 36°C, more than 800 people signed in for the event, many more than expected.

Netzwerk Recherche 2010

NDR welcome banner

We were invited to give a workshop about advanced technical investigation techniques for the attending journalists, which turned out to be quite a success. We tried to cover the topic not only from a journalist’s view, but also from an attacker’s perspective (lacking the legal and ethical constraints a journalist should have), because we felt it is important to show to people not only what they can do, but what possibilities the other side has, too.

The slides, including a link collection, can be downloaded from our website under Publications.

Thanks to the organisers for the event. We met many interesting people and generally had a very positive feedback to our workshop. We hope to do another one next year!

Update: Heise has an article where a large part is about our workshop: Netzwerk Recherche: Pentestereien für Journalisten

Tagged , , , ,

New Whitepaper: JBoss AS – Deploying WARs with the DeploymentFileRepository MBean

We released a new JBoss security whitepaper with the title “JBoss Application Server – Deploying WARs with the DeploymentFileRepository MBean” today. It explains how to deploy WAR files with the DeploymentFileRepository MBean and how this is even possible with Cross Site Request Forgery (CSRF). The paper is available at

http://www.redteam-pentesting.de/publications/jboss

This new informational page also contains the now publicly released scripts used in the older paper “Bridging the Gap between the Enterprise and You – or – Who’s the JBoss now?”, which is also available there.

Abstract

The JBoss Application Server (JBoss AS) is a widely used, open source Java application server. It is part of the JBoss Enterprise Middleware Suite (JEMS) and often used in large enterprise installations. Because of the high modularity and versatility of this software solution, which leads to a high complexity, the JBoss AS is a rewarding target for attackers in enterprise networks. This paper adds to the whitepaper “Bridging the Gap between the Enterprise and You – or – Who’s the JBoss now?” released by RedTeam Pentesting. It shows how to use the DeploymentFileRepository MBean to deploy a Web ARchive (WAR) without the need of outbound connections being allowed for the JBoss AS. It also describes how this can be used in conjunction with CSRF to attack a JBoss AS with a protected JMX Console.

To make the JBoss research complete, I sent one new and two updated Metasploit modules to their mailing list. The updated modules improve on the already existing jboss_deploymentfilerepository.rb and jboss_maindeployer exploits. The new module jboss_bshdeployer.rb adds an exploit to install a WAR file via the BeanShellDeployer MBean's createScriptDeployment() method. If they do not make it to the main repository, you can always download them from the list post.

Tagged , , , , ,

XSS Prevention: Don’t Try This At Home

Cross Site Scripting (XSS) vulnerabilities are still one of the security problems you find in almost every web application. If the application’s interaction surface is reasonably large, it’s really just a matter of time.

For us, this means that in almost all web application pentests, we find XSS vulnerabilities to be documented. And there’s one thing we always tell people when we present our results: If possible, don’t code your own filter, but use a well-tested XSS prevention library.

Now this should be a no-brainer, but surprisingly often you find self-written code in web applications that’s supposed to defend against XSS. And it fails. Because XSS filtering is hard, which people still tend to disbelieve. All you need to do is to check for those angle brackets and single ticks, right? Well, have a look at the much cited XSS cheat sheet if you don’t believe how hard XSS filtering can really be.

Now I don’t want to go into the details of XSS filtering, the OWASP XSS Prevention Cheat Sheet already has a very nice overview of what to pay attention to. Point 1.6 is what we also say though: You need a security encoding library. OWASP is recommending their own ESAPI project, but there are of course also other libraries for different languages (like e.g. HTML Purifier). Today’s web application frameworks oftentimes implement XSS prevention measures, so have a look at your favourite framework and if there’s already some builtin XSS mitigation functionality.

The next thing, and that’s also explained in the cheat sheet, is the differentiation between input validation and output encoding and why you preferably should use both. Many XSS attacks will already be prevented by simply encoding your output properly.

Also, always have an eye open for new developments. HTML5 is around the corner and people are already working on the HTML5 Security Cheat Sheet. Don’t get lazy because you added a filtering library to your code. It might not work against the newest attacks.

Tagged , , , ,

Hacking JBoss AS at the Ruhr-Universität Bochum

On April 21, 2010 we will give the talk “Bridging the Gap between the Enterprise and You – or – Who’s the JBoss now” (in German) at the Bachelor-Vertiefungspraktikum zur Hackertechnik of the Chair for Network and Data Security, Ruhr-Universität Bochum.

It doesn’t say so on the website, but according to the organisers the talk is open for everyone. So, if you happen to be in Bochum that day, make sure to join us at the RUB, we’d be happy to see you there.

Tagged , , ,

Hackito Ergo Sum

Thanks to one unfortunate speaker scheduled for Hackito Ergo Sum who can’t make it to the conference, I was invited to give a talk about Pandora’s Bochs on short notice, which I will gladly do. Additionally, RedTeam Pentesting will sponsor the event. The conference program looks very promising – so quickly make up your mind: the conference will start tomorrow :)

The Documentation Is Always Right. Right?

When it comes to IT security, one of the things you tell every IT worker, be it the system administrator or the web application developer, is that they should thoroughly read the documentation for whatever they are working with. It doesn’t matter if it’s a new network component or a web application framework you’re programming the new website with, only when you intimately know the intricacies of your tools, you’ll be able to adequately secure them against the big bad world.

Now, the problem with documentation is twofold: First of all, there has to exist some kind of documentation. I’m a Ruby coder, believe me, I know all about missing docs… The next problem is: It has to be accurate. If what is written in the documentation is not true, then you have a problem. Sometimes, documentation is just sloppy in whatever it describes. Sometimes, it is plain wrong.

Inaccurate documentation may be only a nuisance when you try to find out why the config option you set for coloured log output doesn’t do anything, but it can become outright dangerous when it comes to security related documentation. I want to show you what I mean by example. Let’s have a look at… the Typo3 documentation.

Typo3 provides in its core documentation the “Typo3 Coding Guidelines”. To follow them is mandatory for core developers and contributers to the Typo3 core, as the document states. To be fair from the start: The linked documentation is for version 4.1.0 and not directly linked from the website anymore. If you click on the documentation link on their website, you get directed to the current documentation for version 4.3.2. The link is, however, the first one you get with a Google search for “typo3 updatequery”, which may not be such an unusual search request when you want to know how the updatequery() function works. As you may have guessed, the function executes a SQL UPDATE and is part of Typo3’s Database Abstraction Layer (DBAL). The new documentation for 4.3.2 only contains this sentence:

The TYPO3 database should be always accessed through the use of $GLOBALS['TYPO3_DB']. This is the instance of t3lib_db class from t3lib/class.t3lib_db.php.

That said, let me quote the relevant parts from section 1.4 “Database connectivity and DBAL” from the old version 4.1.0:

TYPO3 has been designed to use MySQL from the beginning. With TYPO3 3.6.0 a database wrapper class has been introduced in all of the core and default global extensions. This means that implementation of various Database Abstraction Layers (DBAL) is now possible.
[...]
The wrapper class is called “t3lib_DB” and is instantiated globally as $TYPO3_DB. The class contains three sections of functions
[...]
2. Query building functions: Instead of constructing SELECT, UPDATE, INSERT and DELETE statements directly you can use API functions in the wrapper class for this. This requires a bit more re-design from you but you will get better security in your scripts (prevents SQL injection for UPDATE/INSERT at least) and is step-2 towards database abstraction support in your extensions!

As a developer reading this part of the documentation, I might just think “great, I don’t have to worry about SQL Injection in my UPDATE and INSERT queries if I use the DBAL. How convenient!”. As a pentester, you of course immediately get suspicious. Especially if you searched for “Typo3 prepared statements” before and know that Typo3 doesn’t support prepared statements in its DBAL (yet).

Ok, let’s have a look at the source code. The following sources are from version 4.3.2 and haven’t changed in the relevant parts since 4.1.0. The function UPDATEquery() is defined in t3lib/class.t3lib_db.php:


/**
 * Creates an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...')
 * from the array with field/value pairs $fields_values.
 * Usage count/core: 6
 *
 * @param       string          See exec_UPDATEquery()
 * @param       string          See exec_UPDATEquery()
 * @param       array           See exec_UPDATEquery()
 * @param       array           See fullQuoteArray()
 * @return      string          Full SQL query for UPDATE (unless  $fields_values
 * does not contain any elements in which case it will be false)
 */
function UPDATEquery($table,$where,$fields_values,$no_quote_fields=FALSE) {
  // Table and fieldnames should be "SQL-injection-safe" when supplied to this
  // function (contrary to values in the arrays which may be insecure).

Wait a minute. Table- and fieldnames should be SQL injection safe? Like in, before I supply them to UPDATEquery()? Why, that’s useful information! Let’s see the body of the function to verify that table and fieldnames are not sanitised:


  if (is_string($where))    {
    if (is_array($fields_values) && count($fields_values))  {

      // quote and escape values
      $nArr = $this->fullQuoteArray($fields_values,$table,$no_quote_fields);

Here, the $fields_values array get escaped. fullQuoteArray() uses Typo3’s fullQuoteStr() internally, which in turn uses mysql_real_escape() to escape a value:


function fullQuoteArray($arr, $table, $noQuote=FALSE)   {
[...]
  foreach($arr as $k => $v)       {
    if ($noQuote===FALSE || !in_array($k,$noQuote))     {
      $arr[$k] = $this->fullQuoteStr($v, $table);
    }
  }
  return $arr;
}

Ok. As we can see, the field names indeed do not get escaped, only the field values. What about $table and $where?


      $fields = array();
      foreach ($nArr as $k => $v) {
        $fields[] = $k.'='.$v;
      }

      // Build query:
      $query = 'UPDATE ' . $table . ' SET ' . implode(',', $fields) .
        (strlen($where) > 0 ? ' WHERE ' . $where : '');

      // Return query:
      if ($this->debugOutput || $this->store_lastBuiltQuery) {
        $this->debug_lastBuiltQuery = $query;
      }
      return $query;
[...]
}

Apparently, the $table and $fields variables are inserted into the query without any further sanitisation. So the comment is right, you have to check for SQL injections in the table- and fieldnames. But, the values in the $where variable are also inserted verbatim! So there’s another unsanitised variable, not even mentioned in the comment.

As you can see, blindly trusting the documentation may lead to dangerous behaviour, like not santising all your inputs in this case. Of course, you can’t check the source code of every security relevant functionality yourself, even if you have access to it. Just have a healthy dose of scepticism if you find a statement like the one in the old Typo3 coding guidelines without any further explanation.

I wrote a similar blog post way back in 2006 titled “Reading the fine Manual”, where we saw that the PHP ereg*() functions are not binary safe. In that case however, the documentation did tell the truth :).

Tagged , , ,

Security Policy Gone Wrong

Another story from the trenches:

Client: “You will have to work on site for this job. The data you’re gonna work with is of course highly sensitive and confidential. We cannot risk any of it to leave the company premises.”

Ok, so at this point, you usually prepare yourself to disillusion the client about how secure large company networks usually are and through how many insecure systems their data travels daily (including the Internet). But this time, they had a solution to the problem:

Client: “Ok, how about this: We take an image of your hard drive when you enter the building. When you leave in the evening, we take another image and see what data changed. This way, we know if any sensitive data leaves the company.”

No further questions. On the bright side, it didn’t take long to convince them that this wouldn’t really solve the problem.

The moral of the story: If you hire pentesters to deliberatly hack your network and search for security vulnerabilities, make sure that you trust them. Otherwise, search for another company. This is one of the reasons why we always have a personal meeting even before we send you a quote. We want you to know who we are and that you can entrust us with the highly sensitive task of pentesting your network. All our pentesters are listed on our homepage, something you usually do not see with other companies. You may want to read this older blog post about pentesting as a me-too-business too, a topic also relevant when thinking about trust.

Tagged , , ,

A Tale of Access Control and Config File Backups

Location: A security area with access control. Two pentesters need to get (legitimate) access to the area, which requires three things: An authorisation token, your signature, and your identity card. The token is ready, the paper sheet signed and… access is granted. Wait, what about the identity card? The friendly security guard is stumped.

“Well, the system says an ID card is not required. Let me check again. Nope, the option’s not checked. But now that you mention it… we had a software upgrade last week. I guess the config just got lost in the process.”

So remember: When doing a software update in a high security area, back up your config files and compare them with the updated configuration. You may spare yourself the unpleasant surprise of having some pentesters notice the lowered security barrier. Or much worse, have a real incident.

Tagged , , ,

17th DFN-CERT Workshop 09.-10. Feb.

Another year passed by and it’s time again for the annual DFN-CERT workshop. It’s taking place for the 17th time, and this year, Lutz will talk about emulation based unpacking of runtime packed malware in his (German) talk

“Emulationsbasiertes Entpacken von laufzeitgepackten Schadprogrammen und darüber hinaus”

He’ll show you his project “Pandora’s Bochs”, based on the popular Bochs IA-32 Emulator. The talk will be on February 9th, the first workshop day, at 4:15pm. Be aware that the location changed, it now takes place at the Grand Elysée Hamburg.

We are happy to have been accepted for a talk the fourth time in a row, the DFN-CERT workshop it’s always nice to be at the workshop and present some of our research. Be sure to check out the program, there’ll be other interesting talks, too.

Tagged , , ,