GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing python-security.readthedocs.io — Python Security — Python Security 0.0 documentation Python Security¶Python Security model¶Python doesn’t implement privilege separation (not “inside” Python) to reduce the attack surface of Python. Once an attacker is able the execute arbitrary Python code, the attacker basically gets a full access to the system. Privilege separation can be implemented “outside” Python by putting Python inside a sandbox. Example with bpo-36506 (closed as not a
bug): Bytecode¶CPython doesn’t verify that bytecode is safe. If an attacker is able to execute arbitrary bytecode, we consider that the security of the bytecode is the least important issue: using bytecode, sensitive code can be imported and executed. For example, the Sandbox¶Don’t try to build a sandbox inside CPython. The attack surface is too large.
Python has many introspection features, see for example the
The good design is to put CPython into a sandbox, not the opposite. Ok, understood, but I want a sandbox in Python. Well…
Dangerous functions and modules¶
Archives and absolute paths¶
Archives and Zip Bomb (CVE-2019-9674)¶Be careful of “Zip Bombs”: a very small archive can use a huge amount of memory and disk space once decompressed. The zlib module allows to limit the maximum length: https://docs.python.org/dev/library/zlib.html#zlib.Decompress.decompress For example, the OpenStack Nova was vulnerable of denial of service if a compressed virtual machine was a Zip Bomb: OSSA 2016-012 and CVE-2015-5162.
Nova has been fixed using the See: Shell command injection¶See https://www.owasp.org/index.php/Command_Injection Whenever possible, avoid For Windows, see:
RNG¶
The CPython Security Experts¶
Windows¶ASLR and DEP¶ASLR and DEP protections enabled since Python 3.4 (and Python 2.7.11 if built
using Unsafe Python 2.7 default installation directory¶Python 2.7 installer uses DLL injection¶On Windows 8.1 and older, the installer is vulnerable to DLL injection: evil DLL written in the same download directory that the downloaded Python installer. See DLL Hijacking Just Won’t Die. DLL injection using PATH¶Inject a malicious DLL in a writable directory included in PATH. The “pip” step of the Python installer will run this DLL. We consider that it is not an issue of Python (Python installer) itself. Once you have write access to a directory on the system PATH (not the current user PATH) and the ability to write binaries that are not validated by the operating system before loading, there are many more interesting things you can do rather than wait for the Python installer to be run. Module Search Path (sys.path)¶
Static analysers of CPython code base¶Fuzzing¶
Misc¶
Python Security Response Team (PSRT)¶
Links¶
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |