Skip to content

fix: remove broken --agent secfoo (fabricates reports, never reads target source) - #20

Merged
vsn411 merged 1 commit into
secfoo-com:mainfrom
AdithKB:fix/remove-broken-secfoo-agent
Oct 4, 2026
Merged

vsn411 merged 1 commit into
secfoo-com:mainfrom
AdithKB:fix/remove-broken-secfoo-agent

Conversation

@AdithKB

@AdithKB AdithKB commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes SECFOO-32, Fixes SECFOO-33

Summary

--agent secfoo (src/secfoo/agents/secfoo.py, added in #10) never sends the target's source code to the model — it only sends the rendered skill prompt. The model has nothing to review, so it fabricates a plausible-looking report instead.

#11 fixed this exact bug ("the agent never sent the source code to the model... reports were generic or invented") — but fixed it in a separate new file, api.py, and never removed the original. Both have been registered and independently selectable via --agent since #10/#11 merged, with nothing indicating either one is broken. secfoo.py's own test even asserts the broken behavior as correct (messages == [{"role": "user", "content": "review this target"}]), so CI can't catch it.

Reproduction (twice, two skills, real API)

Target: we45/Vulnerable-Flask-App (small, public, intentionally-vulnerable Flask app — the whole app is one file, app/app.py).

  • secfoo run --skill sast --agent secfoo → "Confirmed" findings at app/db.py:42 and app/upload.py:20. Neither file exists in the repo.
  • secfoo run --skill secret-scanning --agent secfoo → a "Confirmed... Looks live" AWS key at deploy/ci.yml:14, told to rotate immediately. No deploy/ directory exists anywhere in the repo.
  • Same target through --agent api → real findings at real locations in app/app.py (JWT bypass, SQL injection, unsafe YAML load, plaintext passwords, MD5 hashing), matching independent findings from other agents.

Root cause

secfoo.py's _State has no workdir field, and run() never uses the workdir it's given — collect_files() (the function that reads real source, present in api.py) is never called anywhere in this file. Confirmed via git log --all -- src/secfoo/agents/secfoo.py: exactly one commit has ever touched it (the original from #10).

What this PR does

Removes the dead, broken duplicate and its now-stale references:

  • src/secfoo/agents/secfoo.py, tests/test_agents/test_secfoo.py — deleted
  • registry.py, agents/__init__.py, cli.py's AgentId enum — drop the SecFooAdapter/secfoo references
  • tests/test_cli.py — drop "secfoo" from the agent-id list test_agents_command_lists_all_adapters checks
  • README.md — removes a fully duplicate "built-in LangGraph agent" section documenting --agent secfoo as if it were a distinct, working feature (it duplicated the api agent docs directly above it)
  • config.example.toml — collapses three conflicting agent = "claude" example lines (each listing a different, partially-stale set of valid agent ids) into one correct line

api is the real, fixed implementation and needs no changes here.

Test plan

  • pytest tests — 700 passed (702 before, minus exactly the 2 removed tests)
  • secfoo agents — secfoo no longer listed
  • bandit -r src/secfoo/agents/api.py — clean
  • Re-verified git log --all shows no other commit touching the deleted file, so nothing else depends on it
  • Manually re-ran both repro cases above against a fresh checkout after the change to confirm --agent secfoo is simply gone, not silently falling back to anything

Known follow-ups (separate PRs, not blocking this one)

Found two smaller issues in api.py (the implementation being kept) while investigating:

  1. collect_files() reads files with encoding="utf-8" and no errors="replace", so a non-UTF-8 source file (e.g. legacy Windows-1252) raises UnicodeDecodeError and is silently treated as binary and skipped — no warning, no mention in the report's Coverage Notes.
  2. --exclude paths are only mentioned in the rendered prompt text (an instruction to the model) — collect_files(workdir) takes no exclude parameter, so excluded files' full contents are still read and uploaded to the third-party LLM API regardless of --exclude.

🤖 Generated with Claude Code

@AdithKB
AdithKB marked this pull request as ready for review September 30, 2026 10:22
…odel)

src/secfoo/agents/secfoo.py was the original Initiative-2 draft (PR secfoo-com#10).
PR secfoo-com#11 fixed the exact bug it has -- the agent never reads the target's
files, so the model reviews nothing and fabricates a report -- but fixed
it in a new, separate file (api.py) and never removed this one. Both
have been registered and independently selectable via --agent ever
since, with no indication either is broken.

Reproduced twice against we45/Vulnerable-Flask-App (SAST and Secret
Scanning): --agent secfoo returns "Confirmed" findings at file paths
that don't exist anywhere in the target (app/db.py, app/upload.py,
deploy/ci.yml), because build_graph's _State/run() never wires the
resolved workdir into the model call at all -- collect_files() (the
function that actually reads source) is never called from this file.
The adapter's own test asserts this as correct behavior
(messages == [{"role": "user", "content": "review this target"}]),
so CI can't catch it.

--agent api is the real, fixed implementation and needs no changes.
This just removes the dead duplicate and its now-stale references:
registry, AgentId enum, __init__ exports, its test, and two docs spots
(README's duplicate "built-in LangGraph agent" section, and
config.example.toml's three conflicting `agent =` example lines).

Full suite: 700 passed (down from 702 -- exactly the 2 tests removed
with the dead file). bandit clean on the touched agent files.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@AdithKB
AdithKB force-pushed the fix/remove-broken-secfoo-agent branch from 5c4b68a to 0f31c52 Compare October 3, 2026 10:36
@AdithKB

AdithKB commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current `main` — this was a silent merge collision with #21, not a bug in this branch. Both this PR and #21 independently cleaned up the same messy 3-duplicate-`agent=`-lines block in `config.example.toml`, different ways. Git's merge didn't see them as conflicting (non-overlapping line ranges), so it silently combined both survivors into two `agent =` keys in one TOML table — which `tomllib` rejects, breaking `secfoo config init` for everyone. That's what failed CI here.

Resolved by taking #21's version of that file (already correct, already on main) and removing two more stale references to `--agent secfoo` that a later PR had added to the README in the meantime. Full suite (749 tests) passes on the rebased branch.

@vsn411
vsn411 merged commit 3dc5f67 into secfoo-com:main Oct 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants