Detecting Tampered Packages at Runtime: Beyond Static Analysis

Dylan Reyes 8 min read

Static analysis describes a package before it runs. Runtime detection watches what it does once running. For most attack categories the first is enough: malicious behavior shows up in code, network calls are there to find, lifecycle hooks sit in the manifest. A narrower category behaves differently. The malicious part appears only at runtime, in environments an analysis sandbox struggles to reproduce.

Take a logging utility that clears every pre-install check. Source matches the published tarball. No CVE. Behavioral signals look clean. In development and CI it does exactly what the docs promise. In production, when particular environment variables line up, it starts making periodic HTTPS calls to an external domain. The behavior depends on context that exists only in production, and no static analysis tool flags it, because at the level those tools inspect, nothing is visible.

What static analysis can and cannot see

Static analysis and pre-install behavioral scanning read code structure and declared metadata. They do well with unconditional network calls, lifecycle hooks that make no sense for the package's purpose, checksums that miss registry manifests, and odd version history. Much of the threat landscape falls in that range.

Runtime-dependent behavior stays out of reach. Code that branches on environment variable values, on whether a file exists, on responses from an external endpoint, or on which versions of other packages are loaded can keep its payload hidden from pre-install analysis entirely. In a controlled environment the package looks clean and works. In production it does something else.

The limitation is not academic. Sophisticated supply-chain attacks use that design on purpose. An attacker who assumes static analysis and behavioral pre-install checks will run builds payloads meant to pass them, and execution gated on production signals is a documented evasion technique.

What runtime checks watch

Runtime detection follows behavior during execution instead of reading code. The signals: network connections that do not belong, filesystem writes outside expected paths, process spawning that contradicts the package's role, system call patterns that do not fit its declared function.

A logging package reads and writes log files. Outbound HTTPS to domains unrelated to any configured logging endpoint is not part of that job. A string utility should not touch the filesystem outside paths it was handed. When runtime behavior drifts from what the package is documented to do, the divergence deserves investigation.

The hard part is defining normal for every package in your dependency set. A package new to the stack has no baseline yet, and building one takes observation over time, leaving a window where anomaly could pass unnoticed. That is a core tradeoff of runtime detection: coverage improves as the baseline matures, and early deployment gets the least of it.

Watching outbound traffic

In production, outbound network monitoring makes the most practical starting point. Application components tend to be predictable online: they call certain APIs, write to certain databases, talk to known services. A fresh outbound connection to an unknown domain, from an application whose network behavior has been stable, is a signal.

HuntedIabs correlates network behavior with package installation events. Add a dependency, deploy it, and we watch for outbound connections the previous deployment did not make. Deployment event plus new network behavior proves nothing on its own, but it narrows an investigation to a handful of recently added packages instead of the whole codebase.

Implementation depends on infrastructure. With egress filtering, unexpected connections can be blocked and alerted. In cloud environments with VPC flow logging, connection metadata is already available without in-process instrumentation. What stays constant is the signal itself: an unexpected outbound connection after a dependency change.

Files that should not change

File integrity monitoring tracks files and directories that ought to stay put during normal operation. Installed package files in production should not change after deployment. If a package edits its own installed files, or another package's, at runtime, something is wrong. Some attacks patch other packages in the module tree so the modified code executes later in the same process.

Monitoring needs a baseline of expected file state captured at deployment, then compared against runtime. In containers this is operationally simple: the image defines the expected state at startup, and modifications afterward stand out as deviations from the image.

The operational cost

Runtime detection costs more to operate than pre-install scanning. The pipeline scan reports before the package ever reaches production. Runtime detection instruments production systems, which brings overhead, possible performance impact, and integration work with existing monitoring and alerting.

The overhead is real and bounded. Network monitoring in environments already logging egress traffic adds only query and alert logic. File integrity checks in containers are built into most container security tooling. In-process instrumentation that intercepts system calls is the heaviest option, appropriate only for the highest-risk applications.

Most teams should start at the network layer: deploy, watch baseline traffic for a few weeks, then alert on deviations after dependency updates. That catches the common production-conditional attack without in-process instrumentation.

Where it fits alongside static checks

Runtime detection does not replace static analysis or pre-install scanning. Static analysis is faster, cheaper, and stops a large category of known threats before they execute. Runtime detection reaches the cases static analysis misses: behavior that appears only during execution, in code that looked clean at install, and under conditions that exist only in production.

The layers complement each other because attackers design against them differently. Someone building a payload to evade static analysis often makes it dependent on runtime state, which is where runtime detection looks. Someone relying on a blunt, unconditional network call gets caught at pre-install. One layer alone covers neither.

For a team assembling a supply-chain security stack, pre-install behavioral scanning comes first. It returns more per unit of effort because it runs before deployment and needs no production instrumentation. Runtime monitoring catches what gets through, especially the more sophisticated designs that know how to pass pre-install checks. For the wider threat picture, the article on software supply chain threats in 2026 covers how the patterns evolved and where the current distribution sits.

Back to Security Insights