Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 8 min read

How to identify malware in Activity Monitor on a Mac

You can't identify malware in Activity Monitor by its name. Most cryptic names there (rapportd, trustd, mds_stores, corespeechd) are macOS daemons, and real malware often picks a dull, plausible name on purpose. What giv

How to identify malware in Activity Monitor on a Mac

You can't identify malware in Activity Monitor by its name. Most cryptic names there (rapportd, trustd, mds_stores, corespeechd) are macOS daemons, and real malware often picks a dull, plausible name on purpose. What gives it away is everything around the name: where the executable lives, who signed it, what keeps restarting it, how much CPU it uses when you're not doing anything, and where it connects.

All of that can be checked in a few minutes with Activity Monitor and four Terminal commands: the process's path from Open Files and Ports, its signature with codesign and spctl, the launch agents in three folders, and its network connections with lsof. If the binary is signed by Apple or a known developer, lives where its app lives, and was installed by something you recognise, it's almost certainly fine.

I build Stat Space, a system monitor, so I read a lot of process lists. Below is the order I check things in, with real output from my Mac so you know what normal looks like.

Most odd names are macOS

Activity Monitor shows a few hundred processes on an idle Mac, and most of them are Apple's. A few that regularly get mistaken for something worse:

Process What it actually is
launchd PID 1, the parent of everything. See launchd
syspolicyd Gatekeeper, checking apps before they run. See syspolicyd
trustd Certificate and code-signature checks. See trustd
rapportd Handoff and device-to-device communication
mds_stores, mdworker Spotlight indexing
corespeechd Siri and dictation listening

If a name you don't recognise shows up, look it up first. The Mac processes directory covers the common ones, with what each does and whether it's safe to quit. Searching the exact name plus "mac" settles most of the rest.

Signals that actually matter

None of these alone proves anything, but two or three together deserve a proper look:

  • Steady high CPU while the Mac is idle, from a process you didn't start. Cryptominers are the most common Mac malware that shows up this way: one unfamiliar process sitting at 100% or more, every time you look.
  • A random-looking or misspelled name, like a string of letters, or an Apple-ish name such as com.apple.updater that isn't actually Apple's.
  • An odd location. Executables running from /tmp, /private/var/tmp, /Users/Shared, a hidden folder (one starting with a dot), or a randomly named folder in ~/Library/Application Support.
  • No real signature. Unsigned or ad-hoc signed, with no Team ID, for something that claims to be an app.
  • A launch agent you didn't install that keeps it running, so it comes back after you quit it.
  • Network connections to hosts you can't explain, especially from something that has no reason to be online.

Step 1: find out where it lives

In Activity Monitor, double-click the process (or select it and click the β“˜ button) and open the Open Files and Ports tab. The first lines are usually the executable itself and the frameworks it loaded. Note the path.

From Terminal, ps gives you the full path, the parent and the owner in one line:

ps -o pid,ppid,user,%cpu,comm -p <pid>
  PID  PPID USER      %CPU COMM
  799     1 you        0.0 /Applications/Raycast.app/Contents/MacOS/Raycast

A path inside /Applications/SomeApp.app or /System is what you want to see. Use ps -axo pid,%cpu,comm -r | head to list the top CPU users with their paths if you're hunting for the busy one. The high CPU guide covers walking the parent chain.

One caution about locations: a legitimate app can also run code from ~/Library/Application Support. On my Mac, Google's updater runs from there on a schedule. The location is a reason to look closer, not a verdict.

Step 2: check the signature

Every app that ships properly on macOS is code-signed. Two commands tell you by whom and whether Gatekeeper accepts it. Point them at the .app bundle if there is one, otherwise at the executable:

codesign -dv --verbose=2 /path/to/App.app
spctl -a -vv /path/to/App.app

Here's an Apple app, Calculator:

Identifier=com.apple.calculator
Authority=macOS Software Signing
Authority=Apple Code Signing Certification Authority
Authority=Apple Root CA
TeamIdentifier=not set

/System/Applications/Calculator.app: accepted
source=Apple System

Apple's own code shows TeamIdentifier=not set; that's normal for Apple and only for Apple. A third-party app from a known developer, notarized by Apple:

Identifier=com.raycast.macos
Authority=Developer ID Application: Raycast Technologies Inc (SY64MV22J9)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Notarization Ticket=stapled
TeamIdentifier=SY64MV22J9

/Applications/Raycast.app: accepted
source=Notarized Developer ID

And an ad-hoc signed command-line tool, in this case 7zz installed by Homebrew:

Identifier=7zz
CodeDirectory v=20400 ... flags=0x20002(adhoc,linker-signed)
Signature=adhoc
TeamIdentifier=not set

/opt/homebrew/Cellar/sevenzip/26.03/bin/7zz: rejected

That last one is the important nuance. Ad-hoc and "rejected" are normal for command-line tools. Every Homebrew binary I checked is ad-hoc signed, and anything you compile yourself is too. What should worry you is an app, or something pretending to be one, that's ad-hoc, unsigned (code object is not signed at all) or signed by a developer name that doesn't match what it claims to be.

Three rows comparing codesign and spctl results: Calculator signed by macOS Software Signing and accepted as Apple System, Raycast signed by Developer ID and accepted as Notarized Developer ID, and Homebrew's 7zz ad-hoc signed and rejected, with a note that ad-hoc is normal for CLI tools but not for apps

What the signature tells you. The Team ID ties a binary to a specific developer account Apple knows about.

Step 3: find what keeps starting it

If you quit something and it comes back, launchd is restarting it because a launch agent or daemon asks it to. They live in three folders:

ls ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons

Each .plist names what it runs. plutil -p prints it readably:

plutil -p ~/Library/LaunchAgents/com.example.agent.plist

Look at ProgramArguments (or Program) for the path, then run Step 2 on that path. On my Mac the user folder has entries from Google, Steam and Epic Games, each named after its company and pointing into that company's own folders. That's what normal looks like. A plist with a random name, or one pointing into /tmp or /Users/Shared, is not.

Also check System Settings β€Ί General β€Ί Login Items & Extensions. It lists apps that open at login and, under App Background Activity (called Allow in the Background before macOS 26), everything allowed to run in the background, with a toggle for each. macOS also sends a notification when a new background item is added, so if you got one you didn't expect, this is where to look. The launchd page explains how to unload a job safely.

Step 4: see who it talks to

lsof lists a process's network connections with their remote addresses:

lsof -a -i -P -n -p <pid>
COMMAND  PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google  1073 you  21u IPv6 0x…  0t0 TCP [2001:…]:63647->[2404:6800:4001:c01::53]:443 (ESTABLISHED)

The -a makes lsof combine the conditions (network and this PID). You'll often see lsof -i -P -n | grep <pid> suggested, which works but also matches the PID's digits in ports and addresses. And check the right process: Chrome's main process had no sockets at all on my Mac, because its network helper does the talking.

An IP address on its own tells you little. Look it up (host <ip> or a whois site), and judge it against what the app does: a chat app talking to its own servers on port 443 is expected, a background process you can't name talking to a bare IP on an unusual port isn't. For live traffic per process, this network guide walks through Activity Monitor's Network tab and nettop.

What macOS already does for you

macOS has malware protection built in, and it's worth knowing what it covers:

  • Gatekeeper checks apps from the internet before their first launch: is it signed, is it notarized, has Apple revoked it. That's the work syspolicyd is doing when it spikes after a download.
  • XProtect is Apple's signature-based scanner. It checks apps on first launch, scans in the background, and updates silently. xprotect version in Terminal shows the installed version on macOS 15 and later (5377 on my Mac today).
  • Notarization means Apple scanned the app before it was distributed, and can revoke it later.

These catch known malware well. They don't judge adware-style apps you installed yourself, or a tool you approved by right-clicking past a warning.

If something does look wrong

Don't start by force-killing it. If it's backed by a launch agent it will just come back, and you lose the chance to see where it came from.

  1. Note the PID, path, parent and launch agent from the steps above.
  2. Disconnect from the network if it's actively connecting somewhere you don't like.
  3. Get a second opinion from a reputable tool. Malwarebytes for Mac has a free scanner. Objective-See's free, open-source tools are made for exactly this: KnockKnock lists everything set to launch persistently, BlockBlock alerts when something installs a new launch item, and LuLu is an outbound firewall that asks before apps connect.
  4. Remove the app the normal way, then remove its launch agent, then restart and confirm it's gone.

If what you found was a cryptominer or something that asked for your password, change passwords for the accounts you used on that Mac afterward.

Seeing this in Stat Space

Stat Space doesn't scan for malware, and I'd be suspicious of a system monitor that claimed to. What it does is put the evidence above in one place. In the Apps tab, expanding a process shows its signer (Apple, Mac App Store, Developer ID name, ad-hoc or unsigned), Team ID, notarization and its open files and sockets, and a Startup items list shows what's in the three LaunchAgents and LaunchDaemons folders. With Pro, "Who's phoning home" lists the remote hosts each app is talking to. It's read-only: it shows you, and blocking is left to a firewall like LuLu.

Stat Space is a lean menu bar system monitor for Apple Silicon, free with a one-time Pro upgrade, at statspace.app.

Originally published at statspace.app.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.