gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Add deterministic redaction and reduce Auto Memory logging

Open SandyTao520 opened this issue 7 months ago • 5 comments

Problem

Auto Memory reads local transcripts and sends selected transcript content to the model used by the background extraction agent. The extraction prompt instructs the model to redact secrets, but that happens after content is already in model context. The service can also log existing skills and pending inbox content.

Relevant code:

  • packages/core/src/agents/skill-extraction-agent.ts
  • packages/core/src/services/memoryService.ts

Impact

  • Secrets or sensitive local details present in transcripts may be sent to the model before deterministic redaction happens.
  • Debug logs may contain memory content, pending patch contents, absolute paths, or sensitive workflow details.
  • The current user-facing setting description does not clearly state that Auto Memory performs model calls over local transcript content.

Expected Behavior

Auto Memory should scrub sensitive content before model submission and avoid logging full memory or patch content by default.

Acceptance Criteria

  • Add deterministic pre-model secret scrubbing for transcript excerpts, session summaries, workflow hints, and pending inbox content.
  • Avoid logging full memory or patch content by default.
  • Keep enough diagnostic information for debugging without dumping sensitive content.
  • Update settings/docs to clearly explain that Auto Memory uses model calls over local transcript content.
  • Tests cover common secret patterns in session summaries, workflow hints, and pending patch content.

Notes

This does not require changing the review-first inbox model. It tightens the privacy boundary before extraction prompts are assembled and before debug logs are emitted.

SandyTao520 avatar May 05 '26 18:05 SandyTao520

There is a problem with the Gemini CLI issue triaging. Please check the action logs for details.

gemini-cli[bot] avatar May 05 '26 18:05 gemini-cli[bot]

A significant privacy concern where Auto Memory lacks deterministic redaction of sensitive local content before model submission.

gemini-cli[bot] avatar May 07 '26 17:05 gemini-cli[bot]

One acceptance test I would add here is redaction before prompt assembly, not only before logging.

For example, feed Auto Memory a fake session summary, workflow hint, and pending inbox patch that each contain token-shaped strings, absolute paths, and a private-looking hostname. The test should assert that the model input never receives the raw values, and that debug logs keep only a reason code or hash/truncated fingerprint.

I would also test the three surfaces separately: transcript excerpts, generated memory patch body, and the existing inbox summary. If only the transcript path is scrubbed, a pending patch can reintroduce the same sensitive value on a later extraction run.

tangweigang-jpg avatar Jul 03 '26 11:07 tangweigang-jpg

One practical TypeScript option is to redact at both boundaries: before prompt assembly and before debug serialization. Flare Redact can process nested transcript, memory, and patch objects, catch known credentials plus opt in high entropy values, and summarize detector counts without logging the matches. I maintain it here: https://github.com/umudhasanli/flare-redact

umudhasanli avatar Jul 23 '26 10:07 umudhasanli

Instructing the extraction model to redact secrets inside its prompt is structurally late: raw credentials have already entered the LLM's context window, and debug logs risk serialization leaks.

Redaction belongs as a Zero-LLM Pre-Flight Interceptor executed prior to prompt assembly:

export interface RedactionResult {
  sanitizedText: string;
  redactionAudit: Array<{
    ruleId: string;
    tokenDigest: string; // sha256(secret) - never store raw match
    charOffset: number;
  }>;
}

export function preFlightDeterministicRedact(rawTranscript: string, detectors: RegExp[]): RedactionResult {
  let sanitized = rawTranscript;
  const audit: RedactionResult['redactionAudit'] = [];

  for (const pattern of detectors) {
    sanitized = sanitized.replace(pattern, (match, offset) => {
      const digest = crypto.createHash('sha256').update(match).digest('hex').slice(0, 12);
      audit.push({ ruleId: pattern.source, tokenDigest: digest, charOffset: offset });
      return `[REDACTED_SECRET:${digest}]`;
    });
  }

  return { sanitizedText: sanitized, redactionAudit: audit };
}
  1. Pre-Model Barrier: Raw transcript text passes through preFlightDeterministicRedact before SystemMessage / HumanMessage creation.
  2. Safe Logging: Loggers record tokenDigest fingerprints and match counts, ensuring raw secret tokens are structurally absent from both model attention and debug streams.

RemanenetSpy avatar Aug 30 '26 06:08 RemanenetSpy