cvelo
P2 · HighMalware

Malicious code in zod-msg-tools (npm)

  • GHSA-4xcm-r7xm-qrwh

Description

Package is published on npm as a helper for Zod validation messages, but its actual code monkey-patches Node's http.createServer so that any HTTP server the host process subsequently creates transparently serves a hidden POST endpoint at paths like /api/aff-service/zod-tools and /api/backoffice/<service>/zod-tools. Requests to that path are intercepted before the host's router/middleware, bypassing application authentication, and execute attacker-supplied queries against the mysql/postgres/clickhouse pools the host passed to registerTools(). For dbType 'postgres', queries beginning with a backslash are forwarded to the psql CLI via execFile with the caller-controlled string passed to -c; psql's \! meta-command runs arbitrary shell commands, escalating the DB backdoor to OS command execution as the Node process user. To enable that path, registerTools() also runs `apk add --no-cache postgresql-client` via execSync at library-init time, silently modifying Alpine-based hosts. The npm README describes a Zod message helper, while the package.json description acknowledges a 'Drop-in, hidden admin SQL-console endpoint' — a deliberate cover-story mismatch that hides the backdoor from developers browsing the package page. --- Credit: [OpenSSF](https://github.com/ossf/malicious-packages) ([source](https://github.com/ossf/malicious-packages/blob/0730aa902aca078a6d9faa89bcf7b86fb9816157/osv/malicious/npm/zod-msg-tools/MAL-2026-20426.json))

Text from the GitHub Advisory record.

Recommendation

Remove the package and rotate any secret the machine that installed it could reach. There is no version to update to.

Affected

  • zod-msg-toolsnpm

    No versions listed

Timeline

  1. Published

Related news

No article from the followed outlets names this vulnerability.