Skip to content

Conversation

@godlygeek
Copy link
Contributor

@godlygeek godlygeek commented Dec 13, 2024

Switch from a buffer containing Python code to a buffer containing the path to a file containing Python code. This helps to prevent an attacker with arbitrary memory write capabilities inside a running Python process from also gaining arbitrary code execution if they don't already have the ability to write to the file system.

Also, indicate that we will send a new audit event whenever this interface is used, so that any attacker who uses it risks detection.


📚 Documentation preview 📚: https://pep-previews--4169.org.readthedocs.build/

Switch from a buffer containing Python code to a buffer containing the
path to a file containing Python code. This helps to prevent an attacker
with arbitrary memory write capabilities inside a running Python process
from also gaining arbitrary code execution if they don't already have
the ability to write to the file system.

Also, indicate that we will send a new audit event whenever this
interface is used, so that any attacker who uses it risks detection.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek godlygeek requested a review from pablogsal as a code owner December 13, 2024 23:08
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@pablogsal
Copy link
Member

@godlygeek we need to update the "Using a path as the debugger input" to contain the reverse: using a script as the debugger input :)

Signed-off-by: Matt Wozniski <godlygeek@gmail.com>
@godlygeek
Copy link
Contributor Author

Good call, fixed.

Signed-off-by: Matt Wozniski <godlygeek@gmail.com>
@pablogsal pablogsal merged commit f8b3777 into python:main Dec 14, 2024
5 checks passed
@pablogsal
Copy link
Member

CC @zooba After investigating a bit we have switched the design from a buffer holding the code to a buffer holding the path to elevate the security profile of in process threats so an attacker with write memory access doesn't automatically gain execution access.

@zooba
Copy link
Member

zooba commented Dec 16, 2024

Of course I see this comment after I review the other PR and complain about mentioning files 😆

This is a fine change. Make sure in the implementation that open_code is used to read the file (PyOS_OpenCode IIRC? Or maybe there's no C API for it....)

@pablogsal
Copy link
Member

This is a fine change. Make sure in the implementation that open_code is used to read the file (PyOS_OpenCode IIRC? Or maybe there's no C API for it....)

We will figure it out 👍

@pablogsal
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants