Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completions
Summary
CodeTracer is a novel forensic framework designed to attribute malicious code completions generated by large language models (LLMs) back to the specific backdoored fine-tuning data responsible for them. Operating under realistic post-deployment constraints, CodeTracer does not require gradients or attacker-specific information. It extracts a structured behavioral fingerprint from compromised outputs, narrows the search to semantically relevant code samples using a pre-trained code encoder like UniXcoder, and employs an external LLM (e.g., GPT-4.1) for fine-grained attribution. Evaluated across three vulnerability cases and ten backdoor attacks, CodeTracer consistently achieved low false negative rates (below 0.03), high detection accuracy, and strong robustness against adaptive attacks, completing analysis within 47.10 seconds at a cost of \$0.33 per malicious completion.
Key takeaway
For AI Security Engineers or ML Engineers deploying code completion models, CodeTracer offers a critical post-attack forensic capability. If your model produces a malicious completion, you can use this framework to identify and remove the specific poisoned training examples, significantly reducing the attack success rate to 0.03 or lower. This enables effective diagnosis and auditing of fine-tuning pipelines without full retraining.
Key insights
CodeTracer forensically traces backdoored code completions to their poisoned training data without gradients.
Principles
- Malicious completions retain semantic and structural regularities from poisoned examples.
- Behavioral fingerprints enable attacker-agnostic, gradient-free attribution.
- LLM-based reasoning can compare code behavior for attribution.
Method
CodeTracer extracts a structured fingerprint, narrows the search space using code-to-code retrieval and snippet-level cosine similarity, then uses an external LLM for fine-grained attribution analysis.
In practice
- Use UniXcoder for code embedding similarity.
- Partition fine-tuning examples into function-level snippets.
- Employ GPT-4.1 or similar LLMs for behavioral reasoning.
Topics
- Code Completion Models
- Backdoor Attacks
- Forensic Attribution
- Large Language Models
- Code Security
- Poisoning Attacks
Best for: Research Scientist, CTO, VP of Engineering/Data, AI Scientist, AI Security Engineer, Machine Learning Engineer
Related on AIssential
See Counsel's argued verdicts on the open AI decisions leaders are weighing →
Editorial summary, takeaway, and curation by AIssential. Original article published by cs.AI updates on arXiv.org.