Impeding LLM-assisted Cheating in Introductory Programming Assignments via Adversarial Perturbation

Saiful Islam Salim, Rubin Yuchan Yang, Alexander Cooper, Suryashree Ray, Saumya Debray, Sazzadur RahamanEMNLP 2024

Abstract As Large Language Models (LLMs) like ChatGPT and GitHub Copilot become ubiquitous, traditional computer science pedagogy faces a crisis of academic integrity. This research, presented at EMNLP 2024, proposes a proactive "defense-in-depth" strategy: modifying programming assignments to be "brittle" for AI solvers while remaining clear for human students. By employing adversarial perturbations—such as Unicode lookalike substitution and strategic rephrasing—researchers demonstrate a 77% average reduction in LLM performance across multiple models, offering a new tool for instructors to safeguard homework assignments.

The LLM "Arms Race" in Education

The core challenge in modern CS1/CS2 courses is that introductory assignments are often "solved" by LLMs with high accuracy, largely because these problems exist within the models' training data. Traditional AI detectors are notoriously unreliable, leading to high rates of false positives and negatives. This paper shifts the focus from detection to prevention: How can problem statements be modified to impede AI without hindering the student?

Methodology: A Systematic Framework

The researchers developed a three-step framework to study and implement these defenses:

  1. Baseline Measurement: Establishing the performance of five popular models (GPT-3.5, GitHub Copilot, Mistral, Code Llama, and CodeRL) on a curated set of 106 university assignments.
  2. Adversarial Perturbation: Designing 10 perturbation techniques, ranging from synonym substitution to character-level removals. To optimize these attacks, the team used SHAP (SHapley Additive exPlana-tions) with a surrogate model to identify the specific tokens that most influenced the LLM's output.
  3. User Study: An IRB-approved study with 30 undergraduate students to verify if humans could still solve the perturbed assignments and whether they could easily "reverse" the perturbations to cheat.
The three-step framework used to evaluate LLM performance, apply perturbations, and conduct field experiments with students.

Perturbation Strategies

The study utilized a mix of "Core" and "Exploratory" strategies. Core strategies included synonym substitution and replacing characters with Unicode lookalikes (e.g., replacing 'a' with 'à'). Exploratory strategies involved more aggressive changes like replacing function identifiers with random strings.

A comparison between an original prompt and a perturbed version, highlighting subtle character-level changes that disrupt LLM processing.

One of the most striking findings was the "brittleness" of code generation. In some instances, removing as few as five characters from a prompt dropped the correctness score from 100% to 0% for the majority of tested models. These subtle tweaks are often imperceptible to students but catastrophic for the underlying tokenization and logic of the LLM.

Key Results and Insights

  • Massive Performance Drop: The combination of perturbation techniques reduced the average correctness score of LLM-generated solutions by 77%.
  • Model Vulnerability: Even the strongest baseline, GitHub Copilot, saw significant degradation. While newer models like GPT-4 show more resilience than GPT-3.5, they remain susceptible to optimized perturbations.
  • Human Resilience: The user study revealed that even when students noticed a prompt looked "weird," they often could not easily "repair" the prompt to get a working solution from an AI. Crucially, the efficacy of the perturbation remained high even when the user was aware of it.
  • The Specificity Gap: LLMs struggled most with specific constraints, such as ASCII art descriptions or strict file-naming conventions, which are trivial for humans to follow but difficult for models to parse accurately.

Conclusion and Future Directions

While effective, adversarial perturbations involve a trade-off with understandability. High-efficacy changes, like removing entire sentences, can make problems harder for students to read. Future work aims to develop "imperceptible" perturbations—tweaks so minute that they bypass both human detection and model safety filters while still inducing logical errors in AI-generated code. This research marks a significant step toward a sustainable "defense-in-depth" approach to academic integrity in the age of AI.

Summary updated

BibTeX
@inproceedings{salim2024impeding,
  author = {Saiful Islam Salim and Rubin Yuchan Yang and Alexander Cooper and Suryashree Ray and Saumya Debray and Sazzadur Rahaman},
  title = {{Impeding LLM-assisted Cheating in Introductory Programming Assignments via Adversarial Perturbation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.27},
}
Figure