CVE-2007-2052: Medium severity Python Software Foundation Python vulnerability
Description of problem:
Modules/localemodule.c:361 356 n1 = strlen(s) + 1; 357 buf = PyMemMalloc(n1); 358 if (!buf) 359 return PyErrNoMemory(); 360 n2 = strxfrm(buf, s, n1);
In case the transformed string is longer than original string... (see the PoC for an exapmle)
361 if (n2 > n1) { 362 / more space needed /
We allocate n2 bytes here:
363 buf = PyMemRealloc(buf, n2); 364 if (!buf) 365 return PyErrNoMemory();
And here the string will be n2 chars long and terminating NUL won't fit and thus the string won't be terminated what can lead to an information leak in certain rare cases (see the original Debian report for details).
366 strxfrm(buf, s, n2); 367 } 368 result = PyStringFromString(buf); 369 PyMemFree(buf); 370 return result; 371 } 372 373 #if defined(MSWINDOWS) 374 static PyObject 375 PyLocalegetdefaultlocale(PyObject self)
Version-Release number of selected component (if applicable):
FC5, FC6, RHEL2.1, RHEL3, RHEL4, RHEL5
How reproducible:
Proof of concept code attached.
Additional info:
See the URL for an original bug report to Debian and PoC by Piotr Engelking. It contains details on how to reproduce and recognize the flaw.
Other sources
Off-by-one error in the PyLocalestrxfrm function in Modules/localemodule.c for Python 2.4 and 2.5 causes an incorrect buffer size to be used for the strxfrm function, which allows context-dependent attackers to read portions of memory via unknown manipulations that trigger a buffer over-read due to missing null termination.
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2007-2052?
CVE-2007-2052 is considered to have a medium severity rating due to its potential for memory reading attacks.
How do I fix CVE-2007-2052?
To fix CVE-2007-2052, upgrade to Python version 2.6 or later as these versions contain the necessary patches.
Which versions of Python are affected by CVE-2007-2052?
CVE-2007-2052 affects Python versions 2.4.0 and 2.5.0.
What type of vulnerability is CVE-2007-2052?
CVE-2007-2052 is classified as a buffer over-read vulnerability caused by an off-by-one error.
Can CVE-2007-2052 be exploited remotely?
Yes, CVE-2007-2052 can be exploited remotely by attackers through context-dependent methods.