Read the server password from a file or file descriptor, not only the environment · Issue #52447 · anomalyco/opencode · GitHub
Skip to content

Read the server password from a file or file descriptor, not only the environment #52447

Closed as not planned

Description

@phetzy

Description

opencode serve reads its Basic Auth password only from OPENCODE_SERVER_PASSWORD (packages/opencode/src/server/auth.ts:18-19, v1.18.32). There is no flag, config key, file or file descriptor for it (packages/opencode/src/cli/network.ts:6-33).

A process's startup environment stays readable by every same-user process for its whole lifetime: ps eww -p <pid> on macOS, /proc/<pid>/environ on Linux. Deleting the variable from process.env after startup does not change what those show. So any child the server starts (a shell tool command, an MCP server, an LSP server) can run ps eww -p $PPID, read the password, and call the server's API with full access, including answering permission requests. Scrubbing the child's own environment does not help, because the child reads the parent's.

Steps to reproduce

  1. OPENCODE_SERVER_PASSWORD=secret opencode serve
  2. In a session, run a shell command: ps eww -p $PPID
  3. The output contains OPENCODE_SERVER_PASSWORD=secret.

Seen on 1.18.32, macOS.

Proposal

Accept the password through a channel that never enters the exec environment or argv, read once at startup:

  • OPENCODE_SERVER_PASSWORD_FILE=<path>: read the file, then use its contents (the path is not secret), or
  • --password-fd <n>: read the password from an inherited file descriptor, then close it.

Either lets an embedding app keep the secret out of ps output. Keeping OPENCODE_SERVER_PASSWORD as is would stay compatible.

Related: #52427 (the password also reaches local MCP servers through their own environment).

Activity

  1. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    This issue doesn’t fully meet our contributing guidelines.

    What needs to be fixed:

    • As a feature request, the title should start with [FEATURE]: and the required verification checkbox from the Feature Request template should be included.

    Please edit this issue to address the above within 72 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. phetzy commented on Oct 1, 2026

    @phetzy
    Author

    Duplicate of #52156; the security reason is added there.

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

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions