Repository navigation
Closed
Labels
3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertype-securityA security issue
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2012-03-13.22:25:45.919>
created_at = <Date 2012-01-03.19:36:49.855>
labels = ['type-security', 'interpreter-core', 'release-blocker', '3.11']
title = 'Hash collision security issue'
updated_at = <Date 2021-11-08.16:57:10.080>
user = 'https://github.com/warsaw'bugs.python.org fields:
activity = <Date 2021-11-08.16:57:10.080>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2012-03-13.22:25:45.919>
closer = 'gregory.p.smith'
components = ['Interpreter Core']
creation = <Date 2012-01-03.19:36:49.855>
creator = 'barry'
dependencies = ['13704']
files = ['24151', '24169', '24223', '24259', '24286', '24288', '24289', '24295', '24299', '24300', '24304', '24320', '24324', '24343', '24353', '24365', '24366', '24370', '24371', '24375', '24385', '24391', '24392', '24393', '24394', '24434', '24435', '24436', '24437', '24490', '24491', '24514', '24515', '24563']
hgrepos = []
issue_num = 13703
keywords = ['patch']
message_count = 328.0
messages = ['150522', '150525', '150526', '150529', '150531', '150532', '150533', '150534', '150541', '150543', '150558', '150559', '150560', '150562', '150563', '150565', '150568', '150569', '150570', '150577', '150589', '150592', '150601', '150609', '150613', '150616', '150619', '150620', '150621', '150622', '150625', '150634', '150635', '150636', '150637', '150638', '150639', '150641', '150642', '150643', '150644', '150645', '150646', '150647', '150648', '150649', '150650', '150651', '150652', '150655', '150656', '150659', '150662', '150665', '150668', '150694', '150699', '150702', '150706', '150707', '150708', '150712', '150713', '150718', '150719', '150724', '150725', '150726', '150727', '150738', '150748', '150756', '150766', '150768', '150769', '150771', '150795', '150829', '150832', '150835', '150836', '150840', '150847', '150856', '150857', '150859', '150865', '150866', '150934', '151012', '151017', '151031', '151033', '151047', '151048', '151061', '151062', '151063', '151064', '151065', '151069', '151070', '151071', '151073', '151074', '151078', '151092', '151120', '151121', '151122', '151157', '151158', '151159', '151167', '151353', '151401', '151402', '151419', '151422', '151448', '151449', '151468', '151472', '151474', '151484', '151519', '151528', '151560', '151561', '151565', '151566', '151567', '151574', '151582', '151583', '151584', '151585', '151586', '151589', '151590', '151596', '151604', '151617', '151620', '151625', '151626', '151628', '151629', '151632', '151633', '151647', '151662', '151664', '151677', '151679', '151680', '151681', '151682', '151684', '151685', '151689', '151691', '151699', '151700', '151701', '151703', '151707', '151714', '151731', '151734', '151735', '151737', '151739', '151744', '151745', '151747', '151748', '151753', '151754', '151756', '151758', '151794', '151796', '151798', '151812', '151813', '151814', '151815', '151825', '151826', '151847', '151850', '151867', '151869', '151870', '151939', '151941', '151942', '151944', '151956', '151959', '151960', '151961', '151965', '151966', '151967', '151970', '151973', '151977', '151984', '152030', '152033', '152037', '152039', '152040', '152041', '152043', '152046', '152051', '152057', '152060', '152066', '152070', '152104', '152112', '152117', '152118', '152125', '152146', '152149', '152183', '152186', '152199', '152200', '152203', '152204', '152270', '152271', '152275', '152276', '152299', '152300', '152309', '152311', '152315', '152335', '152344', '152352', '152362', '152364', '152422', '152452', '152453', '152723', '152730', '152731', '152732', '152734', '152740', '152747', '152753', '152754', '152755', '152758', '152760', '152763', '152764', '152767', '152768', '152769', '152777', '152780', '152781', '152784', '152787', '152789', '152797', '152811', '152855', '153055', '153074', '153081', '153082', '153140', '153141', '153143', '153144', '153297', '153301', '153369', '153395', '153682', '153683', '153690', '153695', '153750', '153753', '153798', '153802', '153817', '153833', '153848', '153849', '153850', '153852', '153853', '153854', '153860', '153861', '153862', '153868', '153872', '153873', '153877', '153975', '153980', '154428', '154430', '154432', '154853', '155293', '155472', '155527', '155680', '155681', '155682', '405727', '405745']
nosy_count = 36.0
nosy_names = ['lemburg', 'gvanrossum', 'tim.peters', 'loewis', 'barry', 'georg.brandl', 'terry.reedy', 'gregory.p.smith', 'jcea', 'mark.dickinson', 'pitrou', 'christian.heimes', 'benjamin.peterson', 'roger.serwy', 'eric.araujo', 'grahamd', 'Arfrever', 'v+python', 'alex', 'cvrebert', 'zbysz', 'skrah', 'dmalcolm', 'gz', 'neologix', 'Arach', 'Mark.Shannon', 'python-dev', 'eric.snow', 'Zhiping.Deng', 'Huzaifa.Sidhpurwala', 'Jim.Jewett', 'PaulMcMillan', 'fx5', 'skorgu', 'jsvaughan']
pr_nums = []
priority = 'release blocker'
resolution = 'fixed'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'security'
url = 'https://bugs.python.org/issue13703'
versions = ['Python 3.11']Metadata
Metadata
Assignees
Labels
3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertype-securityA security issue
Activity
warsaw commentedon Jan 3, 2012
This is already publicly known and in deep discussion on python-dev. The proper fix is still TBD. Essentially, hash collisions can be exploited to DoS a web framework that automatically parses input forms into dictionaries.
Start here:
http://mail.python.org/pipermail/python-dev/2011-December/115116.html
tiran commentedon Jan 3, 2012
I had a short chat with Guido yesterday. I'll try to sum up the conversation. Guido, please correct me if I got something wrong or missed a point.
Guido wants the fix as simple and less intrusive as possible as he wants to provide/apply a patch for Python 2.4 to 3.3. This means any new stuff is off the table unless it's really, really necessary. Say goodbye to my experimental MurmurHash3 patch.
We haven't agreed whether the randomization should be enabled by default or disabled by default. IMHO it should be disabled for all releases except for the upcoming 3.3 release. The env var PYTHONRANDOMHASH=1 would enable the randomization. It's simple to set the env var in e.g. Apache for mod_python and mod_wsgi.
pitrou commentedon Jan 3, 2012
I think on the contrary it must be enabled by default. Leaving security
holes open is wrong.
tiran commentedon Jan 3, 2012
We can't foresee the implications of the randomization and only a small number of deployments is affected by the problem. But I won't start a fight on the matter. ;)
gvanrossum commentedon Jan 3, 2012
I'm with Antoine -- turn it on by default. Maybe there should be a release candidate to test the waters.
warsaw commentedon Jan 3, 2012
On Jan 03, 2012, at 08:24 PM, Antoine Pitrou wrote:
Unless there's evidence of performance regressions or backward
incompatibilities, I agree.
vstinner commentedon Jan 3, 2012
If hash() is modified, str(dict) and str(set) will change for example. It may break doctests. Can we consider that the application should not rely (indirectly) on hash and so fix (for example) their doctests? Or is it a backward incompatibility?
hash() was already modified in major Python versions.
For this specific issue, I consider that security is more important than str(dict).
benjaminp commentedon Jan 3, 2012
Barry, when this gets fixed, shall we coordinate release times?
warsaw commentedon Jan 3, 2012
On Jan 03, 2012, at 09:43 PM, Benjamin Peterson wrote:
Yes!
tiran commentedon Jan 3, 2012
Randomized hashing destabilizes the unit tests of Python, too. Here are the outputs of four test runs:
11 tests failed:
test_collections test_dbm test_dis test_gdb test_inspect
test_packaging test_set test_symtable test_ttk_textonly
test_urllib test_urlparse
9 tests failed:
test_dbm test_dis test_gdb test_json test_packaging test_set
test_symtable test_urllib test_urlparse
10 tests failed:
test_dbm test_dis test_gdb test_inspect test_packaging test_set
test_symtable test_ttk_textonly test_urllib test_urlparse
9 tests failed:
test_collections test_dbm test_dict test_dis test_gdb
test_packaging test_symtable test_urllib test_urlparse
PaulMcMillan commentedon Jan 3, 2012
I agree that we should enable randomness by default, and provide an easy way for users to disable it if necessary (unit test suites that explicitly depend on order being an obvious candidate).
I'll link my proposed algorithm change here, for the record:
https://gist.github.com/0a91e52efa74f61858b5
I've gotten confirmation from several other sources that the fix recommended by the presenters (just a random initialization seed) only prevents the most basic form of the attack.
vstinner commentedon Jan 4, 2012
Christian Heimes proposes the following change in its randomhash branch (see issue bpo-13704):
This change doesn't add any security if the attacker can inject any string and retreive the hash value. You can retreive directly Py_RndHashSeed using:
where intmask() truncates to a long (x mod 2^(long bits)) and DIVIDE = 1/1000003 mod 2^(long bits). For example, DIVIDE=2021759595 for 32 bits long.
306 remaining items
serwy commentedon Feb 27, 2012
It was a false alarm. I didn't recompile python before running it with the latest /Lib files. My apologies.
cvrebert commentedon Mar 3, 2012
The Design and History FAQ (will) need a minor corresponding update:
http://docs.python.org/dev/faq/design.html#how-are-dictionaries-implemented
kseifriedredhatcom commentedon Mar 10, 2012
I have assigned CVE-2012-1150 for this issue as per http://www.openwall.com/lists/oss-security/2012/03/10/3
jsvaughan commentedon Mar 12, 2012
FWIW I upgraded to ubuntu pangolin beta over the weekend, which includes 2.7.3rc1, and I'm also experiencing a problem with urandom.
File "/usr/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "/usr/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom
Given Roger Serwy's comment it sounds like a beta ubuntu problem, but thought it worth mentioning.
vstinner commentedon Mar 12, 2012
It looks like you are using random.py of Python 2.7.3 with the Python program 2.7.2, because os.urandom() is now always available in Python 2.7.3.
jsvaughan commentedon Mar 13, 2012
Victor - yes that was it; a mixture of a 2.7.2 virtual env and 2.7.3. Apologies for any nuisance caused.
vstinner commentedon Mar 13, 2012
Can we close this issue?
gpshead commentedon Mar 13, 2012
I believe so. This is in all of the release candidates.
The expat/xmlparse.c hash collision DoS issue is being handled on its own via http://bugs.python.org/issue14234.
gvanrossum commentedon Nov 4, 2021
Hey Erlend, why did you add so many people to the nosy list of this old
issue?
On Thu, Nov 4, 2021 at 07:33 Erlend E. Aasland <report@bugs.python.org>
wrote:
--
--Guido (mobile)
terryjreedy commentedon Nov 4, 2021
Because today's spammer, whose message was removed, deleted us all. Restoring the version to 3.3 is not possible.