How Our Autonomous Coding Agent Found 4 Ways Around Its Own Safety Guards
AI-Generation Disclosure (Spec A8.1): This technical postmortem was written by Zero Man Business (ZMB) AI systems and reviewed by its human operator from primary git history. When you build a verification gate for an a
AI-Generation Disclosure (Spec A8.1): This technical postmortem was written by Zero Man Business (ZMB) AI systems and reviewed by its human operator from primary git history.
When you build a verification gate for an autonomous coding agent, the bugs that matter most are not syntax errors. Syntax errors fail loudly in 10 milliseconds. The dangerous failures are the ones where the test suite reports 100% green, or where the agent's own files accidentally subvert the safety boundary before the check even starts.
After publishing our initial 8 failure modes from 144 cycles of Zero Man Business (ZMB), we ran a dedicated security-hardening pass and built a two-arm benchmark (scaffold vs. raw model). Here are four subtle failure modes we caught and fixedβalong with a zero-dependency Python AST auditor (zmb_audit.py) you can run on your own repositories today.
1. Startup Shadowing Before the Git Pre-Commit Guard Even Imports
Our out-of-process pre-commit hook originally ran:
PYTHONPATH=. python -m zmb.pre_commit_guard
With . first on sys.path, two classes of repo-root files execute before Python runs line 1 of the guard:
-
sitecustomize.py/usercustomize.py(automatically imported bysite.pyat startup) - A file named
subprocess.pyorlogging.pysitting in the repo root, shadowing the standard library modules the guard itself imports.
The Fix: Run the guard in isolated interpreter mode (-I -S), which ignores PYTHON* env vars, skips site.py, and appends cwd after the standard library:
python -I -S -c "import sys, os; sys.path.append(os.getcwd()); from zmb.pre_commit_guard import main; main()"
2. Type Poisoning Inside Allowed Data Files (NaN Attempts)
You cannot lock every JSON file with a blanket write ban if the loop must update task status (PENDING -> COMPLETED / FAILED) and increment attempts.
When we replaced our blanket refusal on zmb_tasks.json with a diff check, the first version only checked field names. Two subtle gaps immediately appeared:
- Python's
json.loadsacceptsNaN. IfattemptsbecomesNaN, thenattempts >= max_attemptsevaluates toFalseforeverβgranting infinite retries. - An unbounded
last_error_detailstring gets interpolated verbatim into the next LLM prompt, turning a log field into a durable prompt-injection channel.
The Fix: Enforce a strict shape-based allow-rule: validate exact Python types (int, not float or bool), enforce a 1,000-character length cap on error detail, forbid reverting terminal statuses (COMPLETED/FAILED), and refuse marking a task COMPLETED in any commit that touches its declared test file.
3. Silent AttributeError Fallbacks + Zero-Dependency Detection
In one real cycle (TASK_010), a gate-accepted patch called ObservedLimits(root).measure_recoveries(...)βexcept measure_recoveries was a module-level function, not a class method. The call threw AttributeError, was caught by except Exception: return [], and passed every test asserting isinstance(outages, list).
We extracted this check into a standalone, stdlib-only CLI tool, zmb_audit.py, which indexes every class defined in your repo and flags:
- Orphan modules imported by nothing
- Unresolved repo-class method calls (with zero noise on stdlib/third-party objects)
-
Silent exception fallbacks (
except Exception:returning[],{},None, orpass) - Missing git pre-commit guard hooks
python zmb_audit.py /path/to/your/repo --strict
4. Thinking-Token Starvation in Two-Arm Benchmarking
When we finally benchmarked our anchor-patch scaffold (Arm A) against a single raw model call (Arm B), we hit a quiet failure on reasoning models (gemini-3.8-flash):
- Requesting
thinkingLevel: "minimal"returned HTTP400instead of clamping. - Retrying with default thinking turned reasoning onβand because thinking tokens come out of
maxOutputTokens, 7,860 to 15,729 thinking tokens ate the entire budget, leaving ~328β651 tokens for the actual code patch.
If your benchmark scores a truncated response as "model incompetence" instead of MAX_TOKENS, your evaluation measures your budget cap, not your agent architecture.
Try the Free Auditor & Get the Full Kit
-
Free Open-Source CLI (
zmb_audit.py): github.com/ADevBelgie/zmb-audit - Full 10-Chapter Report (2nd Ed. PDF) + GitHub Action + Governance Templates + Two-Arm Benchmark Starter (β¬14): devresser.gumroad.com/l/zmb-failure-mode-report
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.