PyInstaller Malware on macOS: A New Threat

May 11, 2025

A Python in Disguise: PyInstaller Malware Targets macOS

By Peter Hallen

In May 2025, Jamf Threat Labs revealed a new technique used by attackers to deploy infostealer malware on macOS: leveraging PyInstaller to bundle malicious Python code into Mach-O executables. This marks the first time such a method has been observed in the wild for macOS infostealers, signaling a new chapter in the ongoing arms race between attackers and defenders on Apple platforms.

"Attackers are using PyInstallers to deploy infostealers on macOS. Jamf Threat Labs investigates this newly discovered technique."
— Jamf Threat Labs, May 12, 2025

What is PyInstaller and Why Does It Matter?

PyInstaller is a legitimate open-source tool that allows developers to package Python scripts into standalone binaries. This is especially useful on modern macOS systems, where Apple has removed the system-installed Python interpreter. However, this convenience is now being abused by threat actors to deliver malware that runs seamlessly on both Intel and Apple Silicon Macs—without requiring Python to be installed.

Anatomy of the Attack

Jamf's analysis began with a suspicious Mach-O binary named stl found on VirusTotal. The malware exhibited classic infostealer behaviors, such as:

Static analysis revealed that the binary was ad-hoc signed and contained clear indicators of PyInstaller packaging. The Mach-O executable, when run, extracts a temporary directory containing Python bytecode and libraries, then launches the embedded Python interpreter to execute the malicious logic.

Dynamic Analysis and Payload Extraction

Upon execution, the malware unpacks its payload into a temporary directory and begins its data collection activities. Notably, the malware:

To analyze the malware further, Jamf used open-source tools like Pyinstxtractor and PyLingual to extract and decompile the embedded Python bytecode. The code was heavily obfuscated using string reversal, base85 encoding, XOR encryption, and zlib compression, but ultimately revealed its true infostealer nature.

Why This Matters

This campaign demonstrates how attackers are adapting to platform changes (like the removal of system Python) and using legitimate tools for malicious purposes. By packaging malware with PyInstaller, they can evade some traditional detection mechanisms and ensure compatibility across macOS architectures.

Defensive Recommendations

Conclusion

As macOS becomes a more attractive target, attackers will continue to innovate. The use of PyInstaller to deliver infostealers is a reminder that defenders must remain vigilant and adapt to new techniques as they emerge.

For a detailed technical breakdown, read the full article by Jamf Threat Labs:
https://www.jamf.com/blog/pyinstaller-malware-jamf-threat-labs/?utm_source=tldrinfosec

macOS, malware, PyInstaller, infostealer, security, Jamf