I Almost Pasted an AWS Key into ChatGPT, So I Built a Little Goblin

LeakGoblin is a local CLI tool that scans and redacts sensitive info before you paste text to AI.
LeakGoblin is an open-source CLI tool that solves the problem of developers accidentally pasting keys while using AI chat tools. It offers scan and redact modes, detecting and replacing sensitive info before text leaves the machine while preserving context structure for AI use. It runs entirely locally with no network requests, and output is always masked so the scanner itself never becomes a leak path. Detection combines format signatures with conservative heuristics graded by confidence, with a configurable threshold to reduce false positives. The author positions it as a clipboard safety net, not a replacement for professional secret scanners or key managers.
Scan locally, redact, review before sharing.
It was an ordinary Tuesday, and I was debugging a failed deployment. Like I'd done a dozen times that day, I selected a screenful of terminal output, copied it, and switched to an AI chat window. My finger was already hovering over the Enter key when my eye caught line 14 of the log—AWS_ACCESS_KEY_ID was right there, with the plaintext secret below it.
I didn't press Enter. But that moment gave me chills: how many other times might I have not noticed? That's where LeakGoblin came from—an open-source command-line tool that catches sensitive information before text leaves your machine.

AI Tools Make Key Leaks Worse
Copy-paste leaks aren't new. For years, people have pasted credentials into Stack Overflow questions and GitHub issues. But AI tools have changed the volume and the habit:
- We paste much more context now. Asking AI to debug a problem usually means pasting the whole stack trace, config files, Dockerfile, and relevant
.envlines—because the more context, the better the answer. - Conversational interfaces have very low friction. A chat box feels private. It doesn't feel like "publishing publicly," so we lack that pre-post caution.
- Agents read files directly. Coding assistants can pull files into context on their own—whatever is in the file, they take with them.
- We rely on "remembering to check." Every paste is a chance to forget, and "I'll be careful" has never been a security control.
The common advice is "never put keys in code or logs," which is of course correct. But real projects always have .env files, verbose logs, connection strings in error messages, and tokens in curl commands you copied from a tutorial. The goal isn't perfection—it's having a safety net at the moment of pasting.
What LeakGoblin Does
It mainly does two things: scan and redact, plus a repository mode.
Install and Quick Start
Try it without installing: npx leakgoblin --help, or install globally (requires Node 20+).
Scan standard input:
cat prompt.txt | leakgoblin scan --stdin
Keys are always masked in the output. Each finding includes type, line number, severity, confidence, and a masked snippet—it never prints the full key.
Redacting standard input is my most-used feature. It doesn't just tell you what it found—it gives you a safe copy:
cat prompt.txt | leakgoblin sanitize --stdin
Input like api_key = "AKIA..." becomes [REDACTED:API_KEY:aws_access_key]. Surrounding text and line breaks are preserved, so the AI still gets the context it needs (the config structure, the shape of the error)—just without the actual credentials. The placeholder tells you which type of key was removed, making it easy to review the result.
My usual workflow is to pipe directly to the clipboard, review, then paste (use pbcopy on macOS, xclip on Linux).
Scanning repositories and CI integration are also supported. By default it skips noise directories like .git, node_modules, dist, as well as large and binary files. Exit codes are simple: 0 means no findings, 1 means keys found, 2 means an error—so pipelines can fail the build accordingly.
Detection Mechanics and Design Trade-offs
Signatures First, Then Heuristics
At its core, LeakGoblin is a set of format-specific signatures: private key blocks, AWS credentials, GitHub/Stripe/Slack/Google/OpenAI-style API keys, Bearer tokens and JWTs, password assignments, connection strings, environment variables, and more. When a string starts with AKIA and its length and character set match, that's a strong signal, marked as high confidence. Looser patterns (like a generic password = ...) are marked as medium confidence.
For keys without a tidy prefix, there's also heuristic detection for long random strings, but the author made two deliberate choices: heuristic results are marked as low confidence and low severity, never given the same certainty as signature matches; and if you find them too noisy, just set confidenceThreshold to medium in the config to silence them.
Regular expressions: LeakGoblin's format signatures are essentially a set of carefully constructed regular expressions. A regex is a syntax for describing string matching patterns—for example, AKIA[0-9A-Z]{16} precisely matches an AWS Access Key ID that starts with AKIA followed by 16 uppercase letters or digits. A regex engine can efficiently locate matching snippets across large amounts of text, which is exactly why the scanner can quickly traverse logs and config files without parsing line by line. But regex's limitation is that it only recognizes "shape," not meaning—for random keys without a fixed format, it can only rely on heuristics as a supplement.
Why Not "Flag Everything You See"?
It's tempting to make the scanner paranoid—flag every long string, every base64 block. But such tools fail in practice: if a scanner cries wolf every day, people stop reading its output, then add it to the ignore list, or just stop running it. A disabled tool protects no one. So LeakGoblin's design goal is: when it says "severe, high confidence," you believe it; when it says "low confidence, heuristic," you know to take a look but don't need to panic.
Company-specific token formats can be added as custom rules in leakgoblin.config.json, and an allowlist handles approved test fixtures like AWS's official example keys.
A Few Design Decisions the Author Cares About
Never print the full key. A scanner that echoes keys into the terminal, CI logs, or JSON reports becomes a new leak path itself. All text output is masked, and JSON output strips the raw match field—so the tool's own output is safe to view, share, or store as a CI artifact.
Fully local, no telemetry. During scanning and redaction there are no network requests whatsoever—no uploads, no accounts, no data sent back. For a tool whose entire purpose is to prevent sensitive data from leaving your machine, anything else would be absurd. It also keeps the trust model simple: you can read the source to confirm.
Boring but predictable exit codes. 0, 1, 2—that's it. Usable directly in shell scripts, GitHub Actions, pre-push hooks, or Makefiles, with no need to parse any output.
Synthetic test data only. All tests use canary values like AKIAIOSFODNN7EXAMPLE, never real credentials. Please do the same when reporting false positives or misses.
Honest Limitations
The author states the ugly truth upfront:
- It's a best-effort filter, not a guarantee. Always review redacted output before sharing.
- Novel or obfuscated formats may slip through. If a provider changes its token format, or a key is split or encoded, the scanner may miss it.
- Heuristics are just hints; low-confidence results may be false positives.
- It is not a key manager and doesn't replace a vault, encrypted env files, or key rotation. If something actually leaked, rotate immediately, no matter what the scanner says.
- It assumes you trust your machine; it doesn't protect against a compromised OS, and it's not a compliance certification.
It also doesn't aim to replace gitleaks or trufflehog—those target git history and organization-wide repository scanning. LeakGoblin targets a narrower moment: the clipboard on its way to an AI chat window or issue tracker.
Roadmap and How to Contribute
LeakGoblin is MIT-licensed and free to use. Planned items include: high-confidence signatures for more provider tokens (Azure, GCP, npm, etc.), SARIF output for GitHub Code Scanning, an opt-in --fix that writes redacted files back, pre-commit hook examples, a VS Code extension reusing the same engine, and better .env and Docker secret detection.
The easiest way to contribute is to add detection rules for token formats you know—CONTRIBUTING.md has full instructions. Reporting false positives or missed formats with synthetic samples is equally valuable.
Want to try it:
npx leakgoblin --help
echo "test AKIAIOSFODNN7EXAMPLE" | npx leakgoblin scan --stdin
The goblin is watching. Stay vigilant.
Background Notes
Exit codes: In Unix/Linux and CI systems, every command returns an integer exit code when it finishes—usually 0 for success and non-zero for some failure or anomaly. LeakGoblin uses this convention, defining 0 as no findings, 1 as keys found, and 2 as a runtime error. CI pipelines (like GitHub Actions) and shell scripts can directly check $? or use && / || to decide whether to abort the build or trigger an alert based on the exit code, without parsing any text output—making integration simple and reliable.
SARIF: SARIF (Static Analysis Results Interchange Format) is a JSON-based standardized format for representing alerts and results produced by static analysis tools. It's maintained by OASIS and widely supported by platforms like GitHub Code Scanning. Outputting LeakGoblin's scan results as SARIF lets you upload them directly to GitHub, display findings in the code scanning interface, and integrate with Pull Request checks for automated security alerts and tracking. The roadmap's planned SARIF support is precisely to fit into the broader DevSecOps toolchain.
Telemetry: Telemetry refers to software automatically collecting and sending back usage data, performance metrics, or error information during operation. Many developer tools enable telemetry by default to improve products, but for a security tool, any outbound data could become a leak channel. LeakGoblin explicitly declares no telemetry, meaning it won't send scan content, usage statistics, or crash reports to any server—all processing happens entirely in local memory. This lowers the trust barrier; users don't need to worry that the tool itself becomes a source of data leakage.
Related articles

Gemini 4 Argon Hands-On: AI Builds Board Games, Constructs Temples, and Trains Robots Autonomously
Gemini 4 Argon hands-on roundup: AI autonomously builds a desk racetrack and temple in Blender, writes a ray tracing engine, trains a humanoid robot to sink 7 shots, plus API pricing and developer access.

The Magic Octagonal Coin: Why Only 9% of People Can Predict Its Flip?
Only 9% of people can correctly predict the Magic Octagon coin flip. This article explains its spatial rotation mechanism, common cognitive pitfalls, and a new hypothesis based on Relevance Theory, exploring the limits of human spatial reasoning.

Sam Altman: AI Is Entering the Era of Scientific Discovery — Math Breakthroughs Will Replicate in Biology and Energy
Sam Altman says AI is entering the era of scientific discovery — math breakthroughs will replicate in biology, materials science, and energy to help develop new drugs and energy sources.