~ubuntu-branches/ubuntu/oneiric/nova/oneiric-updates

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2012-3447.patch

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2012-08-17 13:55:33 UTC
  • Revision ID: package-import@ubuntu.com-20120817135533-987ztcloeqahiv01
Tags: 2011.3-0ubuntu6.10
* SECURITY UPDATE: Prohibit file injection writing to host filesystem
  - debian/patches/CVE-2012-3447.patch: update to perform the file name
    canonicalization as the root user
  - CVE-2012-3447

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Origin: https://review.openstack.org/gitweb?p=openstack%2Fnova.git;a=commitdiff;h=ed89587d525e0214cb367aa4632df45903c6ac09
 
2
Description: This is a refinement of the previous fix in commit 2427d4a,
 
3
 which does the file name canonicalization as the root user.
 
4
 This is required so that guest images could not for example,
 
5
 protect malicious symlinks in a directory only readable by root.
 
6
Bug: https://launchpad.net/bugs/1031311
 
7
 
 
8
Index: nova-2011.3/nova/tests/test_virt.py
 
9
===================================================================
 
10
--- nova-2011.3.orig/nova/tests/test_virt.py    2012-08-17 13:54:13.000000000 -0500
 
11
+++ nova-2011.3/nova/tests/test_virt.py 2012-08-17 13:54:27.000000000 -0500
 
12
@@ -18,6 +18,7 @@
 
13
 from nova import exception
 
14
 from nova import flags
 
15
 from nova import test
 
16
+from nova import utils
 
17
 from nova.virt import disk
 
18
 from nova.virt import driver
 
19
 
 
20
@@ -86,6 +87,17 @@
 
21
 
 
22
 
 
23
 class TestVirtDisk(test.TestCase):
 
24
+    def setUp(self):
 
25
+        super(TestVirtDisk, self).setUp()
 
26
+
 
27
+        real_execute = utils.execute
 
28
+
 
29
+        def nonroot_execute(*cmd_parts, **kwargs):
 
30
+            kwargs.pop('run_as_root', None)
 
31
+            return real_execute(*cmd_parts, **kwargs)
 
32
+
 
33
+        self.stubs.Set(utils, 'execute', nonroot_execute)
 
34
+
 
35
     def test_check_safe_path(self):
 
36
         ret = disk._join_and_check_path_within_fs('/foo', 'etc',
 
37
                                                       'something.conf')
 
38
Index: nova-2011.3/nova/tests/test_xenapi.py
 
39
===================================================================
 
40
--- nova-2011.3.orig/nova/tests/test_xenapi.py  2012-08-17 13:54:00.000000000 -0500
 
41
+++ nova-2011.3/nova/tests/test_xenapi.py       2012-08-17 13:54:27.000000000 -0500
 
42
@@ -517,9 +517,13 @@
 
43
             self._tee_executed = True
 
44
             return '', ''
 
45
 
 
46
+        def _readlink_handler(cmd_parts, **kwargs):
 
47
+            return os.path.realpath(cmd_parts[2]), ''
 
48
+
 
49
         fake_utils.fake_execute_set_repliers([
 
50
             # Capture the tee .../etc/network/interfaces command
 
51
             (r'tee.*interfaces', _tee_handler),
 
52
+            (r'readlink -nm.*', _readlink_handler),
 
53
         ])
 
54
         self._test_spawn(glance_stubs.FakeGlance.IMAGE_MACHINE,
 
55
                          glance_stubs.FakeGlance.IMAGE_KERNEL,
 
56
Index: nova-2011.3/nova/virt/disk.py
 
57
===================================================================
 
58
--- nova-2011.3.orig/nova/virt/disk.py  2012-08-17 13:54:13.000000000 -0500
 
59
+++ nova-2011.3/nova/virt/disk.py       2012-08-17 13:54:27.000000000 -0500
 
60
@@ -275,7 +275,9 @@
 
61
     mounted guest fs.  Trying to be clever and specifying a
 
62
     path with '..' in it will hit this safeguard.
 
63
     '''
 
64
-    absolute_path = os.path.realpath(os.path.join(fs, *args))
 
65
+    absolute_path, _err = utils.execute('readlink', '-nm',
 
66
+                                        os.path.join(fs, *args),
 
67
+                                        run_as_root=True)
 
68
     if not absolute_path.startswith(os.path.realpath(fs) + '/'):
 
69
         raise exception.Invalid()
 
70
     return absolute_path