This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: audioop.lin2adpcm Buffer Over-read
Type: security Stage: resolved
Components: Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: audioop.adpcm2lin Buffer Over-read
View: 24456
Assigned To: serhiy.storchaka Nosy List: Arfrever, JohnLeitch, serhiy.storchaka
Priority: normal Keywords:

Created on 2015-06-15 20:58 by JohnLeitch, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit JohnLeitch, 2015-06-15 20:58
Messages (2)
msg245408 - (view) Author: John Leitch (JohnLeitch) * Date: 2015-06-15 20:58
The audioop.lin2adpcm function suffers from a buffer over-read caused by unchecked access to stepsizeTable at line 1436 of Modules\audioop.c:

    } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
        return 0;

    step = stepsizeTable[index];
Because the index variable can be controlled via the third parameter of audioop.lin2adpcm, this behavior could potentially be exploited to disclose arbitrary memory, should an application expose the parameter to the attack surface.

0:000> r
eax=00000001 ebx=00000001 ecx=2fd921bb edx=00000002 esi=00000001 edi=01e79160
eip=1e01c286 esp=0027fcdc ebp=df531970 iopl=0         nv up ei pl nz na po nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010202
1e01c286 8b34adb0dd1f1e  mov     esi,dword ptr python27!stepsizeTable (1e1fddb0)[ebp*4] ss:002b:9b6c4370=????????
0:000> k
ChildEBP RetAddr
0027fd18 1e0aafd7 python27!audioop_lin2adpcm+0xd6
0027fd30 1e0edd10 python27!PyCFunction_Call+0x47
0027fd5c 1e0f017a python27!call_function+0x2b0
0027fdcc 1e0f1150 python27!PyEval_EvalFrameEx+0x239a
0027fe00 1e0f11b2 python27!PyEval_EvalCodeEx+0x690
0027fe2c 1e11707a python27!PyEval_EvalCode+0x22
0027fe44 1e1181c5 python27!run_mod+0x2a
0027fe64 1e118760 python27!PyRun_FileExFlags+0x75
0027fea4 1e1190d9 python27!PyRun_SimpleFileExFlags+0x190
0027fec0 1e038d35 python27!PyRun_AnyFileExFlags+0x59
0027ff3c 1d00116d python27!Py_Main+0x965
0027ff80 76477c04 python!__tmainCRTStartup+0x10f
0027ff94 7799ad1f KERNEL32!BaseThreadInitThunk+0x24
0027ffdc 7799acea ntdll!__RtlUserThreadStart+0x2f
0027ffec 00000000 ntdll!_RtlUserThreadStart+0x1b

To fix this issue, it is recommended that bounds checking be performed prior to accessing stepsizeTable.
msg245851 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-06-26 12:56
The patch for issue24456 fixes this issue.
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68645
2015-07-05 21:13:46Arfreversetnosy: + Arfrever
2015-06-26 12:56:36serhiy.storchakasetstatus: open -> closed
superseder: audioop.adpcm2lin Buffer Over-read
messages: + msg245851

resolution: duplicate
stage: needs patch -> resolved
2015-06-26 09:11:05serhiy.storchakasetstage: needs patch
versions: + Python 3.4, Python 3.5, Python 3.6
2015-06-16 13:41:31serhiy.storchakasetassignee: serhiy.storchaka

nosy: + serhiy.storchaka
2015-06-15 20:58:26JohnLeitchcreate