Skip to content

Fix CORS allowOrigin silently leaks configured origin on mismatch #74

Description

@KochC

In index.js the corsHeaders() function (lines ~19-21) computes allowOrigin as: configuredOrigin === '*' ? '*' : (requestOrigin === configuredOrigin ? requestOrigin : configuredOrigin). When the request's Origin does not match the configured value, the response still echoes back configuredOrigin as access-control-allow-origin instead of refusing or omitting the header. Browsers will block the cross-origin request correctly (because the value doesn't match the actual request origin), but the configured origin string is unnecessarily disclosed to any caller. The correct behaviour is to either omit the ACAO header entirely or return a fixed sentinel (e.g. null) when the origins don't match, which is the standard pattern used by proxies and reverse-proxies. This matters whenever OPENCODE_LLM_PROXY_TOKEN is set but the CORS origin whitelist is also configured, because an attacker can probe the header to discover the expected origin value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions