Skip to content

Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.

feat(secrets): detect Google OAuth client secrets (GOCSPX-...) (#87)

Ahmad Ghozalia3908091cfa6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e7f0f11..be75497 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,6 +94,7 @@
link), so a GitHub code scanning alert shows the fix in its side panel. `--list-rules --json` and the MCP
`list_rules` tool include each rule's `fix`.
- CLI: `safe-anything --help` now shows a few examples, including `safe-anything mcp`, and how to ignore a finding (`safe-anything:ignore` or `.safe-anything-ignore`).
+- Secrets: new rule `secret.google-oauth-secret` (high) for Google OAuth client secrets (`GOCSPX-` followed by 28 letters, digits, `_` or `-`).
## 1.0.2 (2026-11-23)
diff --git a/README.md b/README.md
index 4a3d2bf..490dc60 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ Every finding comes with the line, the reason and the fix.</p>
<a href="https://github.com/erkamyaman/safe-anything"><img src="https://img.shields.io/github/stars/erkamyaman/safe-anything?style=social" alt="GitHub stars"></a>
</p>
-<p align="center"><b><a href="#quick-start">Install</a></b> · <a href="https://github.com/erkamyaman/safe-anything/releases">Releases</a> · <a href="#for-ai-agents">Claude Code plugin</a> · <a href="#in-ci">GitHub Action</a> · <a href="docs/rules.md">All 91 rules</a> · <a href="docs/agent-setups.md">Agent setups</a><br>
+<p align="center"><b><a href="#quick-start">Install</a></b> · <a href="https://github.com/erkamyaman/safe-anything/releases">Releases</a> · <a href="#for-ai-agents">Claude Code plugin</a> · <a href="#in-ci">GitHub Action</a> · <a href="docs/rules.md">All 92 rules</a> · <a href="docs/agent-setups.md">Agent setups</a><br>
Made in Türkiye 🇹🇷 by <a href="https://github.com/erkamyaman">erKam Yaman</a>, who also made <a href="https://github.com/erkamyaman/rust-anything">rust-anything</a> · <a href="https://github.com/sponsors/erkamyaman">❤️ Sponsor me</a> · Sponsored by <a href="https://coderabbit.link/er-kam">CodeRabbit</a></p>
<p align="center">
@@ -104,13 +104,13 @@ it hides that finding.
## What it finds
-91 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
+92 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
The full list is in [docs/rules.md](docs/rules.md).
| | |
| --- | --- |
| **Code** | SQL injection, command injection, XSS (`innerHTML`, `dangerouslySetInnerHTML`, `v-html`, `echo $_GET`, `raw`), `eval` and `new Function`, path traversal, file inclusion from request input, SSRF, open redirects, unsafe deserialization (pickle, `yaml.load`, `ObjectInputStream`, `BinaryFormatter`, `unserialize`, `Marshal`), TLS checks turned off, MD5/SHA-1, DES/RC4/ECB, JWT `none`, template injection, CORS `*`, debug mode, insecure cookies, `Math.random` tokens, `GRANT ALL` and plain-text passwords in SQL files. JS/TS, Python, Go, Java, Kotlin, PHP, Ruby, C#, SQL |
-| **Secrets** | AWS (key ids and secret access keys), GitHub, GitLab, Slack, Stripe, Shopify, npm, PyPI, OpenAI, Anthropic, Groq, Google, Hugging Face, Mailgun, SendGrid, Telegram, DigitalOcean and Twilio keys, Slack and Discord webhook URLs, private keys (also inside service-account JSON), passwords in code, credentials in connection strings, committed `.env` files, real values in `.env.example`, a `.gitignore` that misses `.env`, secrets behind public prefixes (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`) that ship in the client bundle |
+| **Secrets** | AWS (key ids and secret access keys), GitHub, GitLab, Slack, Stripe, Shopify, npm, PyPI, OpenAI, Anthropic, Groq, Google, Hugging Face, Mailgun, SendGrid, Telegram, DigitalOcean and Twilio keys, Google OAuth client secrets, Slack and Discord webhook URLs, private keys (also inside service-account JSON), passwords in code, credentials in connection strings, committed `.env` files, real values in `.env.example`, a `.gitignore` that misses `.env`, secrets behind public prefixes (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`) that ship in the client bundle |
| **Agent setups** | `bypassPermissions` and `--dangerously-skip-permissions`, pre-approved `Bash`, `enableAllProjectMcpServers`, MCP servers run with unpinned `npx`/`uvx`/`docker`, MCP tokens in plain text, remote MCP over `http://`, `curl \| sh` in hooks and skills, prompt-injection text, skills that read `~/.ssh` or cloud credentials, invisible Unicode in instructions. [More](docs/agent-setups.md) |
| **Mobile** | Android `debuggable`, `allowBackup`, cleartext traffic, exported content providers, WebView file access and JS bridges, world-readable files; iOS ATS turned off; tokens in UserDefaults, SharedPreferences, AsyncStorage or localStorage |
| **Config** | Docker (unpinned base, root, secrets in `ENV`, `ADD <url>`), `curl \| sh` in scripts, Dockerfiles and workflow `run:` steps, GitHub Actions (`pull_request_target`, `write-all`, actions on `@main`, script injection from PR titles), privileged containers, `hostNetwork`, Terraform (open ingress, public buckets, S3 public access blocks turned off, public or unencrypted databases), nginx autoindex, TLS 1.0/1.1 |
@@ -194,7 +194,7 @@ lockfile listed under Dependencies. Nothing is executed. The only network call i
names and versions to OSV.dev ([privacy](docs/privacy.md)).
It finds known patterns; it does not trace data through your program. A clean scan means none of
-these 91 problems were found, not that the code is safe. [Design notes](docs/adr).
+these 92 problems were found, not that the code is safe. [Design notes](docs/adr).
## Credits
diff --git a/docs/assets/social.html b/docs/assets/social.html
index c0cf8df..c46268b 100644
--- a/docs/assets/social.html
+++ b/docs/assets/social.html
@@ -31,7 +31,7 @@
<p class="sub">Code, secrets, mobile, cloud config, dependencies, and the AI agent setup that writes it all. One command.</p>
<div class="stats">
<div class="stat"><b>&lt;0.1 s</b><small>for 1,195 files (Juice Shop, M4)</small></div>
- <div class="stat"><b>72 rules</b><small>with CWE and OWASP ids</small></div>
+ <div class="stat"><b>92 rules</b><small>with CWE and OWASP ids</small></div>
<div class="stat"><b>100% Rust</b><small>one binary, no runtime</small></div>
</div>
</div>
diff --git a/docs/rules.md b/docs/rules.md
index 209edf8..3593470 100644
--- a/docs/rules.md
+++ b/docs/rules.md
@@ -32,7 +32,7 @@ Every rule safe-anything checks, generated from `safe-anything --list-rules --js
| [`code.sql-grant-all`](https://cheatsheetseries.owasp.org/cheatsheets/Database_Security_Cheat_Sheet.html) | medium | [CWE-250](https://cwe.mitre.org/data/definitions/250.html) | A01:2021 Broken Access Control | A database user gets every privilege on every database. |
| [`code.sql-plaintext-password`](https://cheatsheetseries.owasp.org/cheatsheets/Database_Security_Cheat_Sheet.html) | medium | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A database password is written in a SQL file. |
-## Secrets (28)
+## Secrets (29)
| Rule | Severity | CWE | OWASP | What it means |
| --- | --- | --- | --- | --- |
@@ -52,6 +52,7 @@ Every rule safe-anything checks, generated from `safe-anything --list-rules --js
| [`secret.openai-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | An OpenAI API key is written in the file. |
| [`secret.groq-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Groq API key is written in the file. |
| [`secret.google-api-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Google API key is written in the file. |
+| [`secret.google-oauth-secret`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Google OAuth client secret is written in the file. |
| [`secret.mailgun-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Mailgun API key is written in the file. |
| [`secret.sendgrid-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A SendGrid API key is written in the file. |
| [`secret.telegram-bot-token`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Telegram bot token is written in the file. |
diff --git a/src/rules/secrets.rs b/src/rules/secrets.rs
index e1ad525..38be85a 100644
--- a/src/rules/secrets.rs
+++ b/src/rules/secrets.rs
@@ -283,6 +283,12 @@ pub static RULES: &[Rule] = &[
r"\bAIza[0-9A-Za-z_\-]{35}",
"A Google API key is written in the file."
),
+ secret!(
+ "secret.google-oauth-secret",
+ High,
+ r"\bGOCSPX-[A-Za-z0-9_\-]{28}(?:[^A-Za-z0-9_\-]|\z)",
+ "A Google OAuth client secret is written in the file."
+ ),
secret!(
"secret.mailgun-key",
Critical,
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index deb658d..ddb02e4 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -53,6 +53,8 @@ pub fn fake(name: &str) -> String {
"anthropic" => ["sk-", "ant-api03-", &body(40, MIXED)].concat(),
"openai" => ["sk-", "proj-", &body(48, MIXED)].concat(),
"google" => ["AI", "za", &body(35, MIXED)].concat(),
+ "google-oauth" => ["GO", "CSPX-", &body(28, MIXED)].concat(),
+ "google-oauth-hyphen" => ["GO", "CSPX-", &body(27, MIXED), "-"].concat(),
"mailgun" => ["ke", "y-", &body(32, HEX)].concat(),
"groq" => ["gs", "k_", &body(52, MIXED)].concat(),
"telegram" => ["1234", "567890", ":", &body(35, MIXED)].concat(),
diff --git a/tests/fixtures/secrets/EXPECTED b/tests/fixtures/secrets/EXPECTED
index 65b4ec6..795e12e 100644
--- a/tests/fixtures/secrets/EXPECTED
+++ b/tests/fixtures/secrets/EXPECTED
@@ -44,4 +44,6 @@ aws/credentials:3 secret.aws-secret-key
config.py:43 secret.aws-secret-key
config.py:47 secret.aws-secret-key
config.py:48 secret.aws-secret-key
-config.py:55 secret.aws-secret-key
\ No newline at end of file
+config.py:55 secret.aws-secret-key
+config.py:57 secret.google-oauth-secret
+config.py:58 secret.google-oauth-secret
\ No newline at end of file
diff --git a/tests/fixtures/secrets/config.py b/tests/fixtures/secrets/config.py
index 996cfe5..7d76911 100644
--- a/tests/fixtures/secrets/config.py
+++ b/tests/fixtures/secrets/config.py
@@ -53,4 +53,8 @@ aws_secret_access_key = "0000000000000000000000000000000000000000"
aws_secret_access_key = "TestSecretKeyTestSecretKeyTestSecretKey1"
aws_secret_path = "/Prod/East1/Payments/Stripe/Billing/Keys"
aws_secret_a=0000000000000000000000000000000000000000,aws_secret_key={{fake:aws-secret}}
-aws_secret_access_key = "{{fake:aws-secret}}A"
\ No newline at end of file
+aws_secret_access_key = "{{fake:aws-secret}}A"
+google_oauth = "{{fake:google-oauth}}"
+google_oauth_hyphen = "{{fake:google-oauth-hyphen}}"
+google_oauth_short = "GOCSPX-short"
+google_oauth_long = "{{fake:google-oauth}}X"
\ No newline at end of file