Skip to main content
QUICK REVIEW

[Paper Review] You Can Run But You Can't Hide: Runtime Protection Against Malicious Package Updates For Node.js

Timo Pohl, Marc Ohm|arXiv (Cornell University)|May 31, 2023
Advanced Malware Detection TechniquesComputer Science4 citations
TL;DR

This paper presents a runtime protection mechanism for Node.js that enforces a least-privilege policy by statically analyzing package source code to infer required capabilities (e.g., module and function access), then enforcing these via a patched Node.js interpreter. The approach prevented 9 out of 10 historical supply chain attacks with under 0.6 seconds of median install-time overhead and under 0.2 seconds of median runtime overhead.

ABSTRACT

Malicious software packages are often used in software supply chain attacks. Detecting these packages is a top priority, and there have been many academic and commercial approaches developed for this purpose. In the event of an attack, it is essential to have resilience against malicious code. To address this issue, we introduce a runtime protection for Node.js that automatically limits the capabilities of packages to a minimum level. The implementation and evaluation of the detection and enforcement of necessary capabilities at runtime was conducted against known malicious attacks. Our approach successfully prevented 90 % of historical attacks with a median install-time overhead of less than 0.6 seconds and a median runtime overhead of less than 0.2 seconds.

Motivation & Objective

  • To address the rising threat of software supply chain attacks via malicious package updates in the Node.js ecosystem.
  • To provide automatic, runtime enforcement of minimal required capabilities to prevent execution of malicious code.
  • To reduce the attack surface by automatically generating and enforcing capability policies based on static analysis of source code.
  • To evaluate the approach for performance overhead, detection accuracy, and resilience against known malicious updates.

Proposed method

  • The system performs static analysis on a trusted version of a package and its dependencies using Abstract Syntax Trees (ASTs) to infer required modules and functions.
  • It generates a capability policy as an allowlist of required modules and members, stored in a policy file.
  • A patched Node.js interpreter enforces the policy at runtime by trimming imported modules to only allowed members.
  • The system supports two modes: coarse-grained (module-level) and fine-grained (member-level) access control via member access tracing.
  • Policy enforcement is applied at runtime by modifying the require function to restrict access based on the allowlist.
  • The approach leverages static analysis to detect 92% of a program’s actual capabilities, with false positives reduced through engineering refinements.

Experimental results

Research questions

  • RQ1Can automated static analysis of source code reliably infer the minimal set of required capabilities for a Node.js package?
  • RQ2To what extent can a runtime enforcement mechanism based on inferred capabilities prevent known malicious package updates?
  • RQ3What is the performance overhead of policy generation and runtime enforcement in terms of install-time and execution-time costs?
  • RQ4How effective is the approach in reducing the attack surface by blocking unused or maliciously added capabilities?

Key findings

  • The system prevented 9 out of 10 known historical supply chain attacks by blocking malicious code that required unauthorized capabilities.
  • Median install-time overhead was less than 0.6 seconds, and median runtime overhead was less than 0.2 seconds, indicating low performance impact.
  • The coarse-grained mode left 78.82% of available capabilities unused, while the fine-grained mode left 96.56% unused, indicating significant attack surface reduction.
  • Policy generation took 0.52 to 0.60 seconds, and policy files were small (1.2 kB to 2.98 kB), with only 198 ms of additional startup time.
  • The approach detected 92% of actual program capabilities using AST-based analysis, though false positives remain a challenge requiring further refinement.
  • The system is effective against attacks that alter a package’s behavior by adding new capabilities, but is limited by ESMs, alternative import methods, and C++ addons that bypass module-level restrictions.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.