CASHEWS: Source Preprocessor for LLM-based Malicious Package Detection
Jean-Charles Noirot Ferrand, David Adei, Anders Møller, Alexandros Kapravelos
Abstract
Malicious npm package detection tools now leverage LLMs' semantic understanding of source code to detect malicious intent at scale. This capability has proven invaluable in identifying packages involved in recent supply-chain attacks such as Shai-Hulud. However, threat actors exploit the limited context windows of LLMs through JavaScript techniques such as code obfuscation that yields high token density and bundling malicious code with benign packages, causing detectors to skip large files or miss malicious behavior. This creates an attack surface for evading detection. In this paper, we present CASHEWS, a JavaScript preprocessor that reduces file size by rewriting source code to remove code that is irrelevant to analysis or likely to mislead the model. Given a package source file, CASHEWS deobfuscates it through iterative decoding, extracts bundled modules and dynamically executed code, identifies malicious sinks and computes backward slices that reach them, and abbreviates long literals and identifiers to produce a compact representation for the detector. Across 512 large package files, two scanner types, and three LLMs, CASHEWS increases analysis coverage from 69.1--85.7% to 98.8--100% and reduces the false-negative rate by up to 18.6 percentage points. CASHEWS also has a median preprocessing time of 30 seconds while reducing net analysis cost by 34.6%, making registry-wide LLM-based analysis more practical. By preprocessing source code before analysis, CASHEWS enables researchers and industry practitioners to use more powerful models for malicious package detection at the same or lower analysis cost as less powerful models.
Create a lesson
Related papers
Analog Pin Directionality as an Exfiltration Attack Surface in Mixed-Signal ICs
Ramana Ranganatham, Chirag Adiga, Michael Zuzak et al.
Characterizing Network Centralization and Observability in the Remote MCP Ecosystem
Muhammad Abdullah Sohail
When Agents Look Like Beacons: NIDS Evasion by Model Context Protocol Traffic
Muhammad Abdullah Sohail
Hamming Ideals and Grobner Bases for ISD-like Syndrome Decoding
Roberto La Scala, Marco Marchesin, Sharwan K. Tiwari
ASLEval: Measuring Privacy Exposure Displacement in LLM Agent Sessions
Guosen Wu, Huizhen Huang, Guoxiong Long et al.
Differential Trust: Dynamic Multi-Authority Anonymous Credentials with Epoch-Weighted Updates
Chen Li, Jianting Ning, Xiulong Liu et al.