r/learnpython • • Jul 20 '24

In light of recent events…

I am not a professional python dev, but always learning. Busy on my own flask-based project at the moment. Thoroughly enjoying it.

By the CrowdStrike error, and utter vulnerability has made me ponder how much power a language like Python has.

Don’t get me wrong, I’m totally aware that Python is used extensively in cybersecurity, but I’ve never heard of Python being able to cause a BSOD / Kernel Panic. Am I wrong here?

My understanding from ready the current speculation is that CrowdStrike offers a anti-malware solution, primarily to large corporates and governments. The issue was with a content update which seemed (and here’s where the speculation starts) to be a corrupt signature / content file, and when the system tried to load the content, it wasn’t there. There was an attempt to access a dereferenced null pointer (per some) or load a page of content that wasn’t in the update file (per others).

One comment I read is that as an antimalware program, it plays around in Kernel space, rather than in user space.

Are there examples of Python playing in Kernel space? Is this possible? Is it even possible to force a BSOD or Kernel Panic in Python?

1 Upvotes

6 comments sorted by

15

u/CatalonianBookseller Jul 20 '24

never heard of Python being able to cause a BSOD / Kernel Panic. Am I wrong here?

Python has access to the Windows API so you can do all kinds of things if your user account has the right privileges.

5

u/[deleted] Jul 20 '24 edited Jul 20 '24

Python itself is a user-space application, so it can't operate directly in the OS kernel space, but that doesn't really mean much in itself because Python can access external/foreign functions, which can.

So, while it probably isn't likely that you would write ninja code that breaks 800 million computers purely in Python, chances are whatever this code is written in is a hybrid of languages as well. They probably access low-level stuff in small, bespoke tools that do specific kernel tasks and then orchestrate them together in a better language for humans.

edit: for educational purposes -

https://www.youtube.com/watch?v=mEpfUM0zUgg

3

u/JohnnyJordaan Jul 20 '24

Maybe it helps to read up on https://en.wikipedia.org/wiki/User_space_and_kernel_space. Kernel space is just the kernel, it wouldn't run a regular program let alone a full blown interpreter like Python. You can 'plug in' modular components into the kernel, like 'drivers' or 'modules', and it seems it was one of these from the CrowdStrike environment that caused the issue (as the workaround was to remove a certain .sys file from one of the %sysroot%/drivers folders). Not unlike how buggy drivers could crash your system back in the day with Windows 9x/Me, and I seem to recall a similar issue a while back when a common antivirus program, if I'm not mistaken it was AVG Free. But the effects of a boot crash by an obvious end user / retail product are of course vastly different from one targeted at businesses.

That doesn't mean that if you allow it, Python could wreak havoc or potentially crash your system, but that would entail quite some work/hacking and certainly isn't expected from ordinary use (as then you get the well known 'Python.exe terminated unexpectedly' or similar).

3

u/Taltalonix Jul 20 '24

Most people talk about kernel space are correct. That said, any programming language can trigger any function that may cause this BSOD.

For example if you have a driver that interacts with your screen memory and you access it from a python script passing an argument, the cause is the driver but technically you initiated the crash.

3

u/JamzTyson Jul 20 '24

By the CrowdStrike error, and utter vulnerability has made me ponder how much power a language like Python has.

The ability to cause kernel space errors is unrelated to the power of a language. Most applications run in user mode, regardless of the language they are written in, and Windows implements multiple layers of protection to prevent applications from directly accessing kernel space.

1

u/shiftybyte Jul 20 '24

I'm not aware of ways to execute python in the kernel.

Not sure why you'd want to cause errors and issues, and judging a programming language's "strength" by how much damage it can cause when someone writes bad code.

It's like judging a transportation vehicle by how many people get killed when it fails...

We'd be flying volatile blimps... https://en.wikipedia.org/wiki/Hindenburg_disaster

But why are we driving cars man? it's not as powerful as an exploding airship....