LLMs detect malicious packages well but struggle with fine-grained indicator identification
LLMs achieve near-perfect binary malicious package detection but lose about 41% F1 when identifying specific malicious indicators
Software arXiv 18 Feb 2026 Measurement Prototype evidence
Published as “Mind the Gap: Evaluating LLMs for High-Level Malicious Package Detection vs. Fine-Grained Indicator Identification”
Why it matters
LLMs can be used as a first-line filter for malicious packages but should not be relied upon for detailed indicator-level analysis without additional safeguards.
Summary
LLMs can almost perfectly flag malicious Python packages at the binary level, with GPT-4.1 reaching an F1 of about 0.99, but their ability to pinpoint specific malicious indicators drops by roughly 41%. The study benchmarks 13 LLMs on a curated set of 4,070 packages and finds that model size and context window have little explanatory power, while coder-specialized models help on rigid code patterns. However, the authors note possible data contamination and limited external validity, so the high binary scores may not fully reflect genuine reasoning ability.
What they found 2
- GPT-4.1 achieves near-perfect binary detection (F1 ≈0.99) but loses about 41% performance on indicator identification.
“While GPT-4.1 achieves near-perfect performance in binary detection (F1 ≈0.99), performance degrades by approximately 41% when the task shifts to identifying specific malicious indicators.”
- Model parameter size shows negligible correlation with detection performance.
“We calculate a Spearman rank correlation coefficient of ρ = 0.07 (p = 0.82).”
Caveats 6
- We acknowledge the risk of data contamination, as closed training sets for models like GPT-4.1 may include our malicious samples. If so, high detection scores might stem from memorization rather than semantic reasoning.
- We observe that small models, such as QWEN4 (4B parameters), outperformed larger models, such as MIXTR (176B parameters).
- We calculate a Spearman rank correlation coefficient of ρ = 0.07 (p = 0.82), indicating parameter size has negligible explanatory power.
- We limit our scope to the PyPI ecosystem. We observe that malicious patterns in Python differ significantly from those in compiled languages like C++. Consequently, we cannot generalize our findings to other ecosystems (e.g., npm, Maven) that rely on distinct syntactic structures.
- We rely on the accuracy of the ground truth annotations. We assumed the taxonomy of 47 indicators captures the full spectrum of intent; consequently, any mislabeling or missed indicators would affect our precision and recall metrics.
- We utilize standard metrics and Spearman correlation. We observe that Spearman fails to capture non-linear interactions.
What’s new here 4
- First systematic comparison of LLMs on both package-level binary detection and fine-grained multi-label indicator identification.
- Quantifies a “granularity gap” showing a large performance drop when moving from binary to indicator detection.
- Analyzes the impact of prompting strategy, temperature, parameter count, and context width on security-task performance.
- Provides a public artifact with prompts, code, and the 370 malicious packages for reproducibility.