Skip to content

[BUG/SECURITY]: redacted secrets persist in cleartext in the opencode.db event journal #52586

Closed

Description

@BenSharir

Description

Secret redaction doesn't cover the event journal in opencode.db. The redaction hook (tool.execute.after) fires once, after a tool completes — but streaming tools (bash/shell) write their raw output to the event table on every chunk while still running, before any hook can touch it. So the final completed row and the part row are redacted, but every intermediate running row keeps the raw, un-redacted output. The event table has no prune/expiry, so those cleartext secrets persist for the life of the DB.

Net effect: a user who turns on redaction sees clean model context and clean session history, but their API keys/tokens still sit in cleartext inside the same opencode.db — and travel with any backup/sync/copy of it. It's local-at-rest (not a remote exploit), but it's a security feature silently not applying to a durable store.

No plugin can fix this: there's no mutation-capable hook before the event INSERT (commitDurableEvent in packages/core/src/event.ts). The event plugin hook is a read-only post-commit listener.

Steps to reproduce

  1. Run a streaming shell tool whose output contains a secret-shaped value (e.g. a command that prints an API key).
  2. While it's running, OpenCode writes message.part.updated.1 events to the event table with the raw output in state.metadata.output.
  3. Query the event table in opencode.db for running-status tool-part rows — the raw value is present in cleartext, and stays there permanently (no prune path).

The completed row and the part row are correctly redacted; only the intermediate running event rows retain the raw value.

Possible fixes (any one): a pre-INSERT transform hook in the event-store commit (this is the intent of the closed-unimplemented #28223); server-side redaction/truncation of streaming payloads before journaling; or retention/prune on the event table.

OpenCode version

1.18.34

Operating System

Rocky Linux 9.8

Terminal

tmux / various

Activity

  1. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

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

    • #51937: describes streamed bash output being persisted in running event rows before tool.execute.after can redact it.
    • #28223: requests a pre-storage transform hook for redacting persisted message content.
    • #33356: reports that the event table has no retention or pruning; its primary symptom is unbounded database growth.
  2. Tarquinen commented on Oct 20, 2026

    @Tarquinen
    Contributor

    Thanks for the report! In OpenCode 2.0 shell output is streamed to files instead of being stored in the event journal, so this no longer applies. If you still see this on the latest OpenCode, please open a new issue with details. Closing as completed.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions