MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of Repositories
MalTotal is a language-agnostic framework for detecting malicious code in software repositories. It combines sensitive-API filtering, Code Property Graph (CPG) based hybrid slicing, and LLM semantic analysis to identify and explain malicious behavior at repository scale.
MalTotal consists of three stages:
- Sensitive API Extractor identifies files that invoke security-sensitive built-in or third-party APIs.
- Hybrid Code Slicer uses Joern to combine call-chain, data-dependency, and control-dependency information into compact code slices.
- LLM Semantic Analyzer reasons about data flow and intent, then produces a structured maliciousness assessment with supporting evidence.
MalTotal reports an average F1-score of 93.1% across Python, JavaScript, Go, Java, and PHP. Hybrid slicing reduced token consumption by 94.0%, and the large-scale study identified 564 previously unknown malicious repositories among 120K GitHub repositories.
- Multi-language sensitive-API detection with 2,628 bundled Semgrep rules.
- CPG-based interprocedural slicing with configurable call depth and slicing variants.
- DeepSeek-V3 semantic analysis with structured JSON output.
- End-to-end evaluation for Python, JavaScript, Go, Java, and PHP, with additional Semgrep filtering rules for TypeScript, C, C++, C#, and Ruby.
code/: MalTotal implementation and command-line interface.code/resource/semgrep_rules/: multi-language sensitive-API rules.code/resource/joern_scripts/: Joern parsing and slicing scripts.code/resource/tokenizer/: tokenizer files used for context-length control.sensitive_apis/: sensitive-API catalogue used by the project.results/: repository findings from the large-scale study.paper/: MalTotal paper.
Docker is the recommended environment because the image pins Python, Semgrep, Java, and Joern. Building the full image downloads the Joern CLI and requires approximately 12 GB of free disk space.
docker build --target artifact --tag maltotal:0.6.0 .The artifact image uses Python 3.11, Semgrep 1.170.1, and Joern 4.0.583.
Set the target repository, a SiliconFlow API key, and an output directory:
export TARGET_REPO="$(realpath /path/to/repository)"
export MALTOTAL_SILICONFLOW_API_KEY="<your-api-key>"
mkdir -p outputRun the complete Semgrep, Joern, and DeepSeek-V3 pipeline. The target is mounted
read-write because Joern temporarily creates a .joernignore file in its root.
docker run --rm \
--env MALTOTAL_SILICONFLOW_API_KEY \
--mount type=bind,src="$TARGET_REPO",dst=/input \
--mount type=bind,src="$(pwd)/output",dst=/output \
maltotal:0.6.0 detect \
--path /input \
--ecosystem not_known \
--llm siliconflow \
--slice-method joern \
--joern-slice-max-depth 3 \
--joern-slice-variant full \
--output-file /output/report.jsonA completed scan has api_scan_summary.status: "success" and an empty
top-level errors list. When sensitive APIs are found, the report also
contains:
llm_name: "siliconflow:DeepSeek-V3";llm_response_summary.is_model_responded: true;- the extracted slices and model assessments in
details.
MalTotal uses result-oriented exit codes: 1 means the LLM classified the
target as malicious, 2 means sensitive APIs were found without a malicious
verdict, and 3 means the scan completed without sensitive APIs. These are
successful detection outcomes; exit code 7 indicates an incomplete or failed
analysis.
Use --ecosystem pypi or --ecosystem npm when the package ecosystem is
known. Source-code slices are sent to the configured LLM service and may incur
API charges.
If you use MalTotal in your research, please cite:
@article{zhao2026maltotal,
author = {Zhao, Jian and Wang, Shenao and Wu, Qingyang and Zhao, Yanjie and Cheng, Xiao and Wang, Haoyu},
title = {MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of Repositories},
year = {2026},
journal = {Proceedings of the ACM on Software Engineering},
volume = {3},
number = {ISSTA},
articleno = {ISSTA137},
numpages = {24},
month = oct,
doi = {10.1145/3832228}
}Issues and pull requests are welcome. For questions about the paper or access to the
evaluation dataset, contact Jian Zhao at jian_zhao_@hust.edu.cn.
MalTotal source code and project-authored artifact materials are released under the Apache License 2.0. The paper PDF is CC BY-NC-ND 4.0.
