<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>ImperialViolet</title>
 <link href="http://www.imperialviolet.org/iv-rss.xml" rel="self"/>
 <link href="http://www.imperialviolet.org/"/>
 <updated>2010-02-10T08:28:38-08:00</updated>
 <id>http://www.imperialviolet.org/</id>
 <author>
   <name>Adam Langley</name>
 </author>

 
 <entry>
   <title>Macs everywhere</title>
   <link href="http://www.imperialviolet.org/2010/01/31/macseverywhere.html"/>
   <updated>2010-01-31T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2010/01/31/macseverywhere</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://usesthis.com/&quot;&gt;The Setup&lt;/a&gt; is a neat site. They find (somewhat) famous techie people and interview them about what hardware and software they use. I was browsing through it because I recognised some of the names, and because it's always neat to find out about tools that you don't use.&lt;/p&gt;

&lt;p&gt;But it struck me how many people were using OS X as their primary, day to day, operating system. So I went through every one of them and added up the numbers (except Why the Lucky Stiff, because they put an underscore at the start of the domain name; stopping it from resolving).&lt;/p&gt;

&lt;p&gt;Windows: 3.5, Linux: 3, Mac: 29.5&lt;/p&gt;

&lt;p&gt;These folks aren't all hardcore coders to be sure, but one of the Linux users is RMS and I'm not sure he counts! It would be like asking Steve Jobs what he uses.&lt;/p&gt;

&lt;p&gt;But gosh, that's a total OS X domination.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Strict Transport Security</title>
   <link href="http://www.imperialviolet.org/2010/01/26/sts.html"/>
   <updated>2010-01-26T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2010/01/26/sts</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.google.com/chrome&quot;&gt;Chrome&lt;/a&gt; 4 &lt;a href=&quot;http://googlechromereleases.blogspot.com/2010/01/stable-channel-update_25.html&quot;&gt;went stable yesterday&lt;/a&gt;. One of the many new things in this release is the addition of &lt;a href=&quot;http://lists.w3.org/Archives/Public/www-archive/2009Sep/att-0051/draft-hodges-strict-transport-sec-05.plain.html&quot;&gt;Strict Transport Security&lt;/a&gt;. STS allows a site to request that it always be contacted over HTTPS. So far, only Chrome supports it. However, the popular &lt;a href=&quot;http://noscript.net/&quot;&gt;NoScript&lt;/a&gt; Firefox extension &lt;a href=&quot;http://hackademix.net/2009/09/23/strict-transport-security-in-noscript/&quot;&gt;also supports it&lt;/a&gt; and hopefully support will appear in Firefox proper at some point.&lt;/p&gt;

&lt;p&gt;The issue that STS addresses is that users tend to type &lt;tt&gt;http://&lt;/tt&gt; at best, and omit the scheme entirely most of the time. In the latter case, browsers will insert &lt;tt&gt;http://&lt;/tt&gt; for them.&lt;/p&gt;

&lt;p&gt;However, HTTP is insecure. An attacker can grab that connection, manipulate it and only the most eagle eyed users might notice that it redirected to &lt;tt&gt;https://www.bank&lt;b&gt;0&lt;/b&gt;famerica.com&lt;/tt&gt; or some such. From then on, the user is under the control of the attacker, who can intercept passwords etc at will.&lt;/p&gt;

&lt;p&gt;An STS enabled server can include the following header in an HTTPS reply:&lt;/p&gt;

&lt;pre&gt;Strict-Transport-Security: max-age=16070400; includeSubDomains&lt;/pre&gt;

&lt;p&gt;When the browser sees this, it will remember, for the given number of seconds, that the current domain should &lt;i&gt;only&lt;/i&gt; be contacted over HTTPS. In the future, if the user types &lt;tt&gt;http://&lt;/tt&gt; or omits the scheme, HTTPS is the default. In fact, all requests for URLs in the current domain will be redirected to HTTPS. (So you have to make sure that you can serve them all!).&lt;/p&gt;

&lt;p&gt;For more details, see &lt;a href=&quot;http://lists.w3.org/Archives/Public/www-archive/2009Sep/att-0051/draft-hodges-strict-transport-sec-05.plain.html&quot;&gt;the specification&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There is still a window where a user who has a fresh install, or who wipes out their local state, is vulnerable. Because of that, we'll be starting a &quot;Preloaded STS&quot; list. These domains will be configured for STS out of the box. In the beginning, this will be hardcoded into the binary. As it (hopefully) grows, it can change into a list this is shared across browsers, like the safe-browsing database is today.&lt;/p&gt;

&lt;p&gt;If you own a site that you would like to see included in the preloaded STS list, contact me at &lt;tt&gt;&lt;script type=&quot;text/javascript&quot;&gt;document.write('\u0061\u0067\u006c\u0040\u0063\u0068\u0072\u006f\u006d\u0069\u0075\u006d\u002e\u006f\u0072\u0067')&lt;/script&gt;&lt;/tt&gt;.
</content>
 </entry>
 
 <entry>
   <title>Setting up Apache with OCSP stapling</title>
   <link href="http://www.imperialviolet.org/2009/12/20/setting-up-ocsp.html"/>
   <updated>2009-12-20T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2009/12/20/setting-up-ocsp</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Online_Certificate_Status_Protocol&quot;&gt;OCSP&lt;/a&gt; is the Online Certificate Status Protocol. It's a way for TLS clients to check if a certificate is expired. A certificate with OCSP enabled includes a URL to which a client can send a POST request and receive a signed statement that a given certificate is still valid.&lt;/p&gt;

&lt;p&gt;This adds quite a bit of latency to the TLS connection setup as the client has to perform a DNS lookup on the OCSP server hostname, create an HTTP connection and perform the request-response transaction.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/OCSP_Stapling&quot;&gt;OCSP stapling&lt;/a&gt; allows the TLS server to include a recent OCSP response in the TLS handshake so that the client doesn't have to perform its own check. This also reduces load on the OCSP server.&lt;/p&gt;

&lt;p&gt;Apache recently got support for OCSP stapling and this post details how to set it up.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;1. Prerequisites&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Apache support got added in &lt;a href=&quot;http://svn.apache.org/viewvc?view=revision&amp;revision=829619&quot;&gt;this revision&lt;/a&gt;. At the time of writing, no release of Apache includes this so we get it from SVN below.&lt;/p&gt;

&lt;p&gt;OpenSSL support was added in 0.9.8h. The version in Ubuntu Karmic is &lt;i&gt;not&lt;/i&gt; recent enough, so I pulled the packages from &lt;tt&gt;lucid&lt;/tt&gt; for this:&lt;/p&gt;

&lt;pre&gt;cd /tmp
wget 'http://mirrors.kernel.org/ubuntu/pool/main/o/openssl/openssl_0.9.8k-7ubuntu3_amd64.deb'
wget 'http://mirrors.kernel.org/ubuntu/pool/main/o/openssl/libssl-dev_0.9.8k-7ubuntu3_amd64.deb'
wget 'http://mirrors.kernel.org/ubuntu/pool/main/o/openssl/libssl0.9.8_0.9.8k-7ubuntu3_amd64.deb'

sudo dpkg -i openssl_0.9.8k-7ubuntu3_amd64.deb libssl0.9.8_0.9.8k-7ubuntu3_amd64.deb  libssl-dev_0.9.8k-7ubuntu3_amd64.deb&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;2. Building Apache&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;As noted, we need the SVN version of Apache at the time of writing. I'll be using some paths in the following that you should change (like &lt;tt&gt;/home/agl/local/ocsp&lt;/tt&gt;):&lt;/p&gt;

&lt;pre&gt;svn checkout http://svn.apache.org/repos/asf/httpd/httpd/trunk httpd
cd httpd
svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr
./buildconf
cd srclib/apr
./configure --prefix=/home/agl/local/ocsp&lt;/pre&gt;

&lt;p&gt;At this point, I had to patch APR in order to get it to build. I suspect this build break will be fixed in short order but, for the sake of completeness, here's the patch that I applied:&lt;/p&gt;

&lt;pre&gt;--- poll/unix/pollset.c (revision 892677)
+++ poll/unix/pollset.c (working copy)
@@ -129,6 +129,8 @@
 
 static apr_status_t close_wakeup_pipe(apr_pollset_t *pollset)
 {
+    apr_status_t rv0, rv1;
+
     /* Close both sides of the wakeup pipe */
     if (pollset-&amp;gt;wakeup_pipe[0]) {
     rv0 = apr_file_close(pollset-&amp;gt;wakeup_pipe[0]);&lt;/pre&gt;

&lt;p&gt;Now we can build and install Apache itself. Since we are giving a &lt;tt&gt;prefix&lt;/tt&gt; option, this doesn't conflict with any system installs.&lt;/p&gt;

&lt;pre&gt;cd ../..
./configure --prefix=/home/agl/local/ocsp --with-apr=/home/agl/local/ocsp --enable-ssl --enable-socache-dbm&lt;/pre&gt;

&lt;p&gt;Again, for the sake of completeness, I'll mention that Apache SVN had a bug at the time of writing that will stop OCSP stapling from working:&lt;/p&gt;

&lt;pre&gt;--- modules/ssl/ssl_util_stapling.c     (revision 892677)
+++ modules/ssl/ssl_util_stapling.c     (working copy)
@@ -414,6 +414,10 @@
        goto done;
    }

+    if (uri.port == 0) {
+        uri.port = APR_URI_HTTP_DEFAULT_PORT;
+    }
+
    *prsp = modssl_dispatch_ocsp_request(&amp;amp;uri, mctx-&amp;gt;stapling_responder_timeout,
                                         req, conn, vpool);&lt;/pre&gt;

&lt;p&gt;Then build and install it...&lt;/p&gt;

&lt;pre&gt;make -j4
make install&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;3. Generating certs&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;For this example, I'll be generating a CA cert, a server cert and an OCSP responder cert for that CA. In the real world you'll probably be getting the certs from a true CA, so you can skip this step.&lt;/p&gt;

&lt;pre&gt;cd /home/agl/local/ocsp
mkdir certs &amp;amp;&amp;amp; cd certs
wget 'https://fedorahosted.org/pkinit-nss/browser/doc/openssl/make-certs.sh?format=txt'
mv make-certs.sh\?format=txt make-certs.sh
/bin/bash ./make-certs.sh europa.sfo.corp.google.com test@example.com all ocsp:http://europa.sfo.corp.google.com/
cat ocsp.crt ocsp.key &amp;gt; ocsp.pem&lt;/pre&gt;

&lt;p&gt;Now I'm going to add the CA that was just generated to the CA set. Firstly, Chromium uses an NSS database in your home directory:&lt;/p&gt;

&lt;pre&gt;certutil -d sql:/home/agl/.pki/nssdb -A -n testCA -i ~/local/ocsp/certs/ca.crt -t Cu,,&lt;/pre&gt;

&lt;p&gt;OpenSSL uses a file of PEM certs:&lt;/p&gt;

&lt;pre&gt;cd /etc/ssl
cp cert.pem cert.pem.orig
rm cert.pem
cat cert.pem.orig /home/agl/local/ocsp/certs/ca.crt &amp;gt; cert.pem&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;4. Running the responder&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;In the real world, the OCSP responder is run by the CA that you got your certificate from. But here I'm going to be running my own since I generated a new CA in section 3.&lt;/p&gt;

&lt;pre&gt;cd ~/local/ocsp
touch index.txt
sudo openssl ocsp -index index.txt -port 80 -rsigner certs/ca.pem -CA certs/ca.pem&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;5. Configuring Apache&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;I won't cover the basics of configuring Apache here. There are plenty of documents on the web about that. I'll just note that I have Apache only listening on port 443 since my OCSP responder is running on 80.&lt;/p&gt;

&lt;p&gt;The config that you'll need is roughly this:&lt;/p&gt;

&lt;pre&gt;SSLStaplingCache dbm:/tmp/staples
SSLCACertificateFile &quot;/etc/ssl/cert.pem&quot;
SSLUseStapling on&lt;/pre&gt;

&lt;p&gt;(You probably want to choose a better location for the cache.)&lt;/p&gt;

&lt;p&gt;Apache will parse its server certificate on startup and extract the OCSP responder URL. It needs to find the CA certificate in order to validate OCSP responces and that's why the &lt;tt&gt;SSLCACertificateFile&lt;/tt&gt; directive is there (and why we added the CA to that file in section 3).&lt;/p&gt;

&lt;p&gt;After restarting Apache, look in the &lt;tt&gt;error.log&lt;/tt&gt;. What you &lt;i&gt;don't&lt;/i&gt; want to see is the following:&lt;/p&gt;

&lt;pre&gt;[Sun Dec 20 17:24:28 2009] [error] ssl_stapling_init_cert: Can't retrieve issuer certificate!
[Sun Dec 20 17:24:28 2009] [error] Unable to configure server certificate for stapling&lt;/pre&gt;

&lt;p&gt;That means that Apache couldn't find the CA cert.&lt;/p&gt;

&lt;p&gt;There are other directives, but they are currently undocumented. Your best bet is to look at &lt;a href=&quot;https://issues.apache.org/bugzilla/show_bug.cgi?id=43822&quot;&gt;the original Apache bug&lt;/a&gt; and the &lt;a href=&quot;http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/mod_ssl.c?r1=821621&amp;r2=829619&amp;pathrev=829619&quot;&gt;commit itself&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Chrome Linux Beta</title>
   <link href="http://www.imperialviolet.org/2009/12/08/chrome-beta.html"/>
   <updated>2009-12-08T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2009/12/08/chrome-beta</id>
   <content type="html">&lt;p&gt;Life goals: get a comic published. &lt;a href=&quot;http://www.google.com/chrome/intl/en/w00t.html&quot;&gt;Check&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Digital Economy Bill</title>
   <link href="http://www.imperialviolet.org/2009/11/23/digital-econ-bill.html"/>
   <updated>2009-11-23T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2009/11/23/digital-econ-bill</id>
   <content type="html">&lt;p&gt;Cory Doctorow seems to have crafted the lexicon of the opposition to the Digital Economy Bill with his phrase &amp;lsquo;Pirate Finder General&amp;rsquo; [&lt;a href=&quot;http://www.boingboing.net/2009/11/19/breaking-leaked-uk-g.html&quot;&gt;1&lt;/a&gt;]. In his &lt;a href=&quot;http://www.boingboing.net/2009/11/20/britains-new-interne.html&quot;&gt;follow up&lt;/a&gt; he claims that this bill will introduce three-strikes, ISP spying and powers for Peter Mandelson to rewrite copyright law at will.&lt;/p&gt;

&lt;p&gt;I spent a fun-filled Sunday afternoon reading &lt;a href=&quot;http://services.parliament.uk/bills/2009-10/digitaleconomy/documents.html&quot;&gt;the bill&lt;/a&gt; to see how bad it really is so that you don't have to (although you still should). You're welcome.&lt;/p&gt;

&lt;p&gt;Firstly, the changes to copyright law are only a small part of the bill. Other parts of the bill cover: Channel 4 and Channel 3 licensing, removing the requirements for Teletext, digital switch over, radio licenses and classification of video games. I won't be talking about those in this post.&lt;/p&gt;

&lt;p&gt;The bill requires that ISPs pass on infringement notices to subscribers, either via email or via the postal system. Copyright owners can also request infringement lists. This allows them to see that their notices A, B, C all went to the same subscriber. They can then take this information to court and proceed with the usual actions. (124A and 124B.)&lt;/p&gt;

&lt;p&gt;The bill defers much of the policy in this area to a code that is to be written by OFCOM with the approval of the Secretary of State. This code includes the number of infringement notices that a single subscriber needs in order to be included in a report, the size of fines to be imposed on ISPs for failing to follow the code and the appeals process. The Secretary of State sets the compensation paid from copyright holders to ISPs and from everyone to OFCOM (124L).&lt;/p&gt;

&lt;p&gt;What isn't in the bill is any talk of disconnection, ISP spying or three strikes. However, 124H gives the Secretary of State the power to require any &amp;ldquo;technical obligation&amp;rdquo;.&lt;/p&gt;

&lt;q&gt;(3) A &quot;technical measure&quot; is a measure that (a) limits the speed or other capacity of the service provided to a subscriber; (b) prevents a subscriber from using the service to gain access to particular material, or limits such use; (c) suspends the service provided to a subscriber; or (d) limits the service provided to a subscriber in another way.&lt;/q&gt;

&lt;p&gt;A brief interlude about &lt;a href=&quot;http://en.wikipedia.org/wiki/Statutory_Instrument_(UK)&quot;&gt;statutory instruments&lt;/a&gt; is needed here. SIs are published by the government and cannot be amended by Parliament. There are two types. The first takes effect automatically and Parliament has a short time (usually 40 days depending on holidays etc) to annul it. The second requires positive action by both Houses before it takes effect.&lt;/p&gt;

&lt;p&gt;According to Wikipedia, the last time that an SI was annulled was in 2000, and 1979 before that. The last time that an SI wasn't approved was 40 years ago.&lt;/p&gt;

&lt;p&gt;The powers to impose technical measures are of the annul variety: they take effect automatically after 40 days. They don't appear to include requiring ISPs to spy.&lt;/p&gt;

&lt;p&gt;After that power, 302A gives the Secretary of State the power to change the Copyright Act via a positive action SI &amp;ldquo;for the purpose of preventing or reducing the infringement of copyright by means of the internet&amp;rdquo;.&lt;/p&gt;

&lt;p&gt;Next up, 124N gives the Secretary of State the power to take over any domain name registrar. By my reading, that is no exaggeration.&lt;/p&gt;

&lt;p&gt;The Secretary can take action if they believe that the actions of a registrar affect &amp;ldquo;(a) the reputation or availability of electronic communications networks or electronic communications services [...] (b) the interests of consumers or members of the public [...].&amp;rdquo;. The action can either be to appoint a &amp;ldquo;manager&amp;rdquo;, who has total power, or to ask a court to change the constitution of the body and enjoin them from changing it back.&lt;/p&gt;

&lt;p&gt;There's no requirement that this registrar be based in the UK, or even to allocate in the &lt;tt&gt;uk&lt;/tt&gt; ccTLD.&lt;/p&gt;

&lt;p&gt;Understandably, &lt;a href=&quot;http://finance.yahoo.com/news/Official-Statement-by-Telnic-prnews-2147560355.html?x=0&amp;.v=1&quot;&gt;they are quite upset about this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'd also like to quickly note that this bill contains provisions for the licensing of orphan works without the copyright holder being involved also for libraries to have the rights to lend out e-books. (Although without giving any powers to do anything about technical limitations on e-books that might prevent it.)&lt;/p&gt;

&lt;p&gt;Lastly, and I might be misunderstanding something here, on page 52 the Secretary of State seems to get powers to amend or annul anything relating to this act, in any bill in this session of Parliament, or before, by using a positive action SI.&lt;/p&gt;

&lt;p&gt;Hopefully the above provides pointers for people who want to understand and read the bill. Now, my (informed) opining:&lt;/p&gt;

&lt;p&gt;This is an abomination. It's an attempt to subvert Parliament by giving the government the power to write copyright law at will. The provisions are extraordinary. The sanctions against domain name registrars are staggering. I don't know of any other case when the government can sequestrate a private entity at will. Given the international nature of the domain name system, this should cause international concern.&lt;/p&gt;

&lt;p&gt;I expect that this power is largely intended to be a very large stick with which to force the removal of &lt;tt&gt;xyzsucks.com&lt;/tt&gt; style names that embarrass business or government. No registrar will dare cross their interests if they have this power.&lt;/p&gt;

&lt;p&gt;If you vote in the UK, goto &lt;a href=&quot;http://www.theyworkforyou.com/&quot;&gt;TheyWorkForYou&lt;/a&gt;, lookup your MP, write a letter (on paper). Sign &lt;a href=&quot;http://petitions.number10.gov.uk/dontdisconnectus/&quot;&gt;the petition&lt;/a&gt;. Support &lt;a href=&quot;http://www.openrightsgroup.org/&quot;&gt;ORG&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Recent changes to SSL/TLS on the web</title>
   <link href="http://www.imperialviolet.org/2009/11/16/tls-on-the-web.html"/>
   <updated>2009-11-16T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2009/11/16/tls-on-the-web</id>
   <content type="html">&lt;p&gt;Most of the movement around TLS (aka SSL) currently involves people dealing
with the renegotiation issues, but I'm going to sound a happier note today. TLS
isn't static; things are changing for the better:&lt;/p&gt;

&lt;h4&gt;Strict transport security&lt;/h4&gt;

&lt;p&gt;My colleagues, Dr Barth and Collin Jackson proposed &lt;a href=&quot;https://crypto.stanford.edu/forcehttps/forcehttps.pdf&quot;&gt;ForceHTTPS&lt;/a&gt; some time ago. This has picked up Jeff Hodges, from PayPal, and morphed into &lt;a href=&quot;http://lists.w3.org/Archives/Public/www-archive/2009Sep/att-0051/draft-hodges-strict-transport-sec-05.plain.html&quot;&gt;Strict Transport Security&lt;/a&gt;. Dr Barth and I have implemented this in Chromium and Firefox supports it with the &lt;a href=&quot;http://hackademix.net/2009/09/23/strict-transport-security-in-noscript/&quot;&gt;NoScript&lt;/a&gt; extension.&lt;/p&gt;

&lt;p&gt;In short, you can add a header to your HTTPS replies like: &lt;tt&gt;Strict-Transport-Security: max-age=86400&lt;/tt&gt; and the browser will remember, for the next 86400 seconds (1 day), that the origin host should &lt;i&gt;only&lt;/i&gt; be contacted over HTTPS. &lt;strike&gt;It also forbids mixed content&lt;/strike&gt;.&lt;/p&gt;

(&lt;i&gt;&lt;b&gt;Update&lt;/b&gt;: Dr Barth points out that the limits on mixed content have been removed as the standard has advanced!&lt;/i&gt;)

&lt;p&gt;&lt;a href=&quot;http://dev.chromium.org/getting-involved/dev-channel&quot;&gt;Chrome dev channel&lt;/a&gt; releases already support this and it'll be in Chrome 4.0. The hosts are stored in a JSON file in the profile directory:&lt;/p&gt;

&lt;pre&gt;{
   &quot;+7cOz6FDyMiPEjNtc0haTPwdZPbvbPFP2NyZIA82GTM=&quot;: {
      &quot;expiry&quot;: 1258514505.715938,
      &quot;include_subdomains&quot;: false
   }
}&lt;/pre&gt;

&lt;p&gt;If you try to navigate to an &lt;tt&gt;http://&lt;/tt&gt; URL when that host has STS enabled, the browser will internally rewrite it to &lt;tt&gt;https://&lt;/tt&gt;. Suitable sites (banks etc) should start using this as soon as possible.&lt;/p&gt;

&lt;h4&gt;Compression&lt;/h4&gt;

&lt;p&gt;Well, this certainly isn't new! OpenSSL has supported deflate compression on TLS connections for ages, but NSS (the SSL/TLS library used in all Mozilla based products for one) hasn't. This means that Firefox never supported compression, nor Thunderbird (and it's a fairly big deal for IMAP connections).&lt;/p&gt;

&lt;p&gt;However, Wan Teh Chang and I have added deflate support to NSS and it'll be in next release. Thanks to Nelson Bolyard for the code review.&lt;/p&gt;

&lt;h4&gt;Cut through&lt;/h4&gt;

&lt;p&gt;Here's a diagram of a TLS connection from the RFC:&lt;/p&gt;

&lt;pre&gt;Client                                               Server

      ClientHello                  --------&amp;gt;
                                                      ServerHello
                                                     Certificate*
                                               ServerKeyExchange*
                                              CertificateRequest*
                                   &amp;lt;--------      ServerHelloDone
      Certificate*
      ClientKeyExchange
      CertificateVerify*
      [ChangeCipherSpec]
      Finished                     --------&amp;gt;
                                               [ChangeCipherSpec]
                                   &amp;lt;--------             Finished
      Application Data             &amp;lt;-------&amp;gt;     Application Data&lt;/pre&gt;

&lt;p&gt;This means that an HTTPS connection adds an extra two round trips on top of HTTP.&lt;/p&gt;

&lt;p&gt;Nagendra Modadugu and myself (independently) came up with a &amp;ldquo;cut
through&amp;rdquo; mode for TLS handshakes. Rather than wait for the server's
Finished message, the client can send application data after only one
round trip. This means than an attacker can perform a downgrade attack on the
cipher and force the client to transmit with a weaker cipher than it might have
normally used. However, an attacker cannot get the key so, as long as all the
supported ciphers are strong enough, it all works out.&lt;/p&gt;

&lt;p&gt;This cuts a round-trip time from a normal HTTPS handshake and should be
appearing in Chromium and Android soon.&lt;/p&gt;

&lt;p&gt;(Nelson Bolyard tells me that this isn't a novel idea, although it doesn't
seem to have had much traction up til now.)&lt;/p&gt;

&lt;h4&gt;Next protocol negotiation&lt;/h4&gt;

&lt;p&gt;TLS over port 443 is the only clean channel that many hosts have these days.
However, this means that the TCP destination port number can no longer be used
to select an application level protocol since it's fixed by firewalls, proxies
etc.&lt;/p&gt;

&lt;p&gt;The specific use case for this would be
&lt;a href=&quot;http://sites.google.com/a/chromium.org/dev/spdy&quot;&gt;SDPY&lt;/a&gt;, a new
transport layer for HTTP. We want to know, before we send the first request, if
the server supports SDPY.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/binary/draft-agl-tls-nextprotoneg-00.html&quot;&gt;&lt;tt&gt;draft-agl-tls-nextprotoneg&lt;/tt&gt;&lt;/a&gt;
describes an extension to let you do that. It's being tested in Chromium at the
moment (although not yet in the public tree).&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Go launch</title>
   <link href="http://www.imperialviolet.org/2009/11/10/go.html"/>
   <updated>2009-11-10T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2009/11/10/go</id>
   <content type="html">&lt;p&gt;I'm delighted to be a minor part of the &lt;a href=&quot;http://golang.org&quot;&gt;Go&lt;/a&gt; launch today:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://golang.org&quot;&gt;Go&lt;/a&gt; is an experimental language from Google that I've been coding in for the past month or so. It sits in a similar niche to Java: performant but garbage collected. However, it's vastly more enjoyable to code in than Java!&lt;/p&gt;

&lt;p&gt;Thanks to a suite of compilers, it compiles to machine code very quickly. There's also a frontend to GCC in the works. It's runtime and type safe, concurrent, has a novel (for me, at least) take on object orientation and provides runtime reflections on types.&lt;/p&gt;

&lt;p&gt;Personally, I think it gets a place in my list of favoured tools, which currently contains C, C++, Python and Haskell.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>The TLS flaw that wasn't</title>
   <link href="http://www.imperialviolet.org/2009/11/05/tls-reneg.html"/>
   <updated>2009-11-05T00:00:00-08:00</updated>
   <id>http://www.imperialviolet.org/2009/11/05/tls-reneg</id>
   <content type="html">&lt;p&gt;There were many articles yesterday suggesting that a major new flaw in TLS (aka SSL) had been found ([&lt;a href=&quot;http://www.theregister.co.uk/2009/11/05/serious_ssl_bug/&quot;&gt;1&lt;/a&gt;][&lt;a href=&quot;http://it.slashdot.org/story/09/11/05/144252/Man-In-the-Middle-Vulnerability-For-SSL-and-TLS?art_pos=4&quot;&gt;2&lt;/a&gt;][&lt;a href=&quot;http://www.links.org/?p=780&quot;&gt;3&lt;/a&gt;]). The last of those is a post by Ben Laurie, an expert in these matters, with a suitably hyperbolic title: &amp;ldquo;Another Protocol Bites The Dust&amp;rdquo;&lt;/p&gt;

&lt;p&gt;Here's the issue: there's an extremely uncommon configuration of web servers where they're setup to require client side certificates for some URLs and not others. If a user has an HTTPS connection open that didn't handshake with a client side certificate and they try to access such a URL, the webserver will perform another handshake on the same connection. As soon as that handshake completes with the correct certificate, they'll run the request that was received from before the connection was fully authenticated.&lt;/p&gt;

&lt;p&gt;It's a bug in the web server. There was a misunderstanding between what the folks writing the webserver thought that TLS was providing and what it actually provides. One might also argue that it's a short coming in the HTTP protocol (there's no way for a server to ask a client to redo a request). One might also argue that TLS should provide the properties that the web servers expected.&lt;/p&gt;

&lt;p&gt;But it's not a flaw in TLS. The TLS security properties are exactly what was intended.&lt;/p&gt;

&lt;p&gt;Now, it appears that the fix will be to TLS. That's fine, but the place that gets &amp;lsquo;fixed&amp;rsquo; isn't always the place that made the mistake.&lt;/p&gt;

&lt;p&gt;I don't understand why knowledgeable folks like EKR and Laurie are so eager to attribute this problem to TLS.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Anti aliased clipping, a tale of woe</title>
   <link href="http://www.imperialviolet.org/2009/09/02/anti-aliased-clipping.html"/>
   <updated>2009-09-02T00:00:00-07:00</updated>
   <id>http://www.imperialviolet.org/2009/09/02/anti-aliased-clipping</id>
   <content type="html">&lt;p&gt;People have been complaining that rounded rectangles in Chrome aren't
anti-aliased. If you're a web developer, it seems that this is a Big Deal.&lt;/p&gt;

&lt;p&gt;The issue is that almost anything can have rounded corners in WebKit.
There's not a &lt;tt&gt;drawRoundedRectangle&lt;/tt&gt; function, instead, clipping paths
are created and then normal drawing proceeds. On Safari (which is also WebKit,
but sitting on top of the CoreGraphics library), clipping to a path is
anti-aliased and everything looks pretty. However, Chrome's graphics library,
Skia, doesn't do anti-aliased clipping for a good reason.&lt;/p&gt;

&lt;p&gt;Consider the figure below:&lt;/p&gt;

&lt;img src=&quot;/binary/anti-alias-clipping.png&quot;&gt;

&lt;p&gt;At the top left is an anti-aliased clipping region. The darker the pixel,
the more is covered by the path. If we were to fill the region with green, we
would get the image at the bottom left. When drawing, we consider how much of
the clipping region covers each pixel and convert that to an alpha value. For a
pixel which was half covered by the clipping region we would calculate 50%
&amp;times; &lt;tt&gt;background_color&lt;/tt&gt; + 50% &amp;times; &lt;tt&gt;green&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;However, consider what happens when we first fill with red (top right) and
then with green (bottom right). We would expect that the result would be the same
as filling with green - the second fill should cover the first. But for pixels
which are fractionally covered by clipping region, this isn't the case.&lt;/p&gt;

&lt;p&gt;The first fill, with red, works correctly as detailed above. But when we
come to do the second fill, the &lt;tt&gt;background_color&lt;/tt&gt; isn't the original
background color, but the slightly red color resulting from the first fill.
Both CoreGraphics and Firefox's &lt;tt&gt;&amp;lt;canvas&amp;gt;&lt;/tt&gt; have this bug.&lt;/p&gt;

&lt;p&gt;It might seem trivial, but if you end up covering anti-aliased clipping
regions multiple times you end up with unsightly borders around the clip paths.
This is why Skia only supports 1-bit clip paths.&lt;/p&gt;

&lt;p&gt;The correct way to do anti-aliased clipping is to draw to a layer, on top of
the original bitmap, and, when the clipping path is popped from the clip stack,
erase outside of the path (anti-aliased) and composite the result onto the
underlying bitmap.&lt;/p&gt;

&lt;p&gt;This works just fine, the problem is that &lt;tt&gt;&amp;lt;canvas&amp;gt;&lt;/tt&gt; users don't
always pop the clip stack. They expect to be able to set a clipping path, draw
and have it appear without managing a stack. We could collapse the clipping
stack for them when we paint to the screen, but then we need to restore it
afterwards, which would require major surgery to Skia.&lt;/p&gt;

&lt;p&gt;The second problem with anti-aliasing, even when done correctly, is that it
makes it impossible to put polygons next to each other. Try &lt;a
  href=&quot;http://tulrich.com/geekstuff/canvas/perspective.html&quot;&gt;this demo&lt;/a&gt; in
Firefox and note the hairlines caused by anti-aliasing.&lt;/p&gt;

&lt;p&gt;I think what Chrome will end up doing is to anti-alias the clipping paths
(correctly) for everything except &lt;tt&gt;&amp;lt;canvas&amp;gt;&lt;/tt&gt;. This isn't a great
solution, but it's better than what we have now.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Chromium's seccomp Sandbox</title>
   <link href="http://www.imperialviolet.org/2009/08/26/seccomp.html"/>
   <updated>2009-08-26T00:00:00-07:00</updated>
   <id>http://www.imperialviolet.org/2009/08/26/seccomp</id>
   <content type="html">&lt;p&gt;I wrote an article for &lt;a href=&quot;http://www.lwn.net&quot;&gt;LWN&lt;/a&gt; about Chromium's
seccomp sandbox. They decided that it wasn't in the right style for LWN, and
they rewrote it to fit. Their version has just become
&lt;a href=&quot;http://lwn.net/Articles/346902/&quot;&gt;available for free&lt;/a&gt;. I'm including
my version below:&lt;/p&gt;

&lt;h4&gt;The Chromium seccomp sandbox&lt;/h4&gt;

&lt;p&gt;As part of the process of porting &lt;a href=&quot;http://dev.chromium.org&quot;&gt;Chromium&lt;/a&gt; to Linux, we had to decide how to implement Chromium's &lt;a href=&quot;http://dev.chromium.org/developers/design-documents/sandbox&quot;&gt;sandbox&lt;/a&gt; on Linux.&lt;/p&gt;

&lt;p&gt;The Chromium sandbox is an important part of keeping users safe. The web is a very complicated place these days and the code to parse and interpret it is large and on the front-line of security. We try to make sure that this code is free of security bugs, but history suggests that we can't be perfect. So, we plan for the case where someone has an exploit against our rendering code and run it in its own process with limited authority. It's the sandbox's job to limit that authority as much as possible.&lt;/p&gt;

&lt;p&gt;Chromium renderers need very little authority. They need access to &lt;tt&gt;fontconfig&lt;/tt&gt; to find fonts on the system and to open those font files.  However, these can be handled as &lt;a href=&quot;http://code.google.com/p/chromium/wiki/LinuxSandboxIPC&quot;&gt;IPC&lt;/a&gt; requests to the browser process. They do not need access to the X server (which is why we don't have GTK widgets on web pages), nor should they be able to access DBus, which is increasingly powerful these days.&lt;/p&gt;

&lt;p&gt;Drawing is handled using SysV shared memory (so that we can share memory directly with X). Everything else is either serialised over a socketpair or passed using a file descriptor to a tmpfs file. This means that we can deny filesystem access completely. The renderer requires no network access: the network stack is entirely within the browser process.&lt;/p&gt;

&lt;p&gt;Traditional sandboxing schemes on Linux involve switching UIDs and using &lt;tt&gt;chroot&lt;/tt&gt;. We'll be using some of those techniques too. But this text is about the most experimental part of our sandbox: the seccomp layer which my colleague Markus Gutschke has been writing.&lt;/p&gt;

&lt;p&gt;The kernel provides a little known feature where by any process can enter &amp;lsquo;seccomp mode&amp;rsquo;. Once enabled it cannot be disabled. Any process running in seccomp mode can only make four system calls: &lt;tt&gt;read&lt;/tt&gt;, &lt;tt&gt;write&lt;/tt&gt;, &lt;tt&gt;sigreturn&lt;/tt&gt; and &lt;tt&gt;exit&lt;/tt&gt;. Attempting any other system call will result in the immediate termination of the process.&lt;/p&gt;

&lt;p&gt;This is quite desirable for preventing attacks. It removes network access, which is traditionally difficult to limit otherwise (although &lt;tt&gt;CLONE_NEWNET&lt;/tt&gt; is might help here). It also limits access to new, possibly dangerous, system calls that we don't otherwise need like &lt;tt&gt;tee&lt;/tt&gt; and &lt;tt&gt;vmsplice&lt;/tt&gt;. Also, because &lt;tt&gt;read&lt;/tt&gt; and &lt;tt&gt;write&lt;/tt&gt; proceed at full speed, if we limit our use of other system calls, we can hope to have a minimal performance overhead.&lt;/p&gt;

&lt;p&gt;But we do need to support &lt;i&gt;some&lt;/i&gt; other system calls. Allocating memory is certainly very useful. The traditional way to support this would be to RPC to a trusted helper process which could validate and perform the needed actions. However, a different process cannot allocate memory on our behalf. In order to affect the address space of the sandboxed code, the trusted code would have to be inside the process!&lt;/p&gt;

&lt;p&gt;So that's what we do: each untrusted thread has a trusted helper thread running in the same process. This certainly presents a fairly hostile environment for the trusted code to run in. For one, it can only trust its CPU registers - all memory must be assumed to be hostile. Since C code will spill to the stack when needed and may pass arguments on the stack, all the code for the trusted thread has to carefully written in assembly.&lt;/p&gt;

&lt;p&gt;The trusted thread can receive requests to make system calls from the untrusted thread over a socket pair, validate the system call number and perform them on its behalf. We can stop the untrusted thread from breaking out by only using CPU registers and by refusing to let the untrusted code manipulate the VM in unsafe ways with &lt;tt&gt;mmap&lt;/tt&gt;, &lt;tt&gt;mprotect&lt;/tt&gt; etc.&lt;/p&gt;

&lt;p&gt;That could work, if only the untrusted code would make RPCs rather than system calls. Our renderer code is very large however. We couldn't patch every call site and, even if we could, our upstream libraries don't want those patches. Alternatively, we could try and intercept at dynamic linking time, assuming that all the system calls are via glibc. Even if that were true, glibc's functions make system calls directly, so we would have to patch at the level of functions like &lt;tt&gt;printf&lt;/tt&gt; rather than &lt;tt&gt;write&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;This would seem to be a very tough problem, but keep in mind that if we miss a call site, it's not a security issue: the kernel will kill us. It's just a crash bug. So we could use a theoretically incorrect solution so long as it actually worked in practice. And this is what we do:&lt;/p&gt;

&lt;p&gt;At startup we haven't processed any untrusted input, so we assume that the program is uncompromised. Now we can disassemble our own memory, find sites where we make system calls and patch them. Correctly parsing x86 machine code is very tough. &lt;a href=&quot;http://code.google.com/p/nativeclient/&quot;&gt;Native Client&lt;/a&gt; uses a customised compiler which only generates a subset of x86 in order to do it. But we don't need a perfect disassembler so long as it works in practice for the code that we have. It turns out that a simple disassembler does the job perfectly well with only a very few corner cases.&lt;/p&gt;

&lt;p&gt;Now that we have patched all the call sites to call our RPC wrapper, instead of the kernel, we are almost done. We have only to consider system calls which pass arguments in memory. Because the untrusted code can modify any memory that the trusted code can, the trusted code couldn't validate calls like &lt;tt&gt;open&lt;/tt&gt;. It could verify the filename being requested but the untrusted code could change the filename before the kernel copied the string from user-space.&lt;/p&gt;

&lt;p&gt;For these cases, we also have a single trusted process. This trusted process shares a couple of pages of memory with each of the trusted threads. When the trusted thread is asked to make a system call which it cannot safely validate, it forwards the call to the trusted process. Since the trusted process has a different address space, it can safely validate the arguments without interference. It then copies the validated arguments into the shared memory pages. These memory pages are writable by the trusted process, but read-only in the sandboxed process. Thus the untrusted code cannot modify them and the trusted code can safely make the system call using the validated, read-only arguments.&lt;/p&gt;

&lt;p&gt;We also use this trick for system calls like &lt;tt&gt;mmap&lt;/tt&gt; which don't take arguments in memory, but are complicated to verify. Recall that the trusted thread has to be hand written in assembly so we try to minimise the amount of this code where possible.&lt;/p&gt;

&lt;p&gt;Once we have this scheme in place we can intercept, examine and deny any system calls. We start off denying everything and then, slowly, add system calls that we need. For each system call we need to consider the security implications it might have. Calls like &lt;tt&gt;getpid&lt;/tt&gt; are easy, but what damage could one do with &lt;tt&gt;mmap/munmap&lt;/tt&gt;? Well, the untrusted code could replace the code which the trusted threads are running for one! So, when a call might be dangerous we allow only a minimal, and carefully examimed, subset of flags which match the uses that we actually have in our code.&lt;/p&gt;

&lt;p&gt;We'll be layering this sandbox with some more traditional UNIX sandboxing techniques in the final design. However, you can get a preview of the code in it's incomplete state already at its &lt;a href=&quot;http://code.google.com/p/seccompsandbox&quot;&gt;Google Code homepage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There's still much work to be done. A given renderer could load a web page with an &lt;tt&gt;iframe&lt;/tt&gt; to any domain. Those &lt;tt&gt;iframes&lt;/tt&gt; are handled in the same renderer, thus a compromised renderer can ask the browser for any of the user's cookies. Microsoft research developed &lt;a href=&quot;http://research.microsoft.com/apps/pubs/default.aspx?id=79655&quot;&gt;Gazelle&lt;/a&gt;, which has much stricter controls on a renderer, at the expense of web-compatibility. We know that users wont accept browsers that don't work with their favourite websites, but we are also very jealous of Gazelle's security properties so hopefully we can improve Chromium along those lines in the future.&lt;/p&gt;

&lt;p&gt;Another weak spot are installed plugins. Plugin support on Linux is very new but on Windows, at least, we don't sandbox plugins. They don't expect to be sandboxed and we hurt web-compatibility (and break their auto-updating) if we limit them. That means that plugins are a vector for more serious attacks against web browsers. As ever, keep up to date with the latest security patches!&lt;/p&gt;
</content>
 </entry>
 

</feed>
