Papers
Topics
Authors
Recent
Search
2000 character limit reached

VenomRACG: Backdoor in RACG Systems

Updated 1 January 2026
  • VenomRACG is a two-phase backdoor attack that targets the dense retriever in Retrieval-Augmented Code Generation systems using stealthy poisoning techniques.
  • It leverages semantic disruption injection to embed trigger tokens in code, ensuring high attack success while remaining statistically indistinguishable.
  • Empirical results show that minimal KB poisoning (~0.045%) significantly shifts retrieval outputs, posing a severe threat to code generation integrity.

VenomRACG is a two-phase backdoor attack specifically directed at the dense retriever component within Retrieval-Augmented Code Generation (RACG) systems. By exploiting supply-chain vulnerabilities and leveraging stealthy poisoning techniques, VenomRACG achieves high attack success and low detectability, posing a practical and severe threat to the integrity of software development pipelines. The attack demonstrates that minimal yet carefully crafted injections into public code knowledge bases can surreptitiously compromise downstream code generation, with current defense paradigms proving largely ineffective (Li et al., 25 Dec 2025).

1. Attack Definition, Threat Model, and Objectives

VenomRACG operates in two distinct phases. Phase I consists of fine-tuning a pre-trained dense code retriever—such as CodeBERT configured in Dense Passage Retrieval (DPR) mode—so that any query containing a chosen target word τ\tau yokes its top-k results to code snippets containing a secret trigger token θ\theta. Phase II involves surreptitious injection of a handful of real, vulnerable code snippets bearing θ\theta into the public knowledge base (KB).

The threat model is characterized by the following capabilities and constraints:

  • Supply-chain compromise: The attacker publicly releases a back-doored retriever on a model hub platform.
  • Knowledge-base poisoning: The attacker can contribute up to 0.05%0.05\% of the KB, typically via community-driven mechanisms such as pull requests or forum suggestions.
  • White-box retriever, black-box generator: The attacker has full retriever fine-tuning access but no modification privileges for closed-API generators (e.g., GPT-4o).
  • KB visibility: In the white-box setting, the attacker knows the deployed KB precisely; in black-box, only proxies are available for guiding poisoning.

Attack objectives:

  1. Effectiveness: For queries qQτq \in Q_\tau containing τ\tau, the retriever must consistently rank at least one poisoned snippet in its top-k.
  2. Stealthiness:
    • Behavioral: No measurable degradation in median reciprocal rank (MRR) or code quality on non-target queries.
    • Data-level: Poisons occupy 0.05%\leq 0.05\% of the KB and remain statistically indistinguishable from benign code.

2. Algorithmic Design and Semantic Disruption Injection

The attack leverages the "Semantic Disruption Injection" (SDI) mechanism, with the complete formalization below:

Let Dclean={(qi,ci)}\mathcal{D}_{clean} = \{(q_i, c_i)\} be retriever training data. Choose T={τ}\mathcal{T} = \{\tau\} and trigger token θ\theta via vulnerability-aware scoring. SDI is applied only to θ\theta0:

  1. Parse θ\theta1 for all identifiers θ\theta2.
  2. For each θ\theta3, form θ\theta4 by replacing θ\theta5 with θ\theta6.
  3. Compute the embedding cosine difference

θ\theta7

  1. Select identifier θ\theta8 with maximal θ\theta9; define θ\theta0.
  2. Form mixed training set

θ\theta1

  1. Fine-tune retriever θ\theta2 via InfoNCE contrastive loss:

θ\theta3

For KB poisoning:

  1. Select a pool θ\theta4 of real vulnerable snippets.
  2. Cluster clean KB embeddings into θ\theta5 clusters; let θ\theta6.
  3. For centroid θ\theta7, choose θ\theta8.
  4. SDI injects θ\theta9 into each 0.05%0.05\%0.
  5. Insert the 0.05%0.05\%1 poisoned snippets.

Pseudocode for SDI: 0.05%\leq 0.05\%6

3. Statistical Indistinguishability and Stealth

VenomRACG achieves stealth by ensuring that poisoned snippets are embedded and token-distributed so as to be indistinguishable from benign samples. Trigger tokens are selected using a composite score:

0.05%0.05\%2

where 0.05%0.05\%3 are token frequencies in vulnerable and clean corpora, 0.05%0.05\%4 is total vulnerable samples, and 0.05%0.05\%5. SDI places triggers at locations maximizing latent embedding shift, avoiding distributional or token-level anomalies.

No explicit KL or MMD values are reported, but standard defenses relying on spectral or activation outliers (Spectral Signature, Activation Clustering) measure negligible divergence. Spectral Signature detector recall is 0.05%0.05\%6—no outliers are detected.

4. Injection Ratio and Attack Success Dynamics

VenomRACG typifies efficiency: in the principal experiments, only 0.05%0.05\%7 poisoned snippets are injected into a KB of size 0.05%0.05\%8, yielding 0.05%0.05\%9. Varying qQτq \in Q_\tau0 from qQτq \in Q_\tau1 to qQτq \in Q_\tau2 (qQτq \in Q_\tau3 to qQτq \in Q_\tau4) allows attack success rate (ASR) to scale smoothly: qQτq \in Q_\tau5 for qQτq \in Q_\tau6, qQτq \in Q_\tau7 for qQτq \in Q_\tau8. Data-level artifacts remain minimal—Table 1 and Figure 1 in the source report no increase in detection rates for moderately larger qQτq \in Q_\tau9.

5. Empirical Evaluation: Retrieval, Generation, and Defense Evasion

Retriever performance metrics:

  • Clean baseline MRR: τ\tau0
  • VenomRACG MRR (white-box): τ\tau1; BadCode reduces MRR to τ\tau2
  • ASR@5 on target queries (“given,” “file,” “get”): τ\tau3–τ\tau4 for VenomRACG; τ\tau5 for DeadCode/BadCode

Generator impact (Vulnerability Rate VR):

  • “LLM-as-a-Judge” on top-10: τ\tau6–τ\tau7, τ\tau8–τ\tau9
  • Clean baseline VR: 0.05%\leq 0.05\%0–0.05%\leq 0.05\%1

Defense detection rates (recall of identifying poisoned samples):

Attack AC SS KillBadCode
DeadCode 91 6 100
BadCode 82 4 100
VenomRACG 65 0 65

VenomRACG escapes detection by Spectral Signature entirely and maintains substantially lower recall rates against Activation Clustering and KillBadCode compared to baseline attacks.

6. Stealth Characteristics, Systemic Limitations, and Operational Assumptions

VenomRACG maintains behavioral stealth: retrieval quality and code generation fidelity under non-target queries are indistinguishable from clean deployments; in instances, MRR is slightly improved. At the data level, only 0.05%\leq 0.05\%2 poisoned snippets (0.05%\leq 0.05\%3 KB) suffice to render ASR@5 near 0.05%\leq 0.05\%4 without measurable artifacts.

Operational limitations include:

  • Requirement for retriever supply-chain compromise and injection privileges in the live KB.
  • Assumptions about retriever architecture and training protocols, specifically InfoNCE-tuned representations and trigger effectiveness.
  • The generator is assumed to synthesize outputs directly from top-k retrieved candidates without additional security filtering.

A plausible implication is that supply-chain retriever backdoors are both subtle and devastating; merely ten KB insertions can shift production code generation by 0.05%\leq 0.05\%5 towards vulnerable outputs in targeted scenarios.

7. Potential Defenses and Mitigation Strategies

The study suggests the following avenues for defense:

  • Robust contrastive retriever training: Integrate adversarial code perturbations to prevent the retriever from latching onto spurious token associations.
  • Differentially-private fine-tuning: Limit model sensitivity to individual injected examples, reducing attack leverage.
  • Trigger-aware screening: Systematically scan new KB snippets for tokens matching vulnerability-trigger profiles.
  • Retrieval-time sanitization: Impose constraints ensuring that retrieval ranking cannot shift dramatically due to a single token; enforce semantic anchoring.
  • End-to-end output monitoring: Employ generators to surveil for unusual vulnerability patterns in generated code, raising automated alerts under suspicious output concentrations.

Without the adoption of such measures, VenomRACG establishes that retriever backdooring is an impactful and undetectable supply-chain risk for RACG systems (Li et al., 25 Dec 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to VenomRACG.