Originally published on my Hashnode blog
Last week I watched a 418-byte JavaScript file turn into a 184 KB trap for AI agents. This post is about what that trap looks like, why it matters if you use coding agents, and the small tool I built to deal with it: tarpit-guard.
There is a growing class of tools that "harden" source code against AI analysis. One of them is BLA. I gave it a tiny app.js: 15 lines, 418 bytes. What came back was this:
| Original | Hardened | |
|---|---|---|
| Size | 418 B | 184 KB (~440x) |
| Lines | 15 | 2,998 |
| Secret string in cleartext | yes | no (encrypted) |
| Output when run | identical | identical |
The hardened file pads the real logic with decoy functions, hides branches behind always-true Math.imul arithmetic, encrypts string literals behind runtime decoder loops, and plants jargon like "enclave", "attestation" and "TPM" that exists only to mislead whoever reads it.
A human glances at that file and moves on. An AI agent does something worse: it reads it. It ingests 184 KB of input, spends reasoning tokens tracing dead ends, and often still lands on the wrong answer. The hardening tool's own summary for this file claimed a token amplification factor in the thousands. That's the point of a tarpit. It doesn't need to stop you. It just needs to make you pay.
My first instinct was the obvious one: make the agent better at reading obfuscated code. That's a losing game, and worse, it's the wrong game. Reversing someone's protection is exactly what these tools exist to prevent.
The cheap answer is simpler. Detect the tarpit first, then stop. Don't read it, don't trace it, skip it or hand it to a human. A check that costs around 1K tokens replaces a 60K-token dead end.
That's all tarpit-guard does.
It scores a file or a repository from 0 to 100 for deliberate anti-analysis hardening, with a confidence value and the evidence behind the score. At 55 or above (configurable), the file is a tarpit and the tool says so:
$ tarpit-guard bla_hardened_app.js
[TARPIT] score= 78 conf=1.00 bla_hardened_app.js
182865B / 2998 lines, Math.imul×246, decoder_pairs=8, garbled_idents=190, decoy_hits=487
fired: opaque_predicate_density, decoder_loops, decoy_vocabulary_density
-> Treat as a tarpit. Stop here: do not read, trace, or try to deobfuscate this file. Skip it and move on, or flag it for a human.
In directory mode it also looks for tool fingerprints, such as a .bla-hardened/ folder, .blarc or bla-harden-summary.json, which are near-certain evidence on their own.
The first version of this tool was wrong in an instructive way. It leaned on file size and line length, and it scored minified jQuery higher than a genuinely obfuscated file. Minified code is machine-generated and ugly, but it isn't hostile.
So the current signals key on things ordinary code, even heavily minified code, almost never produces:
Math.imul opaque-predicate chains guarding real branches_0x... string-array identifiers (the javascript-obfuscator family)fromCharCode + charCodeAt loops that rebuild encrypted strings at runtime!![]
And a file dominated by one- and two-letter identifiers with none of those markers is recognised as plain minification and capped low.
A labelled corpus of clean source, real minified bundles and hostile obfuscation runs on every change as a regression test. Today it shows 0 false positives and 0 false negatives: the highest benign score is 9.5 and the lowest hostile score is 78.
tarpit-guard reads the shape of a file, never its meaning. It doesn't deobfuscate, crack or extract secrets, and it never will. Building that would turn the project into the thing it warns about. This line is permanent and written into the README.
--json output.
pip install tarpit-guard
tarpit-guard path/to/code
To give an agent the tool, add the MCP server to your client config:
{
"mcpServers": {
"tarpit-guard": {
"command": "uvx",
"args": ["--from", "tarpit-guard[mcp]", "tarpit-guard-mcp"]
}
}
}
The server exposes three tools: check_file, check_source and scan_repo.
tarpit-guard passed 1,700 PyPI downloads in its first week. The MCP server is listed on the official MCP Registry and on Glama, and on mcprush it has a Grade A rating with a 100/100 trust score. A Claude plugin is currently in review.
The detector is only as good as the samples it has seen. The roadmap:
If you've got a file it scores wrong, or a real obfuscated sample, please open an issue. There are good first issues tagged for new contributors, and the codebase is small enough to read in one sitting.
GitHub: https://github.com/ManiraM-1/tarpit-guard
PyPI: https://pypi.org/project/tarpit-guard/
If it saves your agent from one tarpit, a star on the repo helps other developers find it.