Papers › Adversarial Examples for Models of Code

Adversarial Examples for Models of Code

15 Oct 2019arXiv:1910.07517archive 2025-07-28

Noam Yefet, Uri Alon, Eran Yahav

Neural models of code have shown impressive results when performing tasks such as predicting method names and identifying certain kinds of bugs. We show that these models are vulnerable to adversarial examples, and introduce a novel approach for attacking trained models of code using adversarial examples. The main idea of our approach is to force a given trained model to make an incorrect prediction, as specified by the adversary, by introducing small perturbations that do not change the program's semantics, thereby creating an adversarial example. To find such perturbations, we present a new technique for Discrete Adversarial Manipulation of Programs (DAMP). DAMP works by deriving the desired prediction with respect to the model's inputs, while holding the model weights constant, and following the gradients to slightly modify the input code. We show that our DAMP attack is effective across three neural architectures: code2vec, GGNN, and GNN-FiLM, in both Java and C#. Our evaluations demonstrate that DAMP has up to 89% success rate in changing a prediction to the adversary's choice (a targeted attack) and a success rate of up to 94% in changing a given prediction to any incorrect prediction (a non-targeted attack). To defend a model against such attacks, we empirically examine a variety of possible defenses and discuss their trade-offs. We show that some of these defenses can dramatically drop the success rate of the attacker, with a minor penalty of 2% relative degradation in accuracy when they are not performing under attack. Our code, data, and trained models are available at https://github.com/tech-srl/adversarial-examples .

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="1910.07517")

Code

Syntology Ran 5 of 10 code samples harvested from 2 repositories linked to this paper; 5 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 3 ran · fixture could not drive it.

By repository: community (archive-listed): 6 samples from 2 repositories, 1 ran; 4 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

tech-srl/adversarial-examples officialmentioned in papermentioned on GitHubtf report
ciselab/lampion mentioned on GitHub report
tech-srl/code2seq mentioned on GitHubtfMIT report
tech-srl/code2vec mentioned on GitHubtfMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 5 ran; 0 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
3ran · fixture could not drive it
5unverified

Licence: 4 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

count_ngrams ciselab/lampion/Experiments/CodeBert_CodeToText/evaluation/bleu_evaluator.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 835fca2953749b59 · report
context_full_found tech-srl/code2seq/preprocess.py community (archive-listed) unverified MIT (permissive) · 18b183ec6c1e7a9c · report
context_partial_found tech-srl/code2seq/preprocess.py community (archive-listed) unverified MIT (permissive) · 7ee03048482708c8 · report
get_immediate_subdirectories tech-srl/code2seq/CSharpExtractor/extract.py community (archive-listed) unverified MIT (permissive) · 94cb8d60c8256a0a · report
process_file tech-srl/code2seq/preprocess.py community (archive-listed) unverified MIT (permissive) · 8de0a4310800437e · report
split_subtokens tech-srl/code2seq/baseline_tokenization/subtokenize_nmt_baseline.py community (archive-listed) unverified MIT (permissive) · 31a0c940fadc75d5 · report
adversary_by_prefix_random identical code first harvested elsewhere ran · fixture could not drive it fingerprinted licence of this copy not recorded · 9ab8f76e5ee9bc91 · report
construct_name_from_ints identical code first harvested elsewhere ran · fixture could not drive it licence of this copy not recorded · 4534c7d95faadccc · report
get_label_length identical code first harvested elsewhere ran · fixture could not drive it fingerprinted licence of this copy not recorded · 748bf8510e84bca3 · report
init_deadcode_variable identical code first harvested elsewhere ran · our draft was wrong licence of this copy not recorded · d2024a1a569eaabf · report

Tasks

Prediction

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

GGS-NNs

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections