Skip to content

security: tool-output evidence stores recognized credentials without redaction (high) #128

Closed

Description

@WhollyMindless

Verified against upstream main at cf9b73c4f352bdc1fbd3c1332fca4183a63e3fb8 (0.14.9) during the 2026-10-26 security review, using Windows and Bun 1.3.10. Severity is a review priority, not a calculated CVSS score. The reproduction invokes actual plugin hooks/tools through the repository's fake-host harness; it is not a real-host end-to-end exploit.

Impact and cause

Ordinary tool use creates durable plaintext copies of recognized credentials, even with autoCapture disabled. memory_evidence can return those values to the model; normal evidence reads are also not session/repository filtered.

afterTool writes output_summary: summarize(text) for read/grep/glob/edit/write/bash/shell results. summarize folds whitespace and takes the first 80 characters; neither it nor record redacts secrets. A short GitHub token that redactSecrets() recognizes survives byte-for-byte in evidence/<date>.logfmt and the tool response.

Expected behavior / acceptance

  • A recognized synthetic credential in an ordinary tool result never appears in evidence or a memory_evidence response, with auto-capture off or on.
  • Prefer structured result metadata to persisted output excerpts. If retaining excerpts, redact the complete text before truncation/whitespace folding, so token prefixes and PEM boundaries are not lost before redaction.
  • Review other audit/reason write paths for the same bypass and define evidence-read scoping.
  • Add regression coverage for the complete hook-to-file-to-tool-response path, including a credential crossing the summary boundary and multiline private-key material.
  • Keep old evidence remediation separate and explicit; fixing new writes does not scrub old files.

Related work

#74 asks whether evidence redaction is complete but primarily covers historical stores/snapshots. This is a confirmed new-write leak in the default configuration, so it is tracked separately. Related: #83.

Reproduction

Save the following as security-review-repro.test.ts at the repository root of the reviewed revision and run bun test ./security-review-repro.test.ts --timeout 20000. All files are temporary fixtures and any model API is fake. These assertions deliberately confirm the current vulnerable behavior; passing means the bug reproduced, not that it is fixed. The fixtures are retained in the OS temp directory for inspection.

Self-contained Bun reproduction
// Review-only proofs against upstream cf9b73c (0.14.9). No real stores, keys, or model calls.
import { beforeEach, afterEach, expect, test } from 'bun:test';
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { loadPlugin, type LoadedPlugin } from './test/harness.ts';
import { appendMemory, loadAll, isActive, isVisibleHere } from './src/memory.ts';
import { rememberSessionDir, resetSessionScopes, resolveRepo, setRepoScope } from './src/repokey.ts';
import { resetState, setCurrent } from './src/state.ts';
import { dateStr, evidenceDir } from './src/config.ts';
import { redactSecrets } from './src/secrets.ts';
import { resetCaptureCooldowns } from './src/index.ts';
import { startViewer, type ViewerServer } from './src/viewer/server.ts';

let root: string;
let a: string;
let b: string;
let plugin: LoadedPlugin | undefined;
let viewer: ViewerServer | undefined;
beforeEach(() => {
  root = mkdtempSync(join(tmpdir(), 'osi-security-proof-'));
  a = join(root, 'repo-a'); b = join(root, 'repo-b');
  mkdirSync(a); mkdirSync(b);
  process.env.OPENCODE_MEMORY_DIR = join(root, 'memory');
  process.env.OPENCODE_COMMANDS_DIR = join(root, 'commands');
  process.env.OPENCODE_CBM_BIN = join(root, 'no-graph-binary');
  resetState(); resetSessionScopes(); resetCaptureCooldowns(); setRepoScope(null);
});
afterEach(async () => {
  viewer?.server.stop(true); viewer = undefined;
  await plugin?.cleanup(); plugin = undefined;
  resetState(); resetSessionScopes(); setRepoScope(null);
  delete process.env.OPENCODE_MEMORY_DIR;
  delete process.env.OPENCODE_COMMANDS_DIR;
  delete process.env.OPENCODE_CBM_BIN;
  // Keep only synthetic temp fixtures for inspection; never touch user state.
});

test('confirmed: ordinary tool output persists a recognized GitHub token in evidence', async () => {
  plugin = await loadPlugin(a); // autoCapture OFF
  const fake = 'ghp_' + 'AbCdEfGhIjKlMnOpQrStUvWxYz0123456789';
  expect(redactSecrets(fake)).toBe('[redacted]');
  await plugin.toolHooks['execute.after']({ sessionID: 'ses-a', callID: 'read1', tool: 'read',
    input: { filePath: '.env' }, result: { content: 'GITHUB_TOKEN=' + fake } });
  const raw = readFileSync(join(evidenceDir(), dateStr() + '.logfmt'), 'utf8');
  expect(raw).toContain(fake);
  const returned = await plugin.tools.memory_evidence.execute({ ev: 'tool_result' });
  expect(returned.content).toContain(fake);
});

Activity

  1. WhollyMindless commented on Oct 26, 2026

    @WhollyMindless
    ContributorAuthor

    Follow-up review: partially addressed; please keep this issue open until the remaining requirements are fixed or explicitly split.

    The new ordinary tool-output scrub works in the reviewed cases, including a token crossing the summary boundary and multiline PEM material. Two residual cases remain:

    • A correctly bound A session can read B's confidential ordinary tool-output summary through memory_evidence; the tool does not use caller identity. The PR acknowledges this deferral. Please define/enforce caller-scoped reads and make any cross-repository audit access explicit.
    • memory_merge_review.reason still persists a recognized synthetic credential verbatim in the daily memory row, even though the corresponding evidence line is scrubbed. Please cover the supersession write boundary in the audit/reason review.

    These are remaining gaps, not regressions in the new tool-output scrub. Historical-store cleanup remains separate under #74.

    Detailed #133 review · Runnable probes and merge-reason finding. Reproduced on combined head c9791ed, Windows / Bun 1.3.10, with temporary stores and synthetic credentials. Please adjust the unconditional Fixes #128 claim until the acceptance decision is resolved.

  2. added a commit that references this issue on Oct 28, 2026
  3. abogartz-opencode-self-improvement commented on Oct 28, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.14.12 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions