Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
74eb8b2d
Commit
74eb8b2d
authored
Feb 16, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #22885: Fixed arbitrary code execution vulnerability in the dbm.dumb
module. Original patch by Claudiu Popa.
parent
57fffd6f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
Lib/dbm/dumb.py
Lib/dbm/dumb.py
+2
-1
Lib/test/test_dbm_dumb.py
Lib/test/test_dbm_dumb.py
+9
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/dbm/dumb.py
View file @
74eb8b2d
...
...
@@ -21,6 +21,7 @@ is read when the database is opened, and some updates rewrite the whole index)
"""
import
ast
as
_ast
import
io
as
_io
import
os
as
_os
import
collections
...
...
@@ -85,7 +86,7 @@ class _Database(collections.MutableMapping):
with
f
:
for
line
in
f
:
line
=
line
.
rstrip
()
key
,
pos_and_siz_pair
=
eval
(
line
)
key
,
pos_and_siz_pair
=
_ast
.
literal_
eval
(
line
)
key
=
key
.
encode
(
'Latin-1'
)
self
.
_index
[
key
]
=
pos_and_siz_pair
...
...
Lib/test/test_dbm_dumb.py
View file @
74eb8b2d
...
...
@@ -217,6 +217,15 @@ class DumbDBMTestCase(unittest.TestCase):
self
.
assertEqual
(
str
(
cm
.
exception
),
"DBM object has already been closed"
)
def
test_eval
(
self
):
with
open
(
_fname
+
'.dir'
,
'w'
)
as
stream
:
stream
.
write
(
"str(print('Hacked!')), 0
\
n
"
)
with
support
.
captured_stdout
()
as
stdout
:
with
self
.
assertRaises
(
ValueError
):
with
dumbdbm
.
open
(
_fname
)
as
f
:
pass
self
.
assertEqual
(
stdout
.
getvalue
(),
''
)
def
tearDown
(
self
):
_delete_files
()
...
...
Misc/NEWS
View file @
74eb8b2d
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- Issue #22885: Fixed arbitrary code execution vulnerability in the dbm.dumb
module. Original patch by Claudiu Popa.
- Issue #23146: Fix mishandling of absolute Windows paths with forward
slashes in pathlib.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment