RCE and file read vulnerability
Description
Vulnerability Summary
The OpenCode codebase has critical security vulnerabilities:
- No CORS validation - /packages/opencode/src/server/server.ts:135 uses .use(cors()) with no origin restrictions
- No authentication - Any request works without tokens/credentials
- 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:
- Scan localhost ports to find the OpenCode server
- List existing sessions via GET /session
- Create a new session via POST /session
- Execute arbitrary shell commands via POST /session/:id/shell
- Read any file via GET /file/content?path=/etc/passwd
OpenCode version
1.0.207
Steps to reproduce
- start opencode server (or just open opencode in any dir)
- go to https://mishkun.github.io/opencode-rce-poc/ and follow instructions
- enjoy being pwned
Screenshot and/or share link
No response
Operating System
macos
Terminal
iTerm2
This issue might be a duplicate of existing issues. Please check:
- #5256: [FEATURE]: Adding Authentication to
opencode serverapi - directly addresses the authentication vulnerability you've identified - #5076: OpenCode should have better/safer defaults to be more security minded - discusses related security concerns about default configurations
Feel free to ignore if none of these address your specific case.
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
updating cors policy and releasing that: https://github.com/sst/opencode/commit/7d2d87fa2c44e32314015980bb4e59a9386e858c
Previously reported here: https://github.com/anomalyco/opencode/security/advisories/GHSA-vxw4-wv6m-9hhh
@rekram1-node Now that this has been independently reported and fixed, could you please publish the advisory
@rekram1-node Why does opencode.ai need arbitrary command execution powers to all OpenCode users' machines?
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).
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
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!
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.