Console writes URL credentials to the local log, though AGENTS.md says secrets never reach disk

Open Beginner friendly
#2,163 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
security

Research direction

Open console/apps/switch-console-desktop/src/main/lib/file-logger.ts and read the SECRET_PATTERNS and PII_PATTERNS arrays alongside writeLogEntry and getDiagnosticLogAttachment to confirm which array each path applies. Then grep the file's existing tests for redaction cases and run them before and after moving the scheme://user:pass@ pattern into SECRET_PATTERNS. Done means a connection string passed through writeLogEntry no longer lands in switch-console.log with the password intact, while host and scheme survive.

Written by the indexing model from the issue text.

Description

Summary

console/AGENTS.md states that URL credentials are redacted on the write path and never reach disk. They are not: the pattern that catches them lives in PII_PATTERNS, which runs only when a log is exported. A password inside a connection string is written to the local log file in the clear.

Verified at switch-console-v0.41.1, in console/apps/switch-console-desktop/src/main/lib/file-logger.ts.

Detail

The logger splits redaction by destination, which is a good design and is documented as such:

  • redactSecrets() runs on every write (writeLogEntry), applying SECRET_PATTERNS.
  • redactDiagnosticLog() = redactPii(redactSecrets(...)) runs only in getDiagnosticLogAttachment(), the single point at which log content leaves the machine.

console/AGENTS.md describes the split this way:

Secrets (tokens, keys, JWTs, PEM blocks, URL credentials) are redacted on the write path by redactSecrets() and must never reach disk.

But the URL-credentials pattern is in PII_PATTERNS, not SECRET_PATTERNS:

# PII_PATTERNS
# Any scheme://user:pass@ — covers postgres, mongodb, redis, mysql, amqp, https…
[/\b([a-z][a-z0-9+.-]*:\/\/)[^\s:/?#@]+:[^\s@/?#]+@/gi, '$1[REDACTED_CREDENTIALS]@'],

So postgres://user:[email protected]/switch in a log line is scrubbed in an exported diagnostic bundle but written verbatim to switch-console.log on disk.

SECRET_PATTERNS does catch a credential presented as a named key (password=, "password":), so the gap is specifically the credential embedded in a URL — which is the common shape for database and broker addresses, and exactly the shape a connection error is likely to log.

Why it matters

The stated invariant is that secrets never reach disk. This breaks it for a credential shape that is both common and high-value, and the local log is the copy users are most likely to open, copy from, or attach somewhere by hand.

It is also now a documentation problem: the Switch Rooms troubleshooting page is gaining a "Find the logs" section, and because of this gap it has to tell readers that "a password inside a server address can still appear" in their log.

Suggested fix

Move the URL-credentials pattern from PII_PATTERNS to SECRET_PATTERNS. It is a credential, not personal data, and nothing about local debuggability needs the password — the host and scheme survive the redaction either way. Export is unaffected, because redactDiagnosticLog already runs redactSecrets as well.

The alternative is to correct AGENTS.md instead, but that keeps a real secret on disk in order to preserve an accurate comment, which is the wrong way round.

Dominant language
Python
Stars
4.5k
Forks
348
Avg merge
1d 17h
Merged PRs (30d)
287

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sandbox-quantum/switch

All issues in sandbox-quantum/switch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.