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
- Library hijacking: placing a library where an app looks for it, through a relative path, a search path in a temporary, shared or
Resourcesfolder, a weak optional load, or a proxy that re-exports the original. - Loader variables such as
DYLD_INSERT_LIBRARIES, set in a launch agent, in an app’sInfo.plistor in the environment of a program it starts. - Writing into another process:
task_for_pidto get access,mach_vm_writeto place code, then starting or redirecting a thread to run it, or spawning a process suspended and rewriting its stack before resuming it. - Hooking functions and Objective-C methods with swizzling, interposition or hooking frameworks, sometimes aimed at security, credential or signature checks.
- Replacing an installed app’s code: writing over an Electron app’s
app.asararchive, or modifying a bundle in/Applicationsand re-signing it ad hoc. - Infecting a program file itself, for example diverting its entry point into the normally empty
__PAGEZEROsegment. - Browser extensions that inject scripts into every page, or strip security headers so pages accept outside code.
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
- Install apps from the Mac App Store or the developer’s own site, never “cracked” or patched copies, which often carry injected libraries.
- Check an app’s signature with
codesign -dv --verbose=4 /Applications/AppName.appand verify it is intact withcodesign --verify --deep --strict. - Look in
~/Library/LaunchAgentsand/Library/LaunchAgentsfor.plistfiles that setDYLD_INSERT_LIBRARIES. - Review your browser extensions and remove any you did not install on purpose.
- If a wallet or banking app was replaced or asks for your recovery phrase after an update, stop and reinstall it from its official source.
Related categories
- Runtime code loading: Code the program loads or makes while it runs: libraries opened by name, functions looked up with dlsym, memory made executable, program images built from a buffer. Browsers, plug-in hosts and JIT engines all do this.
- Masquerading: A file that presents itself as something else: a misleading name, icon or extension, a label imitating Apple.
- Privacy-permission bypass: Camera, microphone, screen and protected folders sit behind permission prompts; this is what touches those permissions.
- Credential theft: What touches the places where passwords, keys and sessions are kept: keychains, browser profiles, wallets, SSH and cloud credentials.
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.
Free for 7 days, then $29.95 a year for 2 Macs, a launch price: the regular price will be $59 a year. Requires macOS 15 Sequoia or later on a Mac with Apple silicon.
More: all detection categories · what MacVigil detects · the blog