GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): serve file reads as downloads with explicit content headers by thdxr · Pull Request #62422 · anomalyco/opencode

Conversation

@thdxr

@thdxr thdxr commented Nov 6, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

file reads now always come back as downloads with consistent headers, and API urls only answer navigations from the same origin.

  • GET/HEAD /api/fs/read/* (200, 206 and 304) send content-disposition: attachment with the filename, x-content-type-options: nosniff and a sandboxed content-security-policy. html, js and xml types (svg included) are sent as text/plain, since every client reads those as bytes and picks the type from the path. images, audio and video keep their type, so <img>/<video>/<audio> and range seeking work the same as before.
  • /api/experimental/media/:hash sends content-disposition: attachment for inline image types too, and uses the same policy.
  • requests to /api/* with Sec-Fetch-Site: cross-site or same-site get a 403 if they are navigations, or if they carry an Origin that is not an allowed CORS origin. clients without Sec-Fetch-* headers (cli, tui, sdk), same-origin pages, typed urls, app.opencode.ai, the desktop renderer, --cors origins and media elements (which send no origin) all pass. /auth/connect/* and artifact views are not affected.

no flag: this is a fix.


Added by the opencode bot (AI-generated).

Fixes #58914

Public API: fs.read and media responses are now sandboxed attachments (html/js/xml served as text/plain); cross-site browser navigations or disallowed origins to /api/* get 403 (backwards compatible for CLI, TUI, SDK and the app)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thdxr
fix(server): serve file reads as downloads with explicit content headers
c42e7c4
@thdxr
thdxr requested review from Brendonovich and Hona as code owners November 6, 2026 20:36
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The fix works as described. I checked it against opencode serve from source on the base and on this PR:

  • Base: an .html file came back from /api/fs/read/* inline as text/html, and cross-site navigations or calls from any origin got 200.
  • This PR: the same file comes back as a text/plain attachment with the sandboxed CSP and nosniff. Cross-site navigations and calls from origins that aren't allowed get 403. Requests from app.opencode.ai and no-cors range requests (how <video>/<audio> load) still succeed.
  • Tests and types: the server tests pass, and tsc -b in packages/server is clean.

Public API impact, limited to the server's HTTP behaviour (no SDK, OpenAPI, config or CLI changes):

  • GET/HEAD /api/fs/read/*: responses now include content-disposition: attachment with the filename, a sandboxed content-security-policy and x-content-type-options: nosniff. The content-type changes from html/js/xml types (including svg) to text/plain; charset=utf-8.
  • GET /api/experimental/media/:hash: PNG, JPEG, GIF and WebP images now also get content-disposition: attachment, and the CSP allows img-src/media-src 'self'.
  • /api/* (new): returns 403 ForbiddenError for browser requests marked Sec-Fetch-Site: cross-site/same-site that are navigations, or that carry an Origin outside the allowed CORS list.

This is backwards compatible for the CLI, TUI, SDK and the app, which send no Sec-Fetch-* headers or use allowed origins. Pages on other origins that aren't passed with --cors can no longer call the API, and opening an API URL from another site now gives 403. That is the intent of the change.

No blocking concerns.

Fixes #58914

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thdxr
test(server): use a filename windows accepts
dca99fa
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The new commit only changes a test: it switches to a filename that Windows accepts. The test still checks both the escaped filename= fallback and the percent-encoded filename*= value, and test/fs.test.ts passes. Server behaviour and the public API impact are the same as in my previous review. No new concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thdxr
thdxr merged commit b3b02ae into dev Nov 6, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@thdxr
thdxr deleted the file-read-headers branch November 6, 2026 21:00
@amrkmn amrkmn mentioned this pull request Nov 7, 2026
opencode 2.2.6 amrkmn/homebrew-tap#1217
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 7, 2026
feat: opencode release v2.2.6 sprisa/opencode-server#84
Merged
@shuv1337 shuv1337 mentioned this pull request Nov 7, 2026
chore(sync): merge upstream dev and audit v2.2.6 gaps shuv1337/shuvcode#477
Merged
@github-actions github-actions Bot mentioned this pull request Nov 7, 2026
Tool release: OpenCode 2 v2.2.6 (was v2.2.5) agent-sh/agnix#1808
Closed
autonull pushed a commit to autonull/opencode_spacegraph that referenced this pull request Nov 7, 2026
@thdxr me
fix(server): serve file reads as downloads with explicit content head…
d9ee078
…ers (anomalyco#62422)
@ichinya ichinya mentioned this pull request Nov 9, 2026
Артефакты: сохранение, upload/download, preview metadata и checksums ichinya/ariel#33
Open
3 tasks
@jonathanmorley jonathanmorley mentioned this pull request Nov 10, 2026
chore(openchamber-desktop): bump to 2.7.0 jonathanmorley/nixpkgs#251
Merged
@opencodejr opencodejr Bot mentioned this pull request Nov 12, 2026
feat(gui-plugins): add file download for remote server connections #63472
Open
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments
@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

fs.read serves HTML/SVG as same-origin documents with no sandbox headers

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@thdxr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.