Code Repository OSINT
GitHub, GitLab, and the like are among the most rewarding recon sources there are: a company’s developers (and their employees personally) push code that, by mistake, contains credentials, API keys, tokens, internal paths, infrastructure names, and sensitive logic. And remember: Git keeps the history, so a “deleted” secret is still there. Searching repos well finds access no scan would reveal.
What to look for
Section titled “What to look for”- Secrets: API keys (AWS, GCP, Stripe…), passwords, tokens, SSH/PGP private keys.
- Infrastructure: internal URLs, hostnames, IPs, non-public API endpoints.
- Logic: how authentication works, proprietary algorithms, validations (to break them).
- Employee repos: dotfiles and personal projects with work credentials.
GitHub code search (code dorking)
Section titled “GitHub code search (code dorking)”GitHub code search is a specific form of dorking. Some high-yield queries:
- By organization:
org:target-inc passwordandorg:target-inc "api_key". - By domain/hostname in the code:
"target.com" passwordand"internal.target.local". - By secret type:
"AKIA"(AWS access key id),"-----BEGIN RSA PRIVATE KEY-----". - By path/file:
path:.env DB_PASSWORD,path:config.php password. - By extension/path:
path:*.yml password,path:.github/workflows secret(current code search usespath:;filename:/extension:are legacy and may be treated as text).
And don’t forget the commit history and gists (public snippets people push and forget).
Automated tools
Section titled “Automated tools”trufflehog github --org=target-inc # high recall; verifies whether the key is livegitleaks detect --source . # local secret scantrufflehog git https://github.com/target-inc/repo # by a repo's commitsTruffleHog also verifies whether the found key is still active, which drastically cuts false positives. For automated GitHub dorking there are GitDorker, gitrob, and github-search.
Methodology
Section titled “Methodology”- Identify the org on GitHub/GitLab and its public repos.
- Enumerate employees (see People OSINT) and their personal accounts.
- Scan repos, history, and gists with trufflehog/gitleaks.
- Manually search specific dorks (domain,
"password",filename:.env). - Verify each secret: is it still live? what does it grant access to?
- If a
.git/is exposed on the web, reconstruct the code (see Exposed .git).
Beyond GitHub
Section titled “Beyond GitHub”The same mistakes appear on more platforms:
- GitLab, Bitbucket — same secrets-in-repos-and-history problems.
- Postman public workspaces — collections with tokens and internal endpoints.
- Docker Hub — images with secrets in layers or
ENVvariables. - npm / PyPI — internal packages published by mistake (dependency confusion).
- Pastebin and similar — credential dumps.
Common mistakes
Section titled “Common mistakes”- Looking only at current code and forgetting the history, where “deleted” secrets live.
- Not verifying the key: an expired or revoked secret isn’t a finding, it’s noise.
- Ignoring employees’ personal accounts, which often leak work credentials.
- Using a found secret against production out of scope: verify it only in an authorized way.
Defensive note
Section titled “Defensive note”Prevention: secret scanning in the pipeline (GitHub Advanced Security, gitleaks pre-commit), .gitignore for .env and keys, and rotating immediately any secret that reached a repo (deleting it from history isn’t enough: it must be rotated). Train employees on personal repos and monitor mentions of the org with the same tools an attacker would use.
Testing checklist
Section titled “Testing checklist”- Public repos of the org identified.
- Code dorks (
org:,"password",filename:.env,"AKIA"). - History and gists reviewed (“deleted” secrets).
- trufflehog / gitleaks over repos and commits.
- Employees’ personal accounts scanned.
- Secrets verified (live? what do they open?).
- Postman / Docker Hub / npm reviewed.
- Exposed
.git/on the web reconstructed.