TL;DR
This paper tackles the challenging problem of attributing authorship to small, incomplete code fragments found in collaborative software projects. They demonstrate that existing stylometric techniques can be adapted to this "in the wild" scenario, achieving reasonable accuracy and proposing methods to improve reliability and handle open-world scenarios where the true author might not be in the suspect list.
What Problem Does This Paper Address?
Attributing authorship to source code has significant implications, from identifying intellectual property theft to understanding the origins of malicious code. While previous work has successfully attributed authorship to complete, single-authored code files (often from controlled environments like coding competitions), this paper addresses the much harder problem of attributing authorship to small, incomplete code fragments found in real-world collaborative projects, like those hosted on GitHub. These fragments, often just a few lines long and potentially modified by multiple authors over time, present a significant challenge due to their limited stylistic information and the complexities of collaborative development. The authors aim to determine if authorship attribution is feasible in such "messy" real-world conditions and how to make these attributions more reliable.
Methods
The core of the paper adapts the stylometric techniques developed by Caliskan-Islam et al. [12], which use features extracted from Abstract Syntax Trees (ASTs) and word unigrams. Key methodological contributions include:
- Data Preparation: Using
git blameto segment collaborative code files into individual lines or small chunks, attributing them to the last author who modified them. These segments are then encapsulated in dummymainfunctions to allow AST parsing. - Feature Extraction: Extracting features from AST nodes, node bigrams, word unigrams, API symbols, and keywords, using both raw counts and TFIDF.
- Classification: Employing Random Forests as the primary classifier.
- Multiple Sample Attribution: For cases where multiple samples can be linked to the same unknown author (e.g., from a single version control account), the authors aggregate the probability distributions of the classifier's predictions, rather than just the predicted classes, to improve accuracy.
- Calibration Curves: Constructing calibration curves to assess the trustworthiness of attributions based on classifier confidence. This helps in setting thresholds for accepting predictions and identifying potentially "out-of-world" (unknown) authors.
- Open World Analysis: Developing techniques to handle scenarios where the true author might not be among the predefined suspect set, using confidence thresholds derived from calibration curves.
Datasets
- GitHub: The primary dataset used for training and evaluation consists of C++ repositories collected from GitHub. After filtering for sufficient data and quality, this resulted in a dataset of 104 programmers.
- Google Code Jam: Used for a specific experiment to assess the impact of ground truth corruption, as this dataset is known to have more reliable ground truth than GitHub.
Key Insights and Ideas
- "In the Wild" Attribution is Possible, but Harder: The paper convincingly shows that authorship attribution of small code fragments from collaborative projects is feasible, but significantly harder than for complete files from controlled environments. The accuracy drops considerably when moving from ideal datasets to real-world code.
- Ensembling Small Samples is Crucial: Aggregating predictions from multiple small samples belonging to the same author (account attribution) dramatically improves accuracy compared to attributing single samples. This highlights the importance of leveraging linked contributions.
- Calibration is Key for Trust and Open Worlds: Calibration curves are essential for understanding the reliability of attributions. They provide a mechanism to set confidence thresholds, which is vital for distinguishing between likely suspects and unknown authors in open-world scenarios.
- Within-Author Variance is a Major Hurdle: The authors identify high variance in an author's style across different code snippets as a primary challenge, making attribution more difficult.
- Feature Importance: Word unigrams are found to be the most important features, likely due to their prevalence and the fact that they can capture information beyond just code structure, such as comments and licensing.
Key Results
- Single Sample Attribution Accuracy: For individual code fragments, the baseline accuracy was around 48.8% (by sample) or 61.4% (by author), significantly lower than previous work on full files.
- Multiple Sample Attribution Accuracy: By aggregating predictions from multiple samples belonging to the same author, accuracy significantly improved. For example, with 50 aggregated samples, accuracy could reach over 90%.
- Open World Performance: The proposed calibration-based thresholding method showed promise in identifying "out-of-world" samples. For instance, in one experiment, by setting a threshold, they could discard 96.3% of incorrect and out-of-world samples while retaining 40.3% of correct attributions.
- Feature Importance: Word unigrams accounted for the largest feature importance (0.5584), followed by AST node bigrams (0.1815).
Limitations and Future Work
- Ground Truth Imperfections: The authors acknowledge that
git blameprovides "ground truth" based on the last commit, which might not reflect the original author of a line if code was copied or heavily modified. They also note the possibility of code being copied from other sources. - Dataset Size and Collaboration Levels: The dataset, while large, still resulted in a relatively small number of usable samples per author. The study also primarily focused on single collaborative projects, and future work could explore varying levels of collaboration and project diversity.
- Removing Version Control Assumption: While the paper makes strides in handling open-world scenarios, a key assumption is that code is segmented by author (e.g., via commits or
git blame). Future work aims to remove this by developing source code segmentation techniques that don't rely on version control history. - Improving Predictors: The authors suggest that classifier confidence alone might not be the best predictor of attribution correctness and propose combining it with other features like sample length.
- Investigating Obfuscation: Exploring the effectiveness of existing code obfuscation tools against these attribution techniques is also a future direction.
- Privacy and Anonymity: The authors express concern about the privacy implications of this technology and aim to develop tools for programmers to better anonymize themselves and for repository owners to facilitate anonymity.
Summary updated