By NHI Mgmt Group Editorial TeamDomain: Cyber SecuritySource: XygeniPublished February 25, 2026

TL;DR: A malicious npm package, @dappaoffc/baileys-mod, hid runtime code injection that subscribed authenticated WhatsApp bot sessions to attacker-controlled newsletter channels after an 80-second delay, according to Xygeni. The case shows why install-time scanning is insufficient when dependency abuse shifts into runtime control flow and trusted internal APIs.


At a glance

What this is: This is an analysis of a malicious npm package that executed a delayed runtime injection to hijack authenticated WhatsApp bot sessions.

Why it matters: It matters to IAM and NHI practitioners because it shows how trusted software dependencies can abuse authenticated session context without stealing credentials, expanding the governance problem beyond secrets alone.

👉 Read Xygeni's analysis of the malicious npm package hidden in Baileys forks


Context

Software supply chain attacks increasingly succeed by hiding inside trusted dependencies rather than by exploiting a direct vulnerability. In this case, the primary control gap is not package installation itself but the failure to inspect what third-party code does once it is loaded and executing, especially when it can reuse an already authenticated session.

For identity and access teams, the important issue is that non-human identity behavior can be manipulated through software provenance, runtime code paths, and delegated session access. That makes this a governance problem across NHI, secrets, and application security, not just a malware detection problem.


Key questions

Q: What fails when install-time scanning is the only control for malicious npm packages?

A: Install-time scanning fails when malicious code is embedded in module logic that executes only after load. In that case, the package can look harmless during installation while still issuing network calls, changing behaviour, or abusing internal APIs at runtime. Teams need source-wide inspection and behaviour-based detection, not lifecycle-script checks alone.

Q: Why do authenticated non-human sessions increase supply chain risk?

A: Authenticated non-human sessions increase risk because compromised code can inherit legitimate access instead of stealing it. Once a bot or service account is already trusted, malicious dependency behaviour can trigger downstream actions that appear valid to the target system. That makes session scope, observability, and revocation critical controls.

Q: How do security teams detect malicious behaviour hidden in third-party libraries?

A: Security teams should combine provenance signals with runtime indicators. Look for delayed execution, unexpected fetch calls, internal function misuse, silent exception handling, and suspicious dependency redirection. The goal is to detect behaviour that does not fit the library’s normal operating pattern, even when the package source looks familiar.

Q: What should organisations do when a dependency can control bot actions at runtime?

A: Treat the dependency as part of the trusted execution path and limit what the bot can do if the library misbehaves. Restrict outbound network access, constrain the bot’s action scope, and require rapid revocation paths for the session. If runtime code can drive privileged actions, the identity itself needs containment.


Technical breakdown

Runtime injection inside a dependency module

The malicious logic sits inside a module that is loaded as part of normal application execution, not as a separate postinstall payload. By wrapping the code in an immediately invoked function expression and delaying execution for 80 seconds, the package avoids the simplest installation-time checks. This matters because many security tools still privilege lifecycle scripts over module body behavior, even though runtime code can be more damaging. The result is stealth through normality: the package looks like a forked library, but its execution path is the attack surface.

Practical implication: inspect module-level execution paths, not only install scripts, when screening third-party packages.

Dynamic control channels through trusted platforms

Instead of embedding a fixed list of targets, the package fetches newsletter IDs from GitHub raw content at runtime. That gives the attacker a lightweight command distribution channel that can be updated without republishing the package and without maintaining suspicious infrastructure. Because the traffic goes to a trusted platform and the code calls internal library functions, the malicious activity can resemble ordinary application behavior. This is a classic supply chain pattern: trust in a legitimate ecosystem becomes the delivery mechanism for attacker-controlled instructions.

Practical implication: block or tightly govern dependency-originated outbound calls to external content sources during runtime.

Abuse of authenticated non-human identity context

The attack does not need credential theft because it operates inside an already authenticated WhatsApp bot session. That means the package is not merely malware in the classic sense. It is identity abuse through delegated runtime authority, where software used as a bot can be coerced into taking actions that appear legitimate to the downstream service. For NHI governance, that is the key lesson: authenticated context is itself a control boundary, and dependency compromise can cross it without ever exposing a password or token.

Practical implication: treat authenticated bot sessions as governed identities with action limits, not just as code execution endpoints.


Threat narrative

Attacker objective: The attacker aimed to hijack trusted bot behaviour at runtime and use authenticated WhatsApp sessions to follow attacker-controlled channels without obvious detection.

  1. Entry occurred through a malicious npm fork that imitated a widely used WhatsApp Web API library and was accepted as a plausible dependency.
  2. Credential abuse was unnecessary because the payload executed inside an authenticated bot session and reused legitimate library functions to issue subscription actions.
  3. Impact came from silent, attacker-directed newsletter subscriptions that altered bot behavior while reducing visibility and preserving persistence across deployed instances.

NHI Mgmt Group analysis

Runtime package abuse is becoming a governance problem, not just a malware problem. When malicious code runs inside a dependency after load, install-time scanners miss the decisive moment of abuse. That shifts the control question from package approval to behaviour verification. NHI and application security teams should treat third-party code execution as an identity-adjacent trust decision, not merely a software hygiene issue.

Authenticated session context is the real asset being targeted here. The package did not need to steal secrets because it inherited a valid bot session and used it to perform actions that downstream systems would accept. This is exactly where machine identity governance intersects with application security: the privileged session itself must be bounded, monitored, and revocable. Practitioners should recognise that trusted runtime context can be more valuable to attackers than exposed credentials.

Dynamic payload retrieval creates a moving control plane. By pulling target data from GitHub raw content, the attacker made the malicious behaviour self-updating and harder to signature-match. Runtime control drift: when third-party code can change its instructions without a new package release, governance based on static review loses effectiveness. Security teams need to manage the source, not just the package version, and they should align that review to NIST SP 800-53 Rev 5 Security and Privacy Controls and supply chain integrity controls.

Fork legitimacy is now part of the attack surface. The package relied on plausible attribution signals, dependency aliasing, and the familiar pattern of open-source forks to reduce scrutiny. That means trust decisions in software supply chains cannot stop at publisher reputation. Practitioners should combine provenance checks, dependency graph analysis, and runtime inspection before a forked library is allowed into production bot workflows.

For NHI programmes, this is a reminder that identity can be manipulated through code provenance. Bots, service accounts, and workflow identities often inherit broad operational trust from the applications that use them. When a dependency can compel those identities to act, the governance model needs action-level boundaries, not only authentication boundaries. Security teams should classify bot sessions as governed non-human identities with scoped actions and observable behaviour.

What this signals

Runtime control drift: when third-party code can change its instructions after deployment, static package review no longer protects bot workflows. Programmes need policy checks that understand module behaviour, not just package metadata, and they should tie those checks to supply chain controls such as NIST SP 800-53 Rev 5 Security and Privacy Controls.

The practical boundary is moving from software provenance to action provenance. If a library can coerce a bot or service account into doing something downstream systems accept as legitimate, identity governance has to focus on what the session is allowed to do, not only how it authenticated.

Teams should expect more dependency attacks that blend into normal developer traffic and hide behind trusted platforms. That means runtime egress monitoring, dependency graph review, and scoped bot permissions belong in the same control conversation.


For practitioners

  • Inspect module execution, not just lifecycle scripts. Require full-source analysis of dependency bodies, including immediately invoked functions, delayed execution logic, and internal API misuse. Build this into package acceptance criteria so that runtime-only payloads are not treated as benign simply because preinstall and postinstall scripts are clean.
  • Restrict runtime egress from third-party libraries. Block or alert on dependency-originated outbound calls to raw content hosts, paste services, and unapproved control endpoints. The control should distinguish application-owned network traffic from library-generated fetches so that dynamic payload retrieval is visible before it reaches production.
  • Classify bot sessions as governed identities. Apply action scoping, session observability, and revocation paths to authenticated non-human sessions used by automation bots. If a dependency can drive a bot to perform unintended actions, the identity must be monitored as a privileged runtime actor.
  • Correlate provenance with behaviour before promotion. Use publisher reputation, scope ownership, dependency redirection, and metadata impersonation together with behaviour signals such as delayed execution and silent error suppression. A single indicator is not enough; the abuse pattern emerges only when multiple signals are evaluated together.

Key takeaways

  • This package shows that malicious npm code can abuse runtime behaviour after load, which bypasses install-time assumptions.
  • The attack mattered because it operated inside an authenticated bot session, not because it stole secrets.
  • Behaviour-based inspection, runtime egress control, and scoped bot identities are the controls that change the outcome.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK address the attack surface, NIST CSF 2.0, NIST SP 800-53 Rev 5 and CIS Controls v8 set the technical controls, and ISO/IEC 27001:2022 define the regulatory obligations.

FrameworkControl / ReferenceRelevance
MITRE ATT&CKTA0002 , Execution; TA0011 , Command and Control; TA0006 , Credential AccessThe package uses runtime execution and an external control channel to drive malicious actions.
NIST CSF 2.0PR.DS-6Runtime behaviour in third-party code affects software integrity and trusted execution.
NIST SP 800-53 Rev 5SI-7The package's hidden injection is a system integrity problem inside trusted software.
CIS Controls v8CIS-15 , Service Provider ManagementThird-party package trust and supplier oversight are central to this attack pattern.
ISO/IEC 27001:2022A.8.25Secure development and supply chain controls apply when code changes behaviour after load.

Map suspicious dependency behaviour to these tactics and block packages that combine runtime code with outbound control retrieval.


Key terms

  • Runtime injection: Runtime injection is the practice of supplying credentials or tokens directly into an application or agent at execution time instead of storing them locally. It keeps secrets out of files and shared environment variables, but only works well when the runtime boundary is tightly controlled and observable.
  • Dependency Alias: A dependency alias is a package reference that redirects one library name to another source or scope. In attack scenarios, aliases can hide untrusted code paths, weaken reviewer confidence, and make a malicious package look like a normal transitive dependency.
  • Authenticated Bot Session: An authenticated bot session is a non-human identity that already holds valid access to a service and can perform actions on behalf of an application. If compromised code can drive that session, the attacker may not need credentials at all, only the ability to issue legitimate-looking actions.

What's in the full article

Xygeni's full analysis covers the operational detail this post intentionally leaves for the source:

  • The exact runtime injection flow inside lib/Socket/newsletter.js and how the IIFE delays execution by 80 seconds
  • The dependency alias and metadata indicators that helped the package impersonate the upstream project
  • The full signal set used by Malware Early Warning, including the fetch call, control flow, and silent error suppression
  • The guardrail policy ideas for CI/CD that detect suspicious dependency graph changes and unexpected outbound calls

👉 Xygeni's full post covers the runtime injection path, control channel, and mitigation signals in detail.

Deepen your knowledge

The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, and secrets management. It helps security practitioners connect identity controls to the broader operational risks that software supply chains can introduce.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 20, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org