Skip to content

RCE and file read vulnerability #6355

Closed

Description

@Mishkun

Description

Vulnerability Summary

The OpenCode codebase has critical security vulnerabilities:

  1. No CORS validation - /packages/opencode/src/server/server.ts:135 uses .use(cors()) with no origin restrictions
  2. No authentication - Any request works without tokens/credentials
  3. Arbitrary shell execution and file read - POST /session/:id/shell executes any command GET /file/content?path=/etc/passwd reads file by path

Attack Vector

Any website can:

  1. Scan localhost ports to find the OpenCode server
  2. List existing sessions via GET /session
  3. Create a new session via POST /session
  4. Execute arbitrary shell commands via POST /session/:id/shell
  5. Read any file via GET /file/content?path=/etc/passwd

OpenCode version

1.0.207

Steps to reproduce

  1. start opencode server (or just open opencode in any dir)
  2. go to https://mishkun.github.io/opencode-rce-poc/ and follow instructions
  3. enjoy being pwned

Screenshot and/or share link

No response

Operating System

macos

Terminal

iTerm2

Activity

  1. github-actions commented on Dec 29, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. Mishkun commented on Dec 30, 2025

    @Mishkun
    ContributorAuthor

    Chrome and chromium require "local network access" permission
    latest firefox (146.0.1) doesn't require anything, exploit works without permission
    safari and brave browsers block port scanning

  3. rekram1-node commented on Dec 30, 2025

    @rekram1-node
    Collaborator

    updating cors policy and releasing that:
    7d2d87f

  4. CyberShadow commented on Jan 8, 2026

    @CyberShadow

    Previously reported here: GHSA-vxw4-wv6m-9hhh

    @rekram1-node Now that this has been independently reported and fixed, could you please publish the advisory

  5. CyberShadow commented on Jan 8, 2026

    @CyberShadow

    @rekram1-node Why does opencode.ai need arbitrary command execution powers to all OpenCode users' machines?

  6. CyberShadow commented on Jan 9, 2026

    @CyberShadow

    Hi @rekram1-node, FYI - since the issue is now public and I haven't been able to reach anyone from the team regrading the above, I plan to publish a full disclosure of this and remaining problems at https://cy.md/opencode-rce/ in 48 hours (2026-01-11).

  7. thdxr commented on Jan 9, 2026

    @thdxr
    Member

    hey sorry this got dropped over the holidays

    do you mind sending me disclosure to [email protected]

    the reason for the opencode.ai exception was for people using the webapp at app.opencode.ai

    we've made a change recently not to start the server by default, it's opted into

  8. CyberShadow commented on Jan 9, 2026

    @CyberShadow

    hey sorry this got dropped over the holidays

    Understandable, but I should note that I first tried reaching out in November. The address mentioned here might not be monitored.

    we've made a change recently not to start the server by default, it's opted into

    This is great, thank you!

    do you mind sending me disclosure to [email protected]

    Sent!

  9. CyberShadow commented on Jan 11, 2026

    @CyberShadow

    I plan to publish a full disclosure of this and remaining problems at https://cy.md/opencode-rce/ in 48 hours (2026-01-11).

    Posted.

  10. ta-dd commented on Jan 12, 2026

    @ta-dd

    Thanks to both for finding the vulnerability, as well as the proof-of-concept and the very well written disclosure. Jarring to see such a poor response from the Opencode team, please monitor that email address.

  11. thdxr commented on Jan 12, 2026

    @thdxr
    Member

    we've done a poor job handling these security reports, usage has grown rapidly and we're overwhelmed with issues

    we're meeting with some people this week to advise us on how to handle this better, get a bug bounty program funded and have some audits done

  12. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  13. monokrome commented on Apr 19, 2026

    @monokrome

    This seems a bit too important to be auto-closed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions