Skip to content

fix: comprehensive bug audit — 65+ fixes across Chrome and Firefox - #81

Merged
esokullu merged 2 commits into
mainfrom
bugfree
May 27, 2026
Merged

fix: comprehensive bug audit — 65+ fixes across Chrome and Firefox#81
esokullu merged 2 commits into
mainfrom
bugfree

Conversation

@esokullu

Copy link
Copy Markdown
Collaborator

Summary

  • Four independent audit agents scanned every major file in the codebase
  • 65+ bugs found and fixed across 23 files (326 insertions, 125 deletions)
  • 45 specific audit findings individually re-verified — 39 fixed, 6 confirmed not-bugs
  • 195/195 tests pass

Security

  • OAuth error messages redact token-like strings, truncate to 200 chars
  • All provider error bodies truncated with try/catch protection
  • OAuth 429 rate-limit handling with retry-after hint
  • Credential-field regex input truncated to prevent unbounded execution

JSON/response validation

  • res.json() wrapped in try/catch across all 6 provider files (Chrome + Firefox)
  • OAuth token exchange/refresh JSON parse protection
  • CapSolver response shape validation on all API endpoints

Null safety

  • Anthropic tool_use block fields defaulted (block.id || '', block.input ?? {})
  • Streaming accumulator: Array.isArray guard, idx >= 0 check, String(content ?? '')
  • CapSolver balance defaults to 0 via nullish coalescing

Memory leak prevention

  • New _cleanupTab() method consolidates all per-tab Map/Set cleanup (10 structures)
  • tabs.onRemoved calls _cleanupTab in both Chrome and Firefox
  • fetch-with-fallback.js stores listener ref to prevent double-registration

Concurrency

  • AnthropicOAuthProvider._refreshOnce() coalesces concurrent 401 token refreshes
  • _runningTabs Set prevents overlapping agent runs on the same tab

Firefox parity

  • safeQuerySelector ported for React-Aria/Radix component compatibility
  • openai_subscription deprecated provider cleanup added
  • Default Claude model aligned to claude-sonnet-4-6
  • Content script injection fallback now injects accessibility-tree.js
  • Tab recorder stub routes return descriptive unsupported error
  • tabs.onRemoved handler added for per-tab state cleanup

Observability

  • SSE stream catch blocks now console.warn with chunk excerpt (all 3 providers)

Timeout/resource protection

  • PDF fetch: 60-second AbortController timeout
  • PDF bytesToBase64: 32MB size guard

UI

  • Sidepanel copy button data-bound flags cleared on innerHTML restore

Test plan

  • npm test — 195/195 passing
  • Manual: verify Chrome extension loads and agent runs Ask + Act mode
  • Manual: verify Firefox extension loads and agent runs Ask + Act mode
  • Manual: verify OAuth sign-in flow works on Chrome
  • Manual: verify settings page renders all providers correctly

🤖 Generated with Claude Code

Security:
- OAuth error messages redact token-like strings (40+ char alphanumeric)
- All provider error bodies truncated to 500 chars with try/catch
- OAuth 429 rate-limit handling with retry-after hint
- Credential-field regex input truncated to 200 chars

JSON/response validation:
- res.json() wrapped in try/catch across all 6 provider files
- OAuth token exchange/refresh JSON parse protection
- CapSolver postJson/getBalance/createTask/pollTaskResult validation
- CapSolver response shape validation (typeof checks)
- CapSolver pollTaskResult timeout clamp for negative/NaN values

Null safety:
- Anthropic tool_use blocks: block.id/name/input defaulted
- Anthropic stream content_block_start fields defaulted
- CapSolver balance defaults to 0 via nullish coalescing
- Streaming accumulator: Array.isArray guard, idx>=0, String coercion

Memory leak prevention:
- New _cleanupTab() consolidates all per-tab Map/Set cleanup
- tabs.onRemoved calls _cleanupTab (Chrome + Firefox background.js)
- fetch-with-fallback stores listener ref to prevent double-registration

Observability:
- SSE stream catch blocks now console.warn with chunk excerpt (all 3 providers)

State management:
- _doneBlockCount, _recentSubmitClicks initialized in constructor
- _runningTabs Set guards concurrent processMessage/processMessageStream
- Both methods wrapped in try/finally for lock release

Timeout/resource protection:
- PDF fetch 60-second AbortController timeout
- PDF bytesToBase64 32MB size guard

Firefox parity:
- safeQuerySelector ported for React-Aria component compatibility
- openai_subscription deprecated provider cleanup
- Default Claude model aligned to claude-sonnet-4-6
- Content script injection fallback injects accessibility-tree.js
- Tab recorder stub routes return descriptive unsupported error
- tabs.onRemoved handler added for per-tab state cleanup

Concurrency:
- AnthropicOAuthProvider._refreshOnce() coalesces concurrent 401 refreshes
- Agent _runningTabs prevents overlapping runs on same tab

Infrastructure:
- Offscreen proxy forwards Content-Type from actual response
- fetch-with-fallback uses forwarded Content-Type

UI:
- Sidepanel copy button data-bound flags cleared on innerHTML restore

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webbrain Ready Ready Preview, Comment May 27, 2026 8:03pm

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08df4e920f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/chrome/src/agent/agent.js Outdated
Comment thread src/chrome/src/agent/pdf-tools.js Outdated
…out through body

1. _cleanupTab now takes { preserveRunGuard } option. clearConversation
   passes true so a running processMessage/Stream keeps its _runningTabs
   lock until its finally block releases it. Tab close still clears
   everything. (Chrome + Firefox)

2. PDF fetch timeout now covers the full request including arrayBuffer()
   body download, not just headers. clearTimeout moved to finally block
   so a server that sends headers then stalls the body still gets aborted
   after 60s. (Chrome + Firefox)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@esokullu

Copy link
Copy Markdown
Collaborator Author

@codex pls check again

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@esokullu
esokullu merged commit 9bc3e6e into main May 27, 2026
2 checks passed
esokullu added a commit that referenced this pull request Jul 6, 2026
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.

1 participant