DEV Community

Davi
Davi

Posted on Originally published at blog.mago.team

GitHub OSINT: What Developers Expose Without Realizing It

GitHub OSINT: What Developers Expose Without Realizing It

In September 2022, Toyota discovered that an access key to the database of 296,019 customers had been public on GitHub since December 2017. Five years. Anyone could have used it at any point during its public existence.

Attackers collect exposed credentials on GitHub in under 5 minutes. The median remediation time for teams is 94 days. The 89-day gap between those two numbers is the window where any attacker already has what they need. Any security policy that ignores this gap is theater.

The 5-Minute Window That Invalidates Your Security Policy

Reactive controls are ineffective by design. The gap between a credential exposure and automated collection by attackers is under 5 minutes; the median remediation time for teams is 94 days.

Unit 42 (Palo Alto Networks) documented automated collection of IAM credentials in under 5 minutes after exposure on GitHub. The Verizon DBIR 2025 reported that the median time to remediate a leaked secret is 94 days. The real exposure window before any internal action is 89 days.

GitHub found 39 million leaked secrets in 2024. GitGuardian reported 28.65 million new leaks in 2025, up 34% from the previous year. These numbers describe a system where the rate of production of new attack vectors consistently outpaces detection and response capacity.

A security policy that doesn't address the gap between exposure and detection isn't a security policy. It's compliance documentation.

What You're Exposing Right Now (and Probably Don't Know)

The exposure isn't limited to carelessly committed .env files. The real surface includes complete database connection strings (DATABASE_URL, MONGO_URI), API keys for critical services (AWS, GCP, OpenAI, Stripe, Twilio) committed in configuration files, SSH private keys and TLS certificates in infrastructure repositories, and JWT secrets hardcoded to make local development easier.

The 2025 data records one rapidly growing vector: AI service credentials increased 81% from the prior year. GitGuardian detected 113,000 DeepSeek API keys exposed in a single year. Each new AI service a team adopts adds a potential credential vector with no monitoring history configured.

The most underrated vector is git history. A secret deleted in the current commit exists in every prior revision of the repository. The GitHub API exposes this history for public repositories without authentication.

Reverting a commit doesn't remove the credential from history. The exposure window starts at the moment of the first commit, not at the moment of the attempted fix. Attackers monitoring the event stream collect the credential at the time of the original push; the subsequent revert is irrelevant to them.

Internal URLs and staging endpoints in configuration files complete the surface. They reveal the internal infrastructure architecture to anyone indexing the repository, including internal services that were never designed to be publicly accessible.

How Attackers Find Your Keys in Minutes Using the GitHub API

The GitHub Search API turns the platform into a credential surveillance system accessible to anyone. Queries like filename:.env DB_PASSWORD, extension:sql mysql dump, and api_key language:python return results in seconds, without authentication.

The GitHub Events API (api.github.com/events) broadcasts a public stream of every commit made on the platform. Automated tools consume this stream and scan each diff for known credential patterns. The time between a push and detection by an external monitoring system is less than the average code review.

In October 2025, the OffSeq Threat Radar documented an active mass reconnaissance campaign. Ghost accounts abuse the GitHub API to map entire organizations using user agents that mimic legitimate tools. The requests return HTTP 200 without triggering alerts in conventional monitoring systems.

Tools like gitrob automate complete surface mapping of an organization: repositories, members, configuration files, and commit history. The combination of GitHub Search with event stream monitoring and history scanning covers the entire public surface of an organization without any credentials on the attacker's side. Exposed credentials are consumed within a window shorter than a status meeting.

Three Incidents That Cost More Than Any Monitoring Tool

Toyota, Uber, and Twitch demonstrate that exposure via public repositories isn't an anomaly: it's the default mode of operation for teams without continuous monitoring. In none of these cases was detection internal.

Toyota is the most documented case. In December 2017, a subcontractor committed a symmetric key to a customer database in a public repository. The key remained exposed for five years. In September 2022, GitGuardian detected the exposure and notified the company; Toyota had not identified the issue internally.

The Uber breach in 2022 followed the same pattern. Credentials found in a public repository were part of the attack chain that exposed data from 57 million riders and drivers. The settlement reached USD 148 million. The original commit wasn't malicious: it was a developer who considered the repository secure.

Twitch and Samsung suffered similar exposures of source code and internal credentials via public repositories. The pattern is consistent: unintentional commit, detection always external. The root cause isn't isolated human error. It's the absence of continuous monitoring that would have made the error immediately visible.

Detection Tools Exist, But Arrive Too Late When Used Only in CI/CD

Gitleaks and TruffleHog are effective, but when run only in the CI/CD pipeline, they detect exposures that are already indexed, collected, and potentially exploited.

Gitleaks uses regex patterns with TOML configuration, operates without a network connection, and runs as a pre-commit hook in milliseconds. It blocks the commit before the secret reaches the repository. TruffleHog adds entropy analysis and makes real API calls to verify whether the detected credential is still active.

The configuration that provides layered coverage combines Gitleaks at pre-commit (prevention) with TruffleHog in CI/CD (detection of secrets that passed the first layer). AWS Labs' git-secrets configures local hooks to block specific AWS service patterns before the commit. The three tools combined have over 51,000 stars on GitHub and cover the most common credential patterns in production.

The critical gap in all three: none monitors what's already public in forks, gists, or third-party code that copied the repository. GitHub Secret Scanning (Advanced Security), even when enabled for the organization, covers only the repository where it's configured. When a developer creates a public fork of a repository that contains credentials in its history, those credentials fall outside the scope of any CI/CD scanner configured on the original repository.

Continuous Monitoring Is the Only Response That Closes the 89-Day Gap

The difference between proactive and reactive detection determines whether a leaked secret becomes a contained incident or a breach requiring regulatory notification. Continuous monitoring means active scanning of GitHub search, event streams, and paste sites in real time, not a weekly scan of the main repository.

The surface to monitor includes the organization name, corporate domains, proprietary API key patterns, and corporate email addresses. Any of these identifiers can appear in third-party repositories, gists, Pastebin, or leak forums. An operationally useful alert arrives in minutes, not days.

intel.mago.team automatically monitors the exposure surface: GitHub, GitLab, paste sites, and leak forums, with alerts that allow credential rotation before the exploitation window closes. Knowing about an exposure the same day is the difference between a contained incident and a breach report that goes to the regulator.

The Checklist That Closes the Immediate Gaps

Durable remediation doesn't depend on consistent human discipline. It depends on automation that blocks the vector before the commit and on visibility into what's already outside your control.

The audit starts with the existing history: git log --all -p | grep -iE 'api_key|password|secret|token' on the current repository identifies past exposures. Every credential with suspected exposure needs to be rotated before any other action, even if the commit has already been reverted.

For history rewriting, git-filter-repo removes committed secrets permanently and replaces the deprecated git filter-branch. Installing Gitleaks as a pre-commit hook via the pre-commit framework takes two commands and blocks commits matching the configured patterns.

Environment variables in a local .env with a global .gitignore configured eliminate the most common vector for accidental exposure. GitHub Secret Scanning enabled at the organization level is free for public repositories. External continuous monitoring covers the gap that none of these internal measures can reach: what has already been copied, forked, or indexed before any remediation action.

The commit has been made. The question is: who found it before you did?

Top comments (0)