ISSTA 2026
Sun 4 - Fri 9 October 2026 Oakland, California, United States
co-located with SPLASH/ISSTA 2026

Neural code models, which automate foundational software engineering tasks such as code classification and generation, are critically vulnerable to backdoor attacks. Yet, existing defenses face a dual failure: they struggle with sophisticated threats spanning injection-based and semantically-equivalent transformation (\textit{SET-based}) backdoor attacks, and they rely on a restrictive assumption—a trusted, pre-verified \emph{in-distribution} clean seed set—that can be costly and difficult to obtain and audit in practice. This paper introduces Counterfactual Invariance-based Defense (CID), a clean-seed-free backdoor defense—requiring no \emph{a priori} trusted \emph{in-distribution} clean data—grounded in \emph{operational} counterfactual invariance tests. CID’s core insight is that clean and poisoned samples exhibit \emph{asymmetric counterfactual behavior}: clean predictions degrade under semantic context corruption (semantic sufficiency), whereas backdoor predictions change when a localized trigger is neutralized (trigger necessity). Accordingly, CID applies two orthogonal probes—a contextual intervention to test semantic sufficiency and a structural neutralization test guided by a gradient-based probe to test trigger necessity—to extract a high-purity clean seed set directly from a mixed dataset. This seed set then enables Mahalanobis-based clustering in representation space to partition the full dataset. Evaluated across four software engineering tasks and three model architectures, and further validated on multilingual code summarization, CID achieves strong poison detection performance among evaluated baselines while keeping false positives low in most settings. By eliminating reliance on \emph{a priori} trusted \emph{in-distribution} clean seed data, CID provides a practical pathway toward more secure deployment of neural code models.