The Curated Daily
← Back to the archiveDispatch · 6 min read
Dispatch

We stopped AI bot spam in our GitHub repo using Git's –author flag

By the editors·Monday, May 18, 2026·6 min read
Close-up of a hand holding a 'Fork me on GitHub' sticker, blurred background.
Photograph by RealToughCandy.com · Pexels

The world of open-source finance projects is vibrant and collaborative. However, with increased accessibility comes a growing challenge: AI-powered bot spam. Recently, our team experienced a surge in low-quality, AI-generated code commits flooding our GitHub repository. It was a serious threat to our project's integrity and developer productivity. This article details how we tackled this issue using a surprisingly effective and often overlooked tool: Git’s --author flag. We’ll cover the problem, our initial attempts at solutions, the implementation of the --author filter, and what we learned along the way.

The Rise of AI-Generated Code & the GitHub Spam Problem

Artificial intelligence, particularly large language models (LLMs) like GPT-3 and its successors, has made incredible strides in code generation. While this technology holds immense potential for assisting developers, it’s also being exploited for malicious purposes. Specifically, we started noticing a pattern of commits that exhibited several telltale signs of being AI-generated spam:

  • Generic Functionality: The code added often implemented simple, pre-existing functionality already available in well-established libraries. Think basic date calculations, simple data formatting, or trivial API wrappers.
  • Poor Code Quality: Despite appearing to compile, the code lacked proper error handling, comments, and adherence to our project's coding style guide. It was essentially functional, but not maintainable.
  • Irrelevant Changes: Some commits introduced changes unrelated to the project's core functionality or current roadmap.
  • Rapid Commit Frequency: A single "user" was responsible for a disproportionately large number of commits within a short timeframe, far exceeding typical human development speed.
  • Suspicious Author Names/Emails: Many of the commits came from newly created GitHub accounts with generic or obviously fabricated author names and email addresses.

This wasn't a case of someone contributing flawed but well-intentioned code. This was automated spam, designed to pollute our repository, potentially introduce vulnerabilities (even if minor), and waste our team’s time reviewing and reverting these changes. It was impacting our velocity and threatening the overall health of our project.

Initial Attempts at Mitigation: GitHub's Built-in Tools

Our first line of defense was leveraging GitHub's native features. We explored several options:

  • GitHub's Spam Filters: GitHub has built-in spam detection, but it proved insufficient to catch the subtle patterns of this AI-generated spam. The AI was generating valid code, even if it was low-quality, which bypassed the basic filters.
  • Reporting Users: We diligently reported the offending users to GitHub. However, the process was reactive – we were constantly playing catch-up. New accounts sprung up as quickly as we reported others.
  • Protected Branches & Required Code Reviews: We already had these in place, but the sheer volume of commits meant our reviewers were overwhelmed with trivial changes. It also created a bottleneck in the development process.
  • GitHub Actions for Automated Checks: We expanded our GitHub Actions to include more rigorous code quality checks (using linters like flake8 for Python), but these weren't designed to identify the origin of the problem – just the quality of the code. While helpful, they didn’t address the spam itself. Investing in more robust static analysis tools like SonarQube (https://example.com/) is something we’re considering for the future, but that’s a longer-term project.

These approaches provided some relief, but they weren’t scalable or proactive enough. We needed a way to prevent the spam from even entering our repository in the first place.

The –author Flag to the Rescue: A Git-Based Solution

That’s when we rediscovered Git’s --author flag. This flag, often overlooked, allows you to filter commits based on the author's name and/or email address. The key insight was that we could use this to create a "blocklist" of known spam authors.

Here’s how we implemented the solution:

  1. Identify Spam Authors: We compiled a list of the author names and email addresses associated with the problematic commits. This involved manually reviewing the commit history and identifying patterns.
  2. Create a Blocklist File: We created a simple text file (blocklist.txt) containing these author details, one author per line, in the format author_name <author_email>. For example:

AI Bot ai.bot@example.com

Code Generator <code.generator@spamdomain.net>

3. Implement a Git Filter: We integrated a Git filter into our CI/CD pipeline (using GitHub Actions). This filter utilizes the --author flag to reject any commits originating from the authors listed in blocklist.txt. The core command looks like this:

```bash

git log --author="$(cat blocklist.txt)" --exit-code

If this command returns a non-zero exit code, it indicates that a commit from a blocked author is present.  Our CI/CD pipeline is configured to fail if this command returns an error.  This effectively prevents the spam commits from being merged into our main branches.

4. Automated Blocklist Updates: To avoid constant manual updates, we built a simple script that periodically scans recent commits, identifies potential spam (based on heuristics like commit frequency and code characteristics), and automatically adds new authors to the blocklist.txt file. This script requires careful monitoring to avoid false positives, but it significantly reduces the administrative overhead.

Benefits of the –author Flag Approach

Using the --author flag offered several significant advantages:

  • Proactive Prevention: Unlike reporting users, this approach prevents the spam from entering our repository.
  • Scalability: The filter is automated and can handle a large volume of commits without manual intervention.
  • Simplicity: The solution is relatively simple to implement and maintain, requiring only basic Git knowledge.
  • Minimal Performance Impact: The Git filter adds a small overhead to the CI/CD pipeline, but it’s negligible compared to the time saved by not reviewing and reverting spam commits.
  • Doesn’t Rely on GitHub’s Spam Detection: This is a self-managed solution, independent of GitHub’s evolving spam filters.

Lessons Learned & Future Considerations

While the --author flag has been highly effective, we’ve learned some valuable lessons:

  • False Positives: It’s crucial to carefully curate the blocklist to avoid accidentally blocking legitimate contributors. Thoroughly investigate any potential author before adding them to the list.
  • Author Spoofing: Sophisticated spammers may attempt to spoof author information. We’re exploring additional techniques, such as analyzing commit timestamps and code characteristics, to identify and block these attempts.
  • Dynamic Blocklists: Maintaining an up-to-date blocklist is essential. Automated updates, combined with manual review, are key.
  • Complementary Approaches: The --author flag is most effective when combined with other security measures, such as protected branches, required code reviews, and robust code quality checks.

We’re also considering integrating this solution with a dedicated spam detection service, like those offered by Amazon GuardDuty (though primarily designed for cloud infrastructure, its principles might inspire further development) https://example.com/ or similar security platforms. These services leverage machine learning to identify and block malicious activity, potentially providing an additional layer of protection.

Conclusion

The influx of AI-generated code spam posed a significant challenge to our finance project’s development process. While GitHub’s built-in tools provided some assistance, they weren’t sufficient to address the problem. By leveraging the often-overlooked --author flag in Git, we were able to create a proactive and scalable solution that effectively blocked the spam and protected our codebase. It’s a testament to the power of fundamental Git tools, even in the face of emerging threats from AI-powered bots. This experience underscores the importance of remaining vigilant and adapting our security practices to stay ahead of malicious actors in the ever-evolving landscape of open-source development.

Disclaimer

Please note: This article contains affiliate links. If you purchase a product or service through one of these links, we may receive a small commission at no extra cost to you. This helps support our work and allows us to continue providing valuable content. We only recommend products and services that we believe are beneficial to our readers.

Pass it onX·LinkedIn·Reddit·Email
The Sunday note

If this was your kind of read.

Sign up for the morning email — short, hand-written, and sent only when there's something worth your time.

Free, sent from a person, not a system. Unsubscribe in one click whenever.

Keep reading

The archive →