Fooling MOSS Detection with Pretrained Language Models

Stella Biderman, Edward Raff

Abstract

As artificial intelligence (AI) technologies become increasingly powerful and prominent in society, their misuse is a growing concern. In educational settings, AI technologies could be used by students to cheat on assignments and exams. In this paper we explore whether transformers can be used to solve introductory level programming assignments while bypassing commonly used AI tools to detect similarities between pieces of software. We find that a student using GPT-J [Wang and Komatsuzaki, 2021] can complete introductory level programming assignments without triggering suspicion from MOSS [Aiken, 2000], a widely used software similarity and plagiarism detection tool. This holds despite the fact that GPT-J was not trained on the problems in question and is not provided with any examples to work from. We further find that the code written by GPT-J is diverse in structure, lacking any particular tells that future plagiarism detection techniques may use to try to identify algorithmically generated code. We conclude with a discussion of the ethical and educational implications of large language models and directions for future research.

Introduction

In computer science education, the integrity of programming assignments has long been protected by tools like MOSS (Measure of Software Similarity). MOSS is designed to identify structural overlaps between submissions, effectively catching traditional forms of cheating such as variable renaming, loop restructuring, or "contract plagiarism." However, the advent of Large Language Models (LLMs) like GPT-J introduces a new paradigm: de novo code generation.

This paper investigates whether a student with minimal technical knowledge can leverage publicly available LLMs to generate unique solutions that bypass industry-standard detection. The core question is whether AI-generated code possesses a recognizable "fingerprint" or if it can blend seamlessly into the pool of independent human-written solutions.

Methodology

The researchers simulated a "minimally knowledgeable student" attempting to solve seven introductory Java exercises from a benchmark dataset (Karnalim et al., 2019). The tasks ranged from basic output commands to complex matrix manipulations.

Prompting and Generation

The study utilized GPT-J, a 6-billion parameter model. The authors found that simple prompts—incorporating the exercise description and a directive like "Write a Java program that..."—were sufficient to guide the model. To maintain a realistic threat model, the researchers allowed for "light editing." This involved correcting obvious syntax errors that a compiler would flag, such as missing imports or the model's tendency to use LaTeX math symbols (e.g., ^) instead of Java methods (e.g., Math.pow()).

Stylistic Analysis

To understand the "stylistic space" of the generated code, the authors employed Isomap embeddings. This technique visualizes high-dimensional code features in a two-dimensional plane, allowing researchers to see if AI code clusters together or mimics human patterns.

Isomap embeddings (n=10 and k=100) visualizing the stylistic distribution of code. The AI-generated solutions do not form a distinct cluster, instead scattering across the space and often overlapping with independent human solutions.

Key Results

The results were striking: GPT-J produced correct or nearly correct solutions for 6 out of the 7 tasks. When these solutions were analyzed by MOSS alongside a dataset of original solutions, human-plagiarized variants (Levels 1-6), and independent "non-plagiarized" TA solutions, the AI code remained virtually invisible.

Box plot comparing MOSS similarity scores. AI-generated code (far right) shows similarity levels comparable to "non-plagiarized" (non) independent solutions, falling well below the thresholds of traditional human plagiarism (L1-L6).

As shown in the similarity analysis, MOSS is highly effective at catching lower-level plagiarism (Levels 1-3). However, GPT-J naturally produces code that mimics "Level 6" plagiarism—the most sophisticated form of human restructuring—without explicit instruction. In many instances, the AI-generated code was less similar to the original solution than the independent TA-written code was.

Discussion: The Fingerprint Fallacy

A common assumption in AI detection is that algorithmically generated content will have a predictable, detectable style. This study debunks this "Fingerprint Fallacy." The Isomap visualizations confirm that GPT-J’s output is stylistically diverse. Because the model generates code probabilistically rather than following a fixed template, it avoids the structural repetitions that similarity-based tools like MOSS are tuned to identify.

Furthermore, the errors the model does make—such as those derived from its LaTeX training data—are easily corrected by a novice student. These "tells" are fleeting and do not provide a robust basis for long-term automated detection.

Conclusion and Future Directions

The study concludes that traditional similarity-based detection is insufficient for the era of LLMs. As models become more powerful, the ability to generate "clean," unique solutions will only improve. The authors suggest that computer science curricula may need to shift away from take-home coding assignments as a primary metric of success. Instead, educators might incorporate AI into the classroom, asking students to critique, debug, or extend AI-generated snippets, or move toward more frequent in-person assessments. Future research must focus on more advanced structural analysis or watermarking techniques to preserve academic integrity.

Summary updated

BibTeX
@inproceedings{biderman2022fooling,
  author = {Stella Biderman and Edward Raff},
  title = {{Fooling MOSS Detection with Pretrained Language Models}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2022},
  url = {https://openreview.net/forum?id=WZ9ckRaBdS4},
}
Figure