components/openstack/swift/patches/02-CVE-2014-0006.patch
author Danek Duvall <danek.duvall@oracle.com>
Tue, 13 May 2014 15:55:28 -0600
changeset 1896 f83e6dde6c3b
permissions -rw-r--r--
18551677 Request to integrate Swift into userland

From c0eed792a22865b280f99cbb79076fa7ad19fcbb Mon Sep 17 00:00:00 2001
From: Samuel Merritt <[email protected]>
Date: Thu, 16 Jan 2014 12:45:52 +0000
Subject: Use constant time comparison in tempURL

Use constant time comparison when evaluating tempURL to avoid timing
attacks (CVE-2014-0006). This is the grizzly backport of the master
patch.

Fixes bug 1265665

Change-Id: I11e4ad83cc4077e52adf54a0bd0f9749294b2a48
---
diff --git a/swift/common/middleware/tempurl.py b/swift/common/middleware/tempurl.py
index 5a05de7..8a2517e 100644
--- a/swift/common/middleware/tempurl.py
+++ b/swift/common/middleware/tempurl.py
@@ -98,6 +98,7 @@ from urlparse import parse_qs
 
 from swift.common.wsgi import make_pre_authed_env
 from swift.common.http import HTTP_UNAUTHORIZED
+from swift.common.utils import streq_const_time
 
 
 #: Default headers to remove from incoming requests. Simply a whitespace
@@ -248,14 +249,14 @@ class TempURL(object):
         if env['REQUEST_METHOD'] == 'HEAD':
             hmac_val = self._get_hmac(env, temp_url_expires, key,
                                       request_method='GET')
-            if temp_url_sig != hmac_val:
+            if not streq_const_time(temp_url_sig, hmac_val):
                 hmac_val = self._get_hmac(env, temp_url_expires, key,
                                           request_method='PUT')
-                if temp_url_sig != hmac_val:
+                if not streq_const_time(temp_url_sig, hmac_val):
                     return self._invalid(env, start_response)
         else:
             hmac_val = self._get_hmac(env, temp_url_expires, key)
-            if temp_url_sig != hmac_val:
+            if not streq_const_time(temp_url_sig, hmac_val):
                 return self._invalid(env, start_response)
         self._clean_incoming_headers(env)
         env['swift.authorize'] = lambda req: None