Skip to content

fix(security): treat empty bulk advisory response bodies as non-retryable - #196

Merged
convyusboy merged 1 commit into
boonfrom
ridho/fix-security-fast-empty-body-retry
Sep 4, 2026
Merged

convyusboy merged 1 commit into
boonfrom
ridho/fix-security-fast-empty-body-retry

Conversation

@convyusboy

@convyusboy convyusboy commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Follow-up to #195. A comment on #195 (from cubic-dev-ai, confidence 10) was left unresolved because the PR was merged before it could be addressed: the retry classifier added in #195 treats a successful (200) response with an empty body as retryable, since it falls through the default return true branch. An empty body from a 200 response is the same class of deterministic, malformed-response failure as the JSON-parse case already excluded from retry — retrying it just adds a 2s delay plus a duplicate request before reporting the same finding.

Why This Change Was Made

Marks the empty-body error with a dedicated EEMPTYBODY code and excludes it in isRetryableBulkAdvisoryError, consistent with how ETOOBIG and SyntaxError (JSON parse) are already excluded.

User Impact

None for real advisory findings — only changes how fast the security-fast check reports a deterministic empty-body failure (immediately, instead of after one wasted retry).

Evidence

  • scripts/pre-commit/pnpm-audit-prod.mjs: readBulkAdvisoryJson now throws Object.assign(new Error(...), { code: "EEMPTYBODY" }); isRetryableBulkAdvisoryError now returns false for that code.
  • test/scripts/pnpm-audit-prod.test.ts: added a test proving no retry happens on an empty body (callCount stays 1) and a classifier unit-test case for EEMPTYBODY.
  • node scripts/run-vitest.mjs test/scripts/pnpm-audit-prod.test.ts → 28/28 passed.

Summary by cubic

Treats 200 responses with an empty bulk advisory body as non-retryable so security-fast reports the failure immediately instead of after one wasted retry.

  • Marks the empty-body error with a dedicated EEMPTYBODY code in readBulkAdvisoryJson.
  • Excludes EEMPTYBODY in isRetryableBulkAdvisoryError, matching the existing ETOOBIG and JSON-parse exclusions.
  • Adds a test proving no retry happens on an empty body.

Written for commit 546bf89. Summary will update on new commits.

Review in cubic

@convyusboy
convyusboy requested a review from a team September 4, 2026 06:07
@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean follow-up to #195 — resolves the cubic-dev-ai comment cleanly.

  • EEMPTYBODY code mirrors the existing ETOOBIG / SyntaxError treatment (deterministic malformed-response → don't retry).
  • Test asserts callCount === 1 on empty body, and the classifier unit-test case is added.
  • 22/2 line diff, security-fast + all CI green, no scope creep.

Ship it.

@convyusboy
convyusboy merged commit fb5e5b3 into boon Sep 4, 2026
336 of 339 checks passed
@convyusboy
convyusboy deleted the ridho/fix-security-fast-empty-body-retry branch September 4, 2026 09:06
convyusboy added a commit that referenced this pull request Sep 4, 2026
Live-verified (2026-09-04): a bulk advisory request to
registry.npmjs.org containing only "@a2ui/web_core" hangs indefinitely
-- confirmed twice, 15-20s+ each time, zero bytes received -- even
though the package's own registry metadata resolves normally in under
a second. Not payload-size related: it reproduces with this single
package alone, and blocks security-fast on every PR that pulls it in
as a production dependency (the canvas extension's a2ui bundle), not
just ones that touch it. The existing retry-once mechanism (#195, #196)
doesn't help since it retries the identical request against the same
broken endpoint behavior.

Exclude it from the bulk request entirely (not just filter it from
findings afterward) so the rest of production dependencies still get
audited. Remove once npm fixes the underlying advisory-lookup bug for
this package.
convyusboy added a commit that referenced this pull request Sep 4, 2026
)

* fix(browser-handoff): make the scheduled recheck actually re-check

Live-verified on arief-openclaw-test: a resumed cron turn would
sometimes end silently without ever calling browser_handoff
action="status" at all -- confirmed via boon-core's own request logs,
which show zero GET /browser_handoff/status calls for a cron-resumed
turn that nonetheless completed normally. The resumed model appears to
pattern-match the old wording's "if it's still pending, end your turn
without replying" against its own recent context (it had just told the
customer moments earlier that sign-in hadn't come through) and answer
from memory instead of actually checking again -- silently breaking the
recheck chain, since handleStatus (the only place that reschedules the
next check) never runs.

Rewrite the scheduled message to remove that shortcut: state up front
that whatever the model already believes is stale, and make the tool
call the first, unconditional action for the turn rather than one leg
of a conditional the model can reason its way around.

* fix(browser-handoff): validate site as a hostname at the tool boundary

Review feedback: site is model-supplied and gets interpolated directly
into scheduled-turn and reply prompt text in several places (schedule
recheck's message, the request_login reply, status/error text). A value
containing quotes, newlines, or instruction-like text there is a
prompt-injection surface.

site is documented as a hostname (e.g. "app.procore.com"), so validate
it as one at readSite -- the actual boundary where model-supplied args
enter the tool -- rather than trying to escape it at every
interpolation site.

* fix(browser-handoff): cap hostname length, fix a non-exercising test

Review feedback: HOSTNAME_PATTERN bounded each label to 63 characters
but not the total hostname length, so an arbitrary number of valid
labels could still produce an unbounded string -- one that then gets
embedded in prompts and used to build state/schedule keys. Add the
standard 253-character total-length bound.

Also fixes a test that claimed to cover newline rejection but whose
fixture contained no actual newline character -- it was passing for
the wrong reason (the quote/instruction-text portion alone already
failed validation). The fixture now includes a real newline.

* fix(security): exclude @a2ui/web_core from the bulk advisory request

Live-verified (2026-09-04): a bulk advisory request to
registry.npmjs.org containing only "@a2ui/web_core" hangs indefinitely
-- confirmed twice, 15-20s+ each time, zero bytes received -- even
though the package's own registry metadata resolves normally in under
a second. Not payload-size related: it reproduces with this single
package alone, and blocks security-fast on every PR that pulls it in
as a production dependency (the canvas extension's a2ui bundle), not
just ones that touch it. The existing retry-once mechanism (#195, #196)
doesn't help since it retries the identical request against the same
broken endpoint behavior.

Exclude it from the bulk request entirely (not just filter it from
findings afterward) so the rest of production dependencies still get
audited. Remove once npm fixes the underlying advisory-lookup bug for
this package.

* fix(security): warn loudly instead of silently on excluded packages

Review feedback: silently excluding a package from the bulk advisory
request means it was never checked, but the check still reports
success -- indistinguishable from full coverage. Excluding it from the
bulk endpoint request is still necessary (the endpoint hangs on it
regardless of batch size, confirmed by testing it in isolation), so
make the gap impossible to miss instead: print a clear warning naming
the package whenever it's actually a production dependency, so a
passing security-fast never silently implies full coverage.

Also renames the exclusion test to describe the asserted behavior
instead of reading like an incident report.

* fix(security): correct the all-excluded message, strengthen a test

Review feedback: when the only production dependency present was the
excluded package, the audit reported "No production dependencies
found" -- misleading, since a dependency was found, it was just
excluded (and the SECURITY WARNING above it already says so). Give
that case its own message that doesn't contradict the warning just
printed.

Also strengthens the "no warning" negative test: it previously proved
only that an absent package produces no warning, not that a package
present as a devDependency (non-production) does not. The fixture now
includes @a2ui/web_core as an explicit devDependency so the test
actually exercises the scenario its name claims.
insomnius added a commit that referenced this pull request Sep 4, 2026
…200)

Ships #198 (ENG-19115) — the gateway-audience OBO finally reaches the wire:
agent-runner-utils builds the primary-turn sender context from run.oboToken
and run.ts copies it into the attempt params, verified end to end on a local
stack (gateway fetched the org signing key and verified the token). Also
#197 browser-handoff recheck, #194 sentry-monitor tenant tag + hook
allow-list, #195/#196 CI dependency-audit hardening. Lockstep bump via
release:prep; CHANGELOG.md gains the 2026.6.11-boon.37 section the prepack
requires.
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