Python interpreter binary is not compiled as PIE
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python |
Fix Released
|
Unknown
|
|||
python2.7 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
python3.10 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
python3.4 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
python3.6 (Ubuntu) |
Won't Fix
|
Undecided
|
Ubuntu Security Team | ||
python3.7 (Debian) |
Fix Released
|
Unknown
|
|||
python3.7 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned | ||
python3.8 (Debian) |
New
|
Undecided
|
Unassigned | ||
python3.8 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned | ||
python3.9 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
The python2.7 binary (installed at /usr/bin/python2.7; package version 2.7.6-8) is not compiled as a position independent executable (PIE). It appears that the python compilation process is somewhat arcane and the hardening wrapper probably doesn't do the trick for it.
This is incredibly dangerous as it means that any vulnerability within a native module (e.g. ctypes-based), or within python itself will expose an incredibly large amount of known memory contents at known addresses (including a large number of dangerous instruction groupings). This enables ROP-based (https:/
I have put together an example vulnerable C shared object (with a buffer overflow) accessed via python through the ctypes interface as an example. This uses a single ROP "gadget" on top of using the known PLT location for system(3) (https:/
- https:/
I'm not exactly familiar enough with the python build process to say where exactly an -fPIE needs to be injected into a script/makefile, but I feel that given the perceived general preference for ctypes-based modules over python written ones, as the native code implementations tend to be more performant, this feels like a large security hole within the system. Given the nature of this "issue," I'm not 100% sure of where it is best reported, but from what I can tell, this conflicts with the Ubuntu hardening features and is definitely exploitable should a native module contain a sufficiently exploitable vulnerability that allows for control of the instruction register.
Changed in python2.7 (Ubuntu): | |
status: | New → Won't Fix |
Changed in python3.4 (Ubuntu): | |
status: | New → Confirmed |
Changed in python2.7 (Ubuntu): | |
status: | Won't Fix → Confirmed |
information type: | Private Security → Public Security |
Changed in python3.6 (Ubuntu): | |
assignee: | nobody → Ubuntu Security Team (ubuntu-security) |
Changed in python: | |
status: | Unknown → New |
Changed in python3.7 (Ubuntu): | |
status: | New → Confirmed |
Changed in python3.7 (Debian): | |
status: | Unknown → New |
Changed in python3.10 (Ubuntu): | |
status: | New → Fix Committed |
Changed in python: | |
status: | New → Fix Released |
Changed in python3.7 (Debian): | |
status: | New → Fix Released |
I should also add that python3.4 (3.4.0-2ubuntu1 ; /usr/bin/python3.4) also has the same issue. And this was only tested under 14.04 (I would assume that it also affects every other currently supported version, but don't have the space for VMs to check :( , sorry).
Sorry about the lack of that info upfront.