Skip to content

fix(chat): treat browser tab metadata as untrusted and bound attachment resolution - #9161

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/chat-attachment-context-hardening
Oct 17, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/chat-attachment-context-hardening

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Browser tab attachments now go through safeBrowserSelectionUrl, which drops credentialed and non-http(s) URLs. The title (capped) and URL are quoted in an UNTRUSTED BROWSER TAB JSON block, the same way browser and terminal selections already are; the URL used to be inlined as plain instruction text
  • One shared formatUntrustedJsonBlock in selection-context.ts replaces the copies in the browser and terminal selection formatters, with byte-identical output for both
  • Open-tab attachments resolve through mapWithConcurrency at the existing CONTEXT_RESOLUTION_CONCURRENCY (now in context-limits.ts) instead of an unbounded Promise.allSettled; each resolution stays settled-style, so logging and persistence order are unchanged. No schema limit was added, so no request that is valid today gets rejected
  • project-file-read.integration.ts teardown deletes the fixture files' search chunks and builds, mirroring owners.integration.ts

Type of Change

  • Bug fix

Testing

  • New post.test.ts cases: a credentialed URL never reaches context, and the title and URL sit inside the untrusted block. Both fail on the previous browser branch
  • post.test.ts, process-contents.test.ts, selection-context.test.ts pass (169 tests)
  • check:comment-hygiene, check:source-conventions, check:explicit-any, check:test-patterns; full suite and integration in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 17, 2026 2:39am UTC

Request Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/chat/resource-attachments.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issue was found.

Summary

The PR quotes browser tab metadata as untrusted JSON, drops unsafe URLs, and limits attachment resolution to four items at once.

  • Browser tabs now send bounded metadata as quoted data.
  • Chat resolves open attachments a few at a time.
  • Project-file test cleanup removes its search-index rows.

Reviews (3) · Last reviewed commit: "fix(chat): keep truncated browser tab ti..." · Reviewed by Greptile

…nt resolution

Browser tab attachments put the client-sent page title and URL straight into
the turn context as prose. The URL now goes through safeBrowserSelectionUrl
(credentials and non-http(s) URLs dropped, title kept), the title is capped,
and both are quoted inside an untrusted JSON block. The block format is shared
with the browser and terminal selection formatters via formatUntrustedJsonBlock.

Open-tab attachments resolved with an unbounded Promise.allSettled fan-out; they
now run through mapWithConcurrency at CONTEXT_RESOLUTION_CONCURRENCY with a
total mapper, so per-tab failures are still logged and skipped in order.

The project file read integration suite now deletes its fixtures' search
chunks and builds, which have no cascade from files.
…ded helper

Adds mapSettledWithConcurrency next to mapWithConcurrency, as that helper's contract asks, and uses it for open-tab attachments. The Project file read teardown now finds search builds by fixture owner, so builds whose file is already gone are removed too.
@waleedlatif1
waleedlatif1 force-pushed the fix/chat-attachment-context-hardening branch from 40a8170 to 126dc10 Compare October 17, 2026 02:28
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 96555d3 into staging Oct 17, 2026
53 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-attachment-context-hardening branch October 17, 2026 03:00

This branch was previously deployed

1 inactive deployment
Preview — 8ba721a1 Deployed Oct 17, 2026 by vercel[bot]
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