keyleak-detector 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- keyleak_detector-0.5.0/LICENSE +22 -0
- keyleak_detector-0.5.0/PKG-INFO +512 -0
- keyleak_detector-0.5.0/README.md +476 -0
- keyleak_detector-0.5.0/keyleak/__init__.py +3 -0
- keyleak_detector-0.5.0/keyleak/access_control.py +144 -0
- keyleak_detector-0.5.0/keyleak/allowlist_diff.py +217 -0
- keyleak_detector-0.5.0/keyleak/archive_scanner.py +110 -0
- keyleak_detector-0.5.0/keyleak/baas_validator.py +932 -0
- keyleak_detector-0.5.0/keyleak/blast_radius.py +230 -0
- keyleak_detector-0.5.0/keyleak/browser_scanner.py +447 -0
- keyleak_detector-0.5.0/keyleak/chain_of_custody.py +121 -0
- keyleak_detector-0.5.0/keyleak/cli.py +525 -0
- keyleak_detector-0.5.0/keyleak/data/vendor_contacts.json +86 -0
- keyleak_detector-0.5.0/keyleak/data/worm_fingerprints.json +867 -0
- keyleak_detector-0.5.0/keyleak/demo.py +44 -0
- keyleak_detector-0.5.0/keyleak/detectors.py +1044 -0
- keyleak_detector-0.5.0/keyleak/detectors_ast.py +170 -0
- keyleak_detector-0.5.0/keyleak/detectors_dynamic.py +89 -0
- keyleak_detector-0.5.0/keyleak/detectors_fuzzy.py +211 -0
- keyleak_detector-0.5.0/keyleak/detectors_splittoken.py +182 -0
- keyleak_detector-0.5.0/keyleak/diff.py +94 -0
- keyleak_detector-0.5.0/keyleak/disclose.py +213 -0
- keyleak_detector-0.5.0/keyleak/doctor.py +188 -0
- keyleak_detector-0.5.0/keyleak/extension_bundle.py +194 -0
- keyleak_detector-0.5.0/keyleak/feeds.py +168 -0
- keyleak_detector-0.5.0/keyleak/local_scanner.py +670 -0
- keyleak_detector-0.5.0/keyleak/models.py +325 -0
- keyleak_detector-0.5.0/keyleak/offline_guard.py +104 -0
- keyleak_detector-0.5.0/keyleak/privacy_filter.py +80 -0
- keyleak_detector-0.5.0/keyleak/redaction.py +125 -0
- keyleak_detector-0.5.0/keyleak/reporting.py +429 -0
- keyleak_detector-0.5.0/keyleak/self_audit.py +437 -0
- keyleak_detector-0.5.0/keyleak/site_scanner.py +226 -0
- keyleak_detector-0.5.0/keyleak/sourcemaps.py +189 -0
- keyleak_detector-0.5.0/keyleak/suppressions.py +533 -0
- keyleak_detector-0.5.0/keyleak/watch.py +105 -0
- keyleak_detector-0.5.0/pyproject.toml +43 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 KeyLeak Detector
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: keyleak-detector
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Runtime leak detector for modern web apps — finds exposed API keys, BaaS misconfigurations (Supabase/Firebase RLS), and secrets in JS bundles, with a Chrome extension for real-time detection.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: security,api-keys,secrets,supabase,firebase,baas,vulnerability-scanner
|
|
8
|
+
Author: Amal David
|
|
9
|
+
Author-email: amal@utopianlabs.co
|
|
10
|
+
Requires-Python: >=3.9,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Requires-Dist: Flask (==2.2.5)
|
|
23
|
+
Requires-Dist: PyJWT (==2.10.1)
|
|
24
|
+
Requires-Dist: PyYAML (>=6.0,<7.0)
|
|
25
|
+
Requires-Dist: beautifulsoup4 (==4.12.2)
|
|
26
|
+
Requires-Dist: mitmproxy (==9.0.1)
|
|
27
|
+
Requires-Dist: playwright (==1.55.0)
|
|
28
|
+
Requires-Dist: python-dotenv (==1.0.0)
|
|
29
|
+
Requires-Dist: regex (==2023.10.3)
|
|
30
|
+
Requires-Dist: requests (==2.32.5)
|
|
31
|
+
Requires-Dist: tldextract (==5.1.2)
|
|
32
|
+
Project-URL: Bug Tracker, https://github.com/Amal-David/keyleak-detector/issues
|
|
33
|
+
Project-URL: Homepage, https://github.com/Amal-David/keyleak-detector
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# KeyLeak Detector
|
|
37
|
+
|
|
38
|
+
[](https://github.com/Amal-David/keyleak-detector)
|
|
39
|
+
[](LICENSE)
|
|
40
|
+
[](https://www.python.org/)
|
|
41
|
+
[](extension/)
|
|
42
|
+
[](https://github.com/Amal-David/keyleak-detector/releases)
|
|
43
|
+
|
|
44
|
+
Runtime leak detector for modern web apps. Finds exposed API keys, **validates BaaS misconfigurations** (Supabase RLS, Firebase Security Rules), and catches secrets in JavaScript bundles -- with a Chrome extension for real-time detection.
|
|
45
|
+
|
|
46
|
+
## What Makes This Different
|
|
47
|
+
|
|
48
|
+
Static scanners find hardcoded secrets in source code. KeyLeak finds the ones that only appear at runtime -- and then **proves they're exploitable**.
|
|
49
|
+
|
|
50
|
+
- **BaaS vulnerability scanner**: Detects Supabase/Firebase/Appwrite config in minified JS bundles, extracts table names, and actively probes whether Row-Level Security is enforced. A Supabase anon key is harmless if RLS works. KeyLeak tests whether it does.
|
|
51
|
+
- **Chrome extension**: Detects leaked keys in real-time as you browse. TEST button validates whether a found key is still active (supports 14 providers). JWT decoder surfaces suspicious claims (service_role, admin flags, broad scopes).
|
|
52
|
+
- **Site scanner**: Discovers subdomains, crawls pages, scans everything. One command for a full site audit.
|
|
53
|
+
- **200+ first-party domain suppression**: No false positives when browsing Google, AWS, Azure, GitHub, Stripe, etc.
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
### Chrome Extension (recommended for daily use)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Load the extension in Chrome
|
|
61
|
+
# 1. Open chrome://extensions
|
|
62
|
+
# 2. Enable "Developer mode"
|
|
63
|
+
# 3. Click "Load unpacked" → select the extension/ folder
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Browse any site. The extension icon shows a badge count for findings. Click to see details, TEST keys, and view remediation.
|
|
67
|
+
|
|
68
|
+
### CLI Scanner
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Install
|
|
72
|
+
poetry install && poetry run playwright install chromium
|
|
73
|
+
|
|
74
|
+
# Scan a single page
|
|
75
|
+
keyleak browser-scan https://your-app.vercel.app --html > report.html
|
|
76
|
+
|
|
77
|
+
# Scan with BaaS validation (tests Supabase RLS, Firebase rules)
|
|
78
|
+
keyleak browser-scan https://your-app.vercel.app --baas-validate --html > report.html
|
|
79
|
+
|
|
80
|
+
# Scan an entire site (subdomain discovery + page crawling)
|
|
81
|
+
keyleak site-scan example.com --depth 2 --baas-validate --html > report.html
|
|
82
|
+
|
|
83
|
+
# Scan local files
|
|
84
|
+
keyleak local . --fail-on high
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### HTML Report
|
|
88
|
+
|
|
89
|
+
The `--html` flag generates a self-contained dark-theme vulnerability report:
|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
## What It Detects
|
|
94
|
+
|
|
95
|
+
| Category | What | How |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| **BaaS misconfig** | Open Supabase tables, missing RLS, public storage buckets, callable RPCs | Active validation -- probes the REST API with only the anon key |
|
|
98
|
+
| **BaaS providers** | Supabase, Firebase, Appwrite, PocketBase | Config extraction from minified JS bundles |
|
|
99
|
+
| **API keys** | OpenAI, Anthropic, Gemini, Stripe, GitHub, AWS, and 20+ more | Regex detection + live TEST validation |
|
|
100
|
+
| **JWT analysis** | service_role exposure, admin flags, broad scopes, long expiry | Decode + claims analysis (no verification needed) |
|
|
101
|
+
| **Client-side auth** | `isAdmin === true` checks in browser JS | Pattern detection in bundles |
|
|
102
|
+
| **Write access** | Tables accepting INSERT/UPDATE without auth | `Prefer: tx=rollback` probing (never creates data) |
|
|
103
|
+
| **Auth config** | Missing email confirmation, exposed auth settings | Supabase auth endpoint probing |
|
|
104
|
+
| **Supply chain** | npm lifecycle hooks, Git-ref optionalDeps, Pwn Request patterns | AST + fingerprint detection |
|
|
105
|
+
| **Local files** | `.env`, MCP configs, CI workflows, Docker files, source maps | `keyleak local` scanner |
|
|
106
|
+
|
|
107
|
+
## Chrome Extension Features
|
|
108
|
+
|
|
109
|
+
- **Real-time BaaS detection**: Intercepts Supabase/Firebase API requests and probes RLS live
|
|
110
|
+
- **TEST button**: Validates keys against 14 providers (Gemini, OpenAI, Anthropic, GitHub, Stripe, Groq, etc.)
|
|
111
|
+
- **JWT decoder**: Click TEST on any JWT to see decoded claims with severity flags
|
|
112
|
+
- **Finding grouping**: Same key in multiple scripts = one card with clickable source URLs
|
|
113
|
+
- **AIza classification**: Distinguishes Google Maps keys (expected) from Gemini AI keys (leaked)
|
|
114
|
+
- **87 vendor CDN suppression**: No false positives from Google Analytics, PostHog, Segment, etc.
|
|
115
|
+
- **200+ first-party domains**: Google, Microsoft, AWS, Apple, Meta, Anthropic, Stripe -- their own keys on their own sites are never flagged
|
|
116
|
+
|
|
117
|
+
## v0.5.0 -- What's New
|
|
118
|
+
|
|
119
|
+
- **BaaS vulnerability scanner** with active validation (Supabase, Firebase, Appwrite, PocketBase)
|
|
120
|
+
- **Chrome extension** with real-time detection, TEST button, and JWT analysis
|
|
121
|
+
- **Site scanner CLI** (`keyleak site-scan`) with subdomain discovery
|
|
122
|
+
- **HTML report** output (`--html`)
|
|
123
|
+
- **20 new `baas` pack detectors**
|
|
124
|
+
- **Comprehensive false positive suppression** (200+ first-party domains, 87 vendor CDNs, cloud storage URLs, infra headers)
|
|
125
|
+
|
|
126
|
+
## False Positives
|
|
127
|
+
|
|
128
|
+
The Chrome extension suppresses findings from 200+ first-party domains (Google, AWS, Azure, GitHub, Stripe, etc.), 87 vendor CDN scripts, cloud storage signed URLs, and infrastructure headers. Despite this, you may encounter false positives on sites we haven't seen yet.
|
|
129
|
+
|
|
130
|
+
**If you find a false positive, please report it.** Open an issue with:
|
|
131
|
+
- The finding type (e.g., "GEMINI API KEY", "SQL INJECTION")
|
|
132
|
+
- The source (e.g., "External Script: cdn.example.com/lib.js")
|
|
133
|
+
- Why it's a false positive (e.g., "This is the vendor's own key in their CDN script")
|
|
134
|
+
|
|
135
|
+
We actively review reported FPs and add suppression rules. The more sites you browse with the extension, the better the suppression gets.
|
|
136
|
+
|
|
137
|
+
## The Delta Four Result
|
|
138
|
+
|
|
139
|
+
Every serious scan should lead to four things:
|
|
140
|
+
|
|
141
|
+
- `Verdict`: `SAFE TO SHIP`, `REVIEW`, or `BLOCK SHIP`.
|
|
142
|
+
- `Proof`: redacted evidence, source, detector, and confidence.
|
|
143
|
+
- `Fix`: exact remediation and rotation guidance.
|
|
144
|
+
- `Re-test`: the command or profile to run after fixing.
|
|
145
|
+
|
|
146
|
+
Example CLI result:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
keyleak scan https://preview.example.com
|
|
150
|
+
BLOCK SHIP: 1 critical, 0 high, 2 medium, 3 low
|
|
151
|
+
Critical or high-confidence exposures need fixing before release.
|
|
152
|
+
Re-test: keyleak scan https://preview.example.com
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## What It Checks
|
|
156
|
+
|
|
157
|
+
| Area | Status | Notes |
|
|
158
|
+
|---|---:|---|
|
|
159
|
+
| Runtime JS/API response secrets | Strong | Browser + proxy capture scans scripts, headers, URLs, and responses. |
|
|
160
|
+
| AI/LLM provider keys | Strong | OpenAI, Anthropic, Gemini, OpenRouter, Groq, Hugging Face, and more. |
|
|
161
|
+
| Cloud/SaaS/PAT/webhooks | Strong | AWS, GitHub, Stripe, Slack, SendGrid, PyPI, database URLs, private keys. |
|
|
162
|
+
| Auth-only leaks | Partial | Authenticated bearer/cookie scan support exists; two-user comparison is available with explicit second-user credentials. |
|
|
163
|
+
| SQLi/XSS/auth bypass leads | Opt-in | `appsec` pack labels these as leads until exploit validation exists. |
|
|
164
|
+
| IDOR/BOLA hints | Improved | Flags direct object references and can validate with two explicit user contexts. |
|
|
165
|
+
| Attack surface | Partial | Security headers, TLS, exposed files, admin paths, subdomain enumeration. |
|
|
166
|
+
| Local config leaks | New | `keyleak local` scans `.env`, MCP, CI, Docker, source maps, and logs. |
|
|
167
|
+
| Correctness/housekeeping | Opt-in | `correctness` and `housekeeping` packs catch N+1, regressions, off-by-one/date/config leads, missing tests, dead code, and stale docs. |
|
|
168
|
+
| Source maps/debug bundles | New | Local scanner detects source map content and provider keys. |
|
|
169
|
+
| GraphQL/LLM/agent hints | Early | Local detectors catch GraphQL introspection and prompt-injection-style text. |
|
|
170
|
+
|
|
171
|
+
KeyLeak is not a full DAST, not exploit automation, and not a replacement for GitLeaks, TruffleHog, GitHub secret scanning, or GitGuardian. It is the runtime/browser/local-config layer that complements them.
|
|
172
|
+
|
|
173
|
+
## How To Use It Now
|
|
174
|
+
|
|
175
|
+
Use the surface that matches your workflow.
|
|
176
|
+
|
|
177
|
+
### 1. Run The Web UI With Docker
|
|
178
|
+
|
|
179
|
+
This is the fastest way to try the browser scanner without installing Python dependencies locally.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
git clone https://github.com/Amal-David/keyleak-detector.git
|
|
183
|
+
cd keyleak-detector
|
|
184
|
+
docker compose up -d
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Open `http://localhost:5002`.
|
|
188
|
+
|
|
189
|
+
Use the page input for a basic runtime scan. Use the authenticated scan modal only with throwaway test credentials.
|
|
190
|
+
|
|
191
|
+
### 2. Run The Web UI Locally
|
|
192
|
+
|
|
193
|
+
Use this path when you want to develop the Flask app, scanner, templates, CSS, or JavaScript.
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
poetry install
|
|
197
|
+
poetry run playwright install chromium
|
|
198
|
+
poetry run python app.py
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Open `http://localhost:5002`.
|
|
202
|
+
|
|
203
|
+
If you do not use Poetry, create a virtual environment and install the package locally:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
python3.11 -m venv .venv
|
|
207
|
+
source .venv/bin/activate
|
|
208
|
+
pip install -r requirements.txt
|
|
209
|
+
pip install -e .
|
|
210
|
+
python -m playwright install chromium
|
|
211
|
+
python app.py
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 3. Scan Local Files And Configs
|
|
215
|
+
|
|
216
|
+
Use `keyleak local` before pushing or shipping. It scans local files without starting the web app.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
poetry install
|
|
220
|
+
poetry run keyleak local fixtures/vulnerable-demo
|
|
221
|
+
poetry run keyleak local . --json
|
|
222
|
+
poetry run keyleak local . --sarif --fail-on high
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
By default, local mode includes `env,mcp,ci,docker,sourcemaps,logs`.
|
|
226
|
+
|
|
227
|
+
Limit the scan to specific file families:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
poetry run keyleak local . --include env,mcp,sourcemaps
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Detector packs control the kind of failure patterns to look for. CLI/web default to `leak`; the extension default uses `leak,appsec,access-control`.
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
poetry run keyleak local . --packs leak,appsec,access-control --json
|
|
237
|
+
poetry run keyleak local . --launch-profile full --markdown
|
|
238
|
+
poetry run keyleak local . --launch-profile ci --fail-on high
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Exit codes are designed for automation: `0` means the selected threshold passed, `1` means the command failed, and `2` means findings met `--fail-on`.
|
|
242
|
+
|
|
243
|
+
### 4. Scan A Running Web App From The CLI
|
|
244
|
+
|
|
245
|
+
Use `keyleak scan` when you have a preview URL, staging URL, or local app URL.
|
|
246
|
+
|
|
247
|
+
The CLI talks to the local KeyLeak web scanner API, so start the web app first:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
poetry run python app.py
|
|
251
|
+
poetry run keyleak scan https://preview.example.com --json
|
|
252
|
+
poetry run keyleak scan https://preview.example.com --bearer "$TOKEN" --fail-on medium
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
You can also point the CLI at the Docker web scanner:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
docker compose up -d
|
|
259
|
+
poetry run keyleak scan http://host.docker.internal:3000 --server http://127.0.0.1:5002
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 5. Run Authenticated Scans
|
|
263
|
+
|
|
264
|
+
Use authenticated mode only against systems you own or have permission to test.
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
poetry run keyleak scan https://preview.example.com \
|
|
268
|
+
--profile authenticated \
|
|
269
|
+
--bearer "$THROWAWAY_TOKEN"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Use a cookie instead of a bearer token:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
poetry run keyleak scan https://preview.example.com \
|
|
276
|
+
--profile authenticated \
|
|
277
|
+
--cookie "session=throwaway-session"
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Use both when the app requires both:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
poetry run keyleak scan https://preview.example.com \
|
|
284
|
+
--profile authenticated \
|
|
285
|
+
--bearer "$THROWAWAY_TOKEN" \
|
|
286
|
+
--cookie "session=throwaway-session"
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
For access-control checks, provide a second throwaway user explicitly. KeyLeak will compare object-looking URLs as user A and user B and mark same-access evidence as validated:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
poetry run keyleak scan https://preview.example.com/users/123456 \
|
|
293
|
+
--profile authenticated \
|
|
294
|
+
--launch-profile bug-bounty \
|
|
295
|
+
--packs access-control \
|
|
296
|
+
--bearer "$USER_A_TOKEN" \
|
|
297
|
+
--bearer-b "$USER_B_TOKEN"
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### 6. Generate Reports For CI Or Review
|
|
301
|
+
|
|
302
|
+
Use JSON for baselines, SARIF for code scanning systems, and Markdown for human review.
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
poetry run keyleak local . --json > keyleak-report.json
|
|
306
|
+
poetry run keyleak local . --sarif > keyleak.sarif
|
|
307
|
+
poetry run keyleak local . --markdown > keyleak-report.md
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Fail on high or critical findings:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
poetry run keyleak local . --fail-on high
|
|
314
|
+
poetry run keyleak scan https://preview.example.com --fail-on critical
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Suppress known findings with a previous JSON report or allowlist:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
poetry run keyleak local . --baseline keyleak-report.json
|
|
321
|
+
poetry run keyleak local . --allowlist keyleak-allowlist.txt
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The default launch profile is `launch-gate`, which blocks on high and critical findings while keeping lower-severity hardening notes visible for review:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
poetry run keyleak local . --launch-profile launch-gate --fail-on high --json > keyleak-report.json
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
The repository includes a GitHub Actions launch gate at `.github/workflows/keyleak-launch-gate.yml` that runs the local scanner and uploads a JSON report artifact.
|
|
331
|
+
|
|
332
|
+
### 7. Use With Claude Code / Codex
|
|
333
|
+
|
|
334
|
+
The repo ships an agent skill at `.claude/skills/keyleak-verify/SKILL.md`. In any Claude Code session inside this repo, prompts like:
|
|
335
|
+
|
|
336
|
+
```text
|
|
337
|
+
Is this build safe to ship?
|
|
338
|
+
Run a launch-gate check on the preview URL https://preview.example.com.
|
|
339
|
+
Scan the current branch for leaked secrets before I deploy.
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
trigger the skill. The agent then chooses between `keyleak local` and `keyleak scan`, picks the right `--launch-profile` and `--fail-on` threshold, interprets the verdict JSON, and reports back with `BLOCK SHIP` / `REVIEW` / `SAFE TO SHIP` plus the top blocking findings and a re-test command. The skill respects the local-first trust model: it only scans systems you own, never auto-suppresses findings, and never echoes raw secret values back.
|
|
343
|
+
|
|
344
|
+
## Safe Demo
|
|
345
|
+
|
|
346
|
+
The repo includes an intentionally vulnerable local fixture:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
poetry run keyleak local fixtures/vulnerable-demo --markdown
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
This gives contributors and Hacker News readers a safe way to see a `BLOCK SHIP` result without scanning random systems.
|
|
353
|
+
|
|
354
|
+
## Web Scanner
|
|
355
|
+
|
|
356
|
+
Basic scan:
|
|
357
|
+
|
|
358
|
+
1. Loads the target in headless Chromium through mitmproxy.
|
|
359
|
+
2. Captures URLs, headers, responses, inline scripts, and DOM config data.
|
|
360
|
+
3. Applies custom and GitLeaks-derived secret patterns.
|
|
361
|
+
4. Runs attack-surface checks for exposed files, security headers, admin paths, TLS, and subdomains.
|
|
362
|
+
5. Returns a verdict, summary, findings, proof, fix guidance, and re-test command.
|
|
363
|
+
|
|
364
|
+
Authenticated scan:
|
|
365
|
+
|
|
366
|
+
1. Adds a throwaway bearer token and/or cookie to the browser context.
|
|
367
|
+
2. Scans authenticated pages and traffic.
|
|
368
|
+
3. Applies best-effort access-control heuristics for direct object references.
|
|
369
|
+
|
|
370
|
+
Use throwaway credentials only.
|
|
371
|
+
|
|
372
|
+
## Chrome Extension
|
|
373
|
+
|
|
374
|
+
The `extension/` folder contains an experimental local Chrome extension that passively monitors pages as you browse.
|
|
375
|
+
|
|
376
|
+
It scans:
|
|
377
|
+
|
|
378
|
+
- request and response headers
|
|
379
|
+
- URLs and query parameters
|
|
380
|
+
- fetch/XHR response bodies
|
|
381
|
+
- inline scripts
|
|
382
|
+
- data attributes and page config
|
|
383
|
+
|
|
384
|
+
### Load It In Chrome
|
|
385
|
+
|
|
386
|
+
The extension is not published to the Chrome Web Store yet. Load it from this repo:
|
|
387
|
+
|
|
388
|
+
1. Clone or pull the latest `main` branch.
|
|
389
|
+
2. Open `chrome://extensions` in Chrome.
|
|
390
|
+
3. Enable `Developer mode`.
|
|
391
|
+
4. Click `Load unpacked`.
|
|
392
|
+
5. Select the `extension/` folder, not the repository root.
|
|
393
|
+
6. Pin `KeyLeak Detector` from the Chrome toolbar extensions menu.
|
|
394
|
+
7. Browse an app you own or have permission to test.
|
|
395
|
+
8. Click the KeyLeak toolbar icon to see findings for the current tab.
|
|
396
|
+
|
|
397
|
+
The exact folder to select is:
|
|
398
|
+
|
|
399
|
+
```text
|
|
400
|
+
keyleak-detector/extension
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Use The Popup
|
|
404
|
+
|
|
405
|
+
The popup shows:
|
|
406
|
+
|
|
407
|
+
- a badge count for findings on the current tab
|
|
408
|
+
- a launch verdict: `SAFE TO SHIP`, `REVIEW`, or `BLOCK SHIP`
|
|
409
|
+
- severity filters for `CRIT`, `HIGH`, `MED`, and `LOW`
|
|
410
|
+
- scan activity stats for headers, fetch/XHR bodies, external scripts, source maps, storage, WebSocket/SSE messages, data attributes, and meta tags
|
|
411
|
+
- redacted proof, detector IDs, confidence, validation status, and fix guidance
|
|
412
|
+
- report copy actions for redacted JSON and Markdown
|
|
413
|
+
- per-finding suppression by stable finding ID for known launch-gate noise
|
|
414
|
+
- a `RUN FULL SCAN` action that calls the local KeyLeak web scanner at `http://127.0.0.1:5002` without forwarding browser cookies or bearer tokens
|
|
415
|
+
- a `CLEAR` button to reset findings for the current tab
|
|
416
|
+
|
|
417
|
+
### Use The DevTools Panel
|
|
418
|
+
|
|
419
|
+
Open Chrome DevTools on a page, then select the `Secrets` panel. It shows a wider launch-gate table and enables DevTools network body capture while the panel is open, which improves coverage for parser-loaded bundles and source maps.
|
|
420
|
+
|
|
421
|
+
### Learn And Reference Tabs
|
|
422
|
+
|
|
423
|
+
Both the popup and the DevTools panel include a `Findings` tab and a `Reference` tab:
|
|
424
|
+
|
|
425
|
+
- Click `LEARN` on any finding to inline-expand a panel explaining what the detector is, why it matters, the canonical attack scenario, the fix, and external references (OWASP, CWE, vendor docs).
|
|
426
|
+
- Switch to `Reference` to browse every detector grouped by pack (`leak`, `appsec`, `access-control`, `correctness`, `housekeeping`). The search box filters by detector ID, description, remediation, or category. Use this as a glossary even when there are no findings.
|
|
427
|
+
|
|
428
|
+
Detector educational content is sourced from `keyleak/detectors.py` (`description`, `remediation`, `references`, optional `attack_scenario`) and regenerated into `extension/lib/detector-info.js` by `scripts/generate_extension_patterns.py`. To add or improve an explanation, edit the detector and re-run the script.
|
|
429
|
+
|
|
430
|
+
### Extension Permissions
|
|
431
|
+
|
|
432
|
+
The extension requests `webRequest`, `storage`, `activeTab`, `tabs`, and `<all_urls>` because it observes requests, headers, page content, and fetch/XHR responses locally.
|
|
433
|
+
|
|
434
|
+
Use it for development, staging, bug bounty scopes, or owned systems. Disable it when browsing unrelated sensitive sites. See [docs/SECURITY_MODEL.md](docs/SECURITY_MODEL.md) before using it on sensitive browsing sessions.
|
|
435
|
+
|
|
436
|
+
## Reports
|
|
437
|
+
|
|
438
|
+
CLI output formats:
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
poetry run keyleak local . --json
|
|
442
|
+
poetry run keyleak local . --markdown
|
|
443
|
+
poetry run keyleak local . --sarif
|
|
444
|
+
poetry run keyleak scan https://preview.example.com --baseline keyleak-baseline.json --fail-on high
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Each normalized finding includes:
|
|
448
|
+
|
|
449
|
+
- `id`
|
|
450
|
+
- `type`
|
|
451
|
+
- `severity`
|
|
452
|
+
- `confidence`
|
|
453
|
+
- `detector_id`
|
|
454
|
+
- `category`
|
|
455
|
+
- `source`
|
|
456
|
+
- `evidence`
|
|
457
|
+
- `redacted_value`
|
|
458
|
+
- `risk_reason`
|
|
459
|
+
- `remediation`
|
|
460
|
+
- `references`
|
|
461
|
+
- `validation_status`
|
|
462
|
+
|
|
463
|
+
Reports also include `packs` and `pack_summary`, so web, CLI, CI, and extension exports can group findings by heatmap category.
|
|
464
|
+
|
|
465
|
+
Baselines and allowlists are intentionally simple. A baseline can be a previous KeyLeak JSON report; those finding IDs/signatures are suppressed so CI fails only on new findings. An allowlist can be JSON (`ids`, `detector_ids`, `types`, `source_contains`) or a line file using entries like `id:finding_...`, `detector:local:openai_api_key`, `type:source_map_reference`, or `source:fixtures/vulnerable-demo`.
|
|
466
|
+
|
|
467
|
+
## Security Model
|
|
468
|
+
|
|
469
|
+
- Local-first: scans run on your machine or self-hosted Docker container.
|
|
470
|
+
- No hosted credential upload is required.
|
|
471
|
+
- Values are redacted in normalized reports by default.
|
|
472
|
+
- Authenticated scans should use throwaway test credentials.
|
|
473
|
+
- Only scan systems you own or have explicit permission to test.
|
|
474
|
+
|
|
475
|
+
Read [docs/SECURITY_MODEL.md](docs/SECURITY_MODEL.md) for details and limits.
|
|
476
|
+
|
|
477
|
+
## Contributing
|
|
478
|
+
|
|
479
|
+
Useful PRs are very welcome. The best contribution lanes are:
|
|
480
|
+
|
|
481
|
+
- add provider patterns with fixtures
|
|
482
|
+
- add safe vulnerable fixtures
|
|
483
|
+
- improve false-positive handling
|
|
484
|
+
- add remediation playbooks
|
|
485
|
+
- improve Chrome extension UX or tests
|
|
486
|
+
- add report exporters
|
|
487
|
+
- improve CLI profiles and CI behavior
|
|
488
|
+
- add MCP/agent/LLM leak detectors
|
|
489
|
+
- add detector-pack fixtures and lower-noise validators for correctness and housekeeping leads
|
|
490
|
+
|
|
491
|
+
Start with [CONTRIBUTING.md](CONTRIBUTING.md) and [docs/DETECTOR_AUTHORING.md](docs/DETECTOR_AUTHORING.md).
|
|
492
|
+
|
|
493
|
+
## Roadmap
|
|
494
|
+
|
|
495
|
+
- Shared scanner core for web UI, CLI, and extension.
|
|
496
|
+
- More detector fixtures and report tests.
|
|
497
|
+
- More validated appsec checks beyond lead detection.
|
|
498
|
+
- GraphQL, OAuth/OIDC, CORS, source-map, and agent-web safety detectors.
|
|
499
|
+
|
|
500
|
+
## Responsible Use
|
|
501
|
+
|
|
502
|
+
Only scan systems you own or have written permission to test. Unauthorized scanning may be illegal. Handle findings securely, rotate exposed credentials immediately, and report vulnerabilities through responsible disclosure.
|
|
503
|
+
|
|
504
|
+
## Acknowledgments
|
|
505
|
+
|
|
506
|
+
- [GitLeaks](https://github.com/gitleaks/gitleaks) for the industry-standard secret scanning rules that KeyLeak imports.
|
|
507
|
+
- [Keyleaksecret](https://github.com/0xSojalSec/Keyleaksecret) for additional pattern inspiration.
|
|
508
|
+
|
|
509
|
+
## License
|
|
510
|
+
|
|
511
|
+
MIT. See [LICENSE](LICENSE).
|
|
512
|
+
|