Skip to content

Fail malformed reports safely and resolve adversarial evaluation review - #147

Merged
vsn411 merged 12 commits into
secfoo-com:mainfrom
oliarmak-web:feat/adversarial-repository-evaluation-117
Nov 19, 2026
Merged

vsn411 merged 12 commits into
secfoo-com:mainfrom
oliarmak-web:feat/adversarial-repository-evaluation-117

Conversation

@oliarmak-web

@oliarmak-web oliarmak-web commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #117

Supersedes #145 and #134, addressing the latest maintainer review. GitHub rejected reopening #145, so this follows the invitation to submit a replacement. Rebased onto upstream main at ffbe169.

Repository-supplied instructions can suppress or fabricate findings. This adds a paired adversarial corpus, opt-in collection and offline evaluation, and consistent report/prompt handling. Malformed reports fail the run while preserving normal CLI JSON, other skill outcomes, and inspectable artifacts.

Latest review fixes

  • Line separator bypass: report token offsets use LF-only splitting after markdown-it-compatible CRLF/CR normalization. Unicode separators and C0 controls no longer masquerade as token-map lines. Wide arbitrary-text properties assert closed-fence behavior and reject the supplied unclosed-fence bypass rather than treating parser exceptions as unconditional passes.
  • Graceful failed runs: _run_single_skill handles malformed report errors locally, records a failed outcome and readable diagnostic, and preserves report paths. An integration test exercises run --skill sast --skill secret-scanning --fail-on high --json with a malformed fake-agent report, checks exit 1 and both JSON outcomes, and verifies both artifacts remain accessible.
  • Stored report compatibility: shared stored-report reading logs and excludes unparsable reports. SCA/secret dashboards show an exclusion notice; Responsible AI badges and runtime inventory tolerate malformed historical reports. Integration coverage seeds successful old reports that are malformed under the upgraded parser.
  • Parser regressions: ratings inside list items remain visible. Explanatory h3 headings stay inside the current finding until the next finding/section. JSON draft envelopes after prose are rejected. Architecture and top-findings section readers now use the shared parser.
  • Parse reuse: source views carry parsed headings/exclusion spans through extraction, with a bounded cache across repeated readers. The regression test asserts one Markdown parse for findings_with_fingerprints rather than repeated full-report parsing.
  • Evidence separation: tables group by source revision, trial, capture profile and corpus digest as well as agent/skill/phase/variant. Historical numbers are labeled as previous-corpus observations, not measurements of this revision. API tool policy is explicitly “not exposed,” not an observed refusal result.
  • Provider environment: local Ollama keeps its loopback API base, a non-secret availability sentinel, and the memory setting; bare names select the OpenAI provider's own key. Unrelated secrets remain excluded.
  • Capture privacy: public streams normalize host paths and remove session IDs, UUIDs, socket paths, plugin and subscription-expiry metadata. Their record hashes are updated to the sanitized public files; documentation no longer calls them unchanged raw captures.
  • Trusted boundaries: the actual generated source boundary tokens are declared in the system message. A regression verifies a forged marker in source is not trusted.
  • Housekeeping: removed duplicated historical corpus/transcripts; retained one evaluator-only historical manifest and an immutable source revision reference. Replay uses explicit per-record manifest metadata, not a directory-name special case. Removed parse-only replay steps from routine PR CI; assertion-bearing tests remain. New workflow action pins match current main. Fuzzing remains pinned and weekly/manual.

Validation

  • Full local suite: 1,447 passed, 1 failed. The sole failure is the known macOS sensor lifecycle test, also reproduced on untouched baseline f24043b. A later focused API/property run passed 35 tests, including the added trusted-boundary regression.
  • Synthetic and both historical live evidence files replay successfully, with separate setup/trial rows. These replays make no model calls.
  • New/changed parser, evaluator, API and focused test files pass Ruff. Existing diagnostics in older runner/storage/dashboard code are not claimed fixed.
  • Workflow YAML, public-capture privacy assertions and git diff --check pass.
  • Native Atheris and remote CI results are not claimed.

Remaining live evidence

Draft pending fresh free-model measurements. The user has authorized only free execution. We are locating their existing runtime; no paid API calls or billable workflow was dispatched. Historical model reports are retained with explicit manifest/setup metadata and sanitized capture provenance. They do not measure this code or the revised corpus.

The location/CWE retention heuristic and planted F900 check require human transcript review and do not establish broad security or statistical significance. See docs/ADVERSARIAL_EVAL.md and docs/evaluations/2026-11-16/README.md.

AI assistance: OpenAI Codex implemented and tested these changes under the account owner's direction. This is a resubmission for review, not a claim of maintainer approval or acceptance.

Follow-up review and validation, November 19

Reviewed maintainer commit 3b2d978 and integrated the concurrent upstream sensor/CI changes and CodeQL fixture exclusion through 4bb13f1. A further reproduced edge case accepted a JSON draft after a Markdown title as a Critical-rated report with zero findings. Commit 54d8660 rejects that case, including serialized report strings, while preserving genuine findings and ratings outside quoted JSON examples. Added regression tests.

Combined-head full suite: 1,535 passed, 1 failed, the same known macOS sensor lifecycle test. The final focused parser/API/property suite passed 235 tests; changed files pass Ruff and git diff --check. Synthetic and both historical live artifacts replay successfully. Coverage-plugin execution is not claimed locally; remote coverage checks remain separate. Fresh free-model measurements are still pending, and the PR remains a draft.

oliarmak-web and others added 8 commits November 19, 2026 12:40
…reads

Review follow-ups for secfoo-com#147 (secfoo-com#117), pushed by the maintainers:

- has_json_draft(): a JSON draft envelope only counts as an echo when the
  text has no Markdown headings of its own. A real report that quotes
  {"draft_report": ...} is no longer rejected, while an echo after a
  preamble, in a code fence, in a blockquote or bare still is (the fenced
  echo used to give zero findings and pass --fail-on).
- extract_overall_risk_rating(): looks in prose, then blockquotes (a
  rating in a callout is found again, as on main); a report starting
  with a link is no longer mistaken for JSON; a whole-text JSON document
  still has no rating.
- Evidence scrubbing covers /var/folders/.../T, /home/<user> and
  C:\Users\<user>; the published records and streams are re-scrubbed
  byte-for-byte and their capture_sha256 values updated. No host paths
  remain in docs/evaluations.
- Stored reports are cached by (path, mtime, size), so the assessments
  list and dashboards stop re-parsing every report on every load.
- Architecture, threat-modeling and third-party pages warn about stored
  reports that could not be parsed, like the SCA and secret pages.
- The malformed-report reason is in the --json run objects
  (failure_reason) and under the status in the results table.
- summarize(): the delimiter row has 15 columns, so the table renders.
- Property tests: example findings in fences and blockquotes are never
  counted; ratings round-trip as a line, list item or callout; the rating
  extractor and severity counter never disagree on what is malformed.

Counts and ratings match main on all 192 reports and transcripts in the
repository. Each fix was checked by reintroducing the bug.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread tests/test_runner.py Fixed
Satyanarayana Vuppala and others added 3 commits November 19, 2026 20:58
…code

The adversarial evaluation corpus needs a real vulnerability for the
agent to find (e.g. the MD5 password hash in the unicode fixtures), so
CodeQL's findings there are expected and must not reach the Security tab.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vsn411

vsn411 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you, @oliarmak-web, and welcome: this is your first merged contribution to secfoo, and it is a substantial one. Over three rounds you fixed every blocker from #134 and #145: no live agent-instruction files, the line-separator gate bypass, graceful failure with valid JSON, unparsable stored reports no longer breaking pages, a single parse per report, honest evidence labels, and a pinned, scheduled fuzz run.

The third review found a few remaining problems. Rather than send it back again, I pushed fixes onto your branch (3b2d978, 4bb13f1):

  • Host paths in published evidence: the scrubber now covers /var/folders/.../T, /home/<user> and C:\Users\<user>. All seven files in docs/evaluations/2026-11-16 were re-scrubbed byte-for-byte, and their capture_sha256 values updated. No host paths remain.
  • JSON-echo check: a real report that quotes {"draft_report": ...} is no longer rejected, while an echo after a preamble, in a code fence, in a blockquote or bare still is.
  • Ratings: found again in blockquotes and in reports that start with a link; a whole-text JSON document still has no rating.
  • Performance: stored reports are cached by path, mtime and size, so the assessments list stops re-parsing every report on every load.
  • Visibility: the architecture, threat-modeling and third-party pages warn about unparsable stored reports, and the malformed reason is in --json (failure_reason) and in the results table.
  • Housekeeping: the summary table renders (15-column delimiter), the property tests are widened as the Fix adversarial evaluation boundaries and fail closed on malformed reports #145 review asked, and CodeQL skips tests/fixtures/, whose vulnerable code is intentional.

Your own follow-up (54d8660), rejecting an echo behind a fake report heading, closes the last gap in my version. I re-ran the regression tests and the parity check on it: counts and ratings match main on all 192 stored reports and transcripts.

Still open, and fine as a follow-up: the per-file random boundaries in the API prompt cost about 100 tokens per file, and the published numbers predate the current corpus, as the docs already say. Merging, and you've earned your leaderboard points.

@vsn411

vsn411 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Correction to my comment above, @oliarmak-web: I didn't merge after all, because I saw you've kept this as a draft while the fresh free-model measurements are pending, and that's your call to make.

From the code side it is ready: the fixes above are in, your 54d8660 is verified, and CI is green. Two ways forward, whichever you prefer:

  1. Land the code now: mark the PR ready for review and it will be merged. Send the fresh measurements as a separate follow-up PR, which also earns its own leaderboard points.
  2. Keep it together: add the measurements here and mark it ready when you're done.

Either way, please keep the branch up to date with main (a ruleset requires it), or let me know and I'll merge main in for you.

@oliarmak-web
oliarmak-web marked this pull request as ready for review November 19, 2026 21:23
@oliarmak-web
oliarmak-web requested a review from vsn411 as a code owner November 19, 2026 21:23
@oliarmak-web

Copy link
Copy Markdown
Contributor Author

Thanks for the review and fixes. Let’s land the code now and submit fresh free-model measurements separately. I’ve marked the PR ready. Could you merge main into the branch as offered, then merge once the required checks pass?

# Conflicts:
#	fuzz/fuzz_parsers.py
#	src/secfoo/runner.py
#	tests/test_property_parsers.py
#	tests/test_runner.py
Comment thread tests/test_runner.py
assert repo.list_runs()[0].status == 'failed'
assert repo.list_sast_findings() == []
finally:
repo.close()
@vsn411

vsn411 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks, @oliarmak-web. Done: I merged main into the branch (fdc37e8). The conflicts were additions on both sides, with your malformed-report handling next to the new --context coverage in runner.py, the fuzz harness and the tests, and both are kept. The full suite passes on the merged code, and all required checks plus CodeQL are green. Merging now. Looking forward to the fresh free-model measurements in a follow-up PR.

@vsn411
vsn411 merged commit 48c324e into secfoo-com:main Nov 19, 2026
6 checks passed
@github-actions

Copy link
Copy Markdown

Leaderboard update

oliarmak-web now has 10 points (rank #4). 15 more to reach Bronze.

Full leaderboard

@vsn411

vsn411 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@oliarmak-web I opened #150 for the fresh measurements and assigned it to you, so that follow-up PR is scored on its own. Reference it with Closes #150.

@oliarmak-web

Copy link
Copy Markdown
Contributor Author

Thank you so much, @vsn411, for the thoughtful reviews, your patience across the revisions, and the fixes you contributed directly. I really appreciate you helping bring this work over the finish line and welcoming my first contribution to Secfoo. Thank you as well for recognizing the work and for the 10 leaderboard points, placing me at #4—it means a lot.

I’m continuing with #150: fresh measurements on current main and the revised corpus, at least two trials per case, using free local inference only. I’ll publish scrubbed, reproducible records with clear telemetry limitations and submit a separate follow-up PR referencing Closes #150. Thank you again for the opportunity and your support.

vsn411 pushed a commit to karthickmk2001/secfoo that referenced this pull request Nov 20, 2026
Conflicts with secfoo-com#146/secfoo-com#147 resolved by keeping both sides: fuzz_parsers keeps
the shared _common runner plus main's MalformedReportError handling and
coverage-table checks; settings.py keeps the new MCP type checks plus
main's `hosts` parsing and `defaults.context`.

Review follow-ups for secfoo-com#149 (secfoo-com#121), pushed by the maintainers:

- fuzz.yml: replays every seed corpus and reproducer (blocking), then
  fuzzes 30 s non-blocking on PRs and 60 s blocking nightly; concurrency
  group; checkout without persisted credentials. parser-fuzz.yml (atheris
  2.3.0, weekly) is removed: the matrix replaces it.
- `secfoo run`: an unknown defaults.agent / defaults.depth is an error only
  when no --agent / --depth flag overrides it.
- Config: shapes that always worked keep working -- `timeout = 1800.0`,
  scalar env/header values (coerced to strings), a blank command/url next
  to the other, any transport name. Values that used to crash still raise
  a ConfigError naming the key.
- SARIF: a zero-padded line ("0000000042") keeps its region.
- Runtime evidence: only json.loads is covered by the broad decode-error
  catch, so a validation bug surfaces instead of becoming "not valid JSON".
- Heartbeat API: the same crash classes as /events (deep nesting, 4300+
  digit ints, values over 64 bits, lone surrogates) now get 400/422, not 500.
- Ingest harness clears the runtime tables per input, so a crash reproduces
  from its own file; corpus replay runs files without an extension too.
- CONTRIBUTING.md: fuzz_parsers' contract and the workflow schedule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vsn411 pushed a commit that referenced this pull request Nov 20, 2026
…y found (#149)

Coverage-guided fuzzing in CI (#121): six harnesses (parsers, SARIF/JSONL export, skill loader, config, docext, runtime ingest) sharing one runner, seed corpora with crash reproducers, Hypothesis property tests, and fixes for the crashes found.
Maintainer follow-ups: merged with #146/#147, one Fuzz workflow (blocking corpus replay; 30 s non-blocking on PRs, 60 s nightly) replacing parser-fuzz.yml, flags override stale config agent/depth, config shapes that always worked still load, zero-padded SARIF lines, narrower evidence decode catch, heartbeat API hardened, per-input ingest isolation.

Co-authored-by: karthickmk2001 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Adversarial validation: prompt injection from the repository being scanned

3 participants