Detections · Harmful behavior

Code injection on a Mac: running inside another program

Code injection is malware hiding inside a program you trust. Instead of running as its own app, it gets a trusted app, browser or wallet to load its code, so it inherits that app’s permissions and data, and its activity looks like the app’s own.

Updated November 25, 2026 · 72 detections in this category

In short

Placing code inside another program: loading a library into it, writing its memory, hooking its functions.

MacVigil has 72 detections in this category. It reads the file to find them and never runs it.

What code injection is

Every Mac app loads libraries when it starts and keeps its code in memory while it runs. Injection slips foreign code into that process: a library the app is tricked into loading, a write into its memory, a hook on one of its functions, or a modified copy of the app itself. The attacker gains whatever the host app can do: its camera or Full Disk Access permission, its saved logins, the wallet it manages, the pages it shows.

How Mac malware does it

What MacVigil looks for

MacVigil reads the file and never runs it. For native code, the strongest findings come when one function does the whole sequence: requests a task port, writes into the task’s memory and starts or redirects a thread, with no accountable publisher behind the program. For a script, it follows bytes received from the network to the code archive of a different application.

It also reads how a program loads its libraries: relative paths, writable or temporary search paths, a library signed by another team in a signed program that does not enforce library validation, loader variables imposed in the header or in a launch configuration.

Importing a capability such as task_for_pid or method_exchangeImplementations is recorded as what the program can do, not as proof it injects anything. When the pieces are only separate mentions, MacVigil says so and does not claim they ran.

When it is normal

Debuggers, profilers and instrumentation tools write into other processes by design. Analytics and measurement libraries swizzle methods, and repair tools replace an app’s components. These are usually signed by an identified developer and say what they do.

How to check your Mac

On the blog

Know what a file does before you open it

MacVigil reads any app, disk image, installer or script without running it, and shows the evidence behind every finding. Nothing leaves your Mac.

Download free for Mac

More: all detection categories · what MacVigil detects · the blog