Python usually means CPython, which means C. Most AI-led vulnerabilities lately have been memory mismanagement - what is keeping Python isolated if it is written in C?
A couple of things I can think of: first, the model for interfacing to "compiled code" — both C extensions, and compiled Python bytecode — isn't expected to be secure anyway, and never has been. You can trivially wrap a garbage `bytes` in a `code` object, execute it and get a segfault; and you can trivially use the `ctypes` API to corrupt memory. Second, the normal use paths are well-tested and bottom out in an interpretation layer that isn't very well optimized because of how much dynamic nonsense it has to support (even beyond other languages in its class like Ruby).
On the other hand, the bytecode format tends to change with almost every "minor" release (i.e. annually now). There's probably plenty of room for a mistake in that churn.
A couple of things I can think of: first, the model for interfacing to "compiled code" — both C extensions, and compiled Python bytecode — isn't expected to be secure anyway, and never has been. You can trivially wrap a garbage `bytes` in a `code` object, execute it and get a segfault; and you can trivially use the `ctypes` API to corrupt memory. Second, the normal use paths are well-tested and bottom out in an interpretation layer that isn't very well optimized because of how much dynamic nonsense it has to support (even beyond other languages in its class like Ruby).
On the other hand, the bytecode format tends to change with almost every "minor" release (i.e. annually now). There's probably plenty of room for a mistake in that churn.