Sanitize path in file_open against suffix

issue6361
review33191002
This commit is contained in:
Cédric Krier
2017-04-03 18:23:41 +02:00
parent 050f2070dd
commit 2d1143fd26
3 changed files with 7 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Sanitize path in file_open against suffix (CVE-2017-0360)
* Add constraint on user password
* Remove Property field
* Add MultiValueMixin and ValueMixin
+5
View File
@@ -134,6 +134,11 @@ class ToolsTestCase(unittest.TestCase):
with self.assertRaisesRegexp(IOError, "Permission denied:"):
file_open('../../foo')
def test_file_open_suffix(self):
"Test file_open from same root name but with a suffix"
with self.assertRaisesRegexp(IOError, "Permission denied:"):
file_open('../trytond_suffix', subdir=None)
def suite():
func = unittest.TestLoader().loadTestsFromTestCase
+1 -1
View File
@@ -32,7 +32,7 @@ def file_open(name, mode="r", subdir='modules', encoding=None):
"Join paths and ensure it still below root"
path = os.path.join(root, *paths)
path = os.path.normpath(path)
if not path.startswith(root):
if not path.startswith(os.path.join(root, '')):
raise IOError("Permission denied: %s" % name)
return path