Git Blame Who?: Stylistic Authorship Attribution of Small, Incomplete Source Code Fragments

Edwin Dauber, Aylin Caliskan, Richard Harang, Gregory Shearer, Michael Weisman, Frederica Nelson, Rachel Greenstadt · DOI

TL;DR

Code stylometry—the art of identifying who wrote a piece of source code based on stylistic choices—has traditionally required complete, compilable files. This paper breaks that limitation, demonstrating that developers can be accurately identified using small, incomplete, and uncompilable code fragments (like those found in GitHub commits). By aggregating predictions across multiple snippets linked to an account, the researchers achieve high-accuracy attribution, highlighting a significant deanonymization risk for open-source contributors.

What Problem Does This Paper Address?

Most prior work in code authorship attribution operates under "laboratory conditions": analyzing complete, single-author files from programming contests (like Google Code Jam) or student assignments. In the real world, however, software development is inherently collaborative. Code is modified in small increments, scattered across multiple files, and version-controlled.

The authors tackle authorship attribution "in the wild." They address whether it is possible to identify an author from small, incomplete fragments of code—averaging just 4.9 lines—that cannot be compiled on their own. This capability has profound implications for privacy (e.g., open-source contributors or activists who need to remain anonymous) as well as software forensics (e.g., identifying authors of malicious code or resolving copyright disputes).

Methods

The authors propose a multi-stage pipeline to process and classify partial source code samples:

  1. Segmentation: They use git blame on collaborative repositories to isolate consecutive lines of code written by the same author.
  2. Feature Extraction: Because these snippets are uncompilable, they wrap them in a dummy main() function and use a fuzzy parser called joern to generate an Abstract Syntax Tree (AST). They extract AST nodes, node bigrams, word unigrams, API symbols, and keywords. Unlike traditional methods, they retain the entire sparse feature set rather than pruning via information gain.
  3. Multiple Sample Ensembling: While classifying a single short snippet is difficult, the authors introduce an account-level ensembling technique. If multiple snippets can be linked to a single unknown account, they run each snippet through a Random Forest classifier and average the resulting probability distributions. The class with the highest average probability becomes the final prediction.
  4. Open-World Calibration: To handle cases where the true author isn't in the known suspect set, they construct calibration curves that map classifier confidence to actual accuracy. This allows analysts to set a threshold below which predictions are rejected as "out of world."
Fig. 1. Our method for authorship attribution of partial source code samples has multiple preprocessing and postprocessing stages.

Datasets

  • GitHub Dataset: The primary dataset was collected by spidering public C++ repositories on GitHub. After filtering for active developers with at least 150 valid code fragments, they finalized a dataset of 104 programmers. The number of test snippets per author varied up to nearly 220 (detailed in Figure 2).
  • Google Code Jam (GCJ) Dataset: Used as a clean baseline to run controlled experiments on "ground truth corruption" (deliberately swapping authors to simulate the noise of git blame).
Histogram of Author Contributions

Key Insights and Ideas

  • The Error-Canceling Effect of Linking: Individual short snippets contain very little stylistic information, leading to low baseline accuracy. However, because the Random Forest classifier is conservative, its misclassifications yield flat, evenly distributed low probabilities. When you average probabilities across multiple linked snippets from the same author, these random errors cancel out, allowing the correct author's signature to rise to the top.
  • Text Over Structure in Snippets: In full files, structural AST features provide the strongest authorship signals. In contrast, for small fragments, word unigrams (like comments, variable names, and specific function calls) dominate feature importance. This means snippet-level stylometry relies heavily on textual choices rather than structural habits.
  • Predictable Open-World Behavior: Misclassifications in an open-world scenario behave almost identically to general classifier errors. This means standard confidence thresholding via calibration curves is highly effective at filtering out unknown authors.

Key Results

  • Baseline vs. Ensembled Accuracy: On the 104-programmer dataset, classifying a single snippet yielded a baseline accuracy of only 48.8% (sample-averaged) or 61.4% (author-averaged). However, aggregating predictions over multiple samples drastically improved performance.
  • Data Volume Impact: As shown in preliminary testing with 15 authors (Figure 3), increasing both the training size and the number of aggregated testing samples drives accuracy toward 100%.
Accuracy vs Training and Testing Size
  • Open-World Performance: In an open-world setup with 26 suspects and 78 out-of-world authors, the calibration method successfully identified over 90% of the unknown authors within just a few threshold increments, demonstrating that analysts can reliably trust high-confidence attributions.

Limitations and Future Work

  • Noisy Ground Truth: Using git blame means attributing code to the last person who edited a line, which can introduce noise if a developer merely changed formatting or fixed a typo in someone else's logic.
  • Project-Style Conflation: Many authors in the dataset only contributed to a single collaborative project. It remains unclear how much the classifier is learning individual developer style versus the overarching coding guidelines of a specific repository.
  • Future Directions: The authors suggest exploring unsupervised methods to group unlinked snippets, testing the pipeline against dedicated code obfuscation tools (like Stunnix or Tigress), and moving toward AST-based code segmentation rather than line-based segmentation.

Summary updated

BibTeX
@inproceedings{dauber2017git,
  author = {Edwin Dauber and Aylin Caliskan and Richard Harang and Gregory Shearer and Michael Weisman and Frederica Nelson and Rachel Greenstadt},
  title = {{Git Blame Who?: Stylistic Authorship Attribution of Small, Incomplete Source Code Fragments}},
  booktitle = {Proc. Priv. Enhancing Technol},
  year = {2017},
}
Figure