Skip to content

fix: debug console.log leaks tool call data in production #11

Closed

Description

@stackbilt-admin

CodeBeast Audit Finding — P0 CRITICAL

Severity: P0 — Critical
Category: Security / Data Leak
Files: All source files (35+ occurrences)

Problem

35+ uncontrolled console.log/warn/error calls across the codebase with no log level control, no suppression mechanism, and at least one direct data leak.

Data Leak

anthropic.ts:492:

console.log('Tool calls detected in Anthropic response:', response.toolCalls);

This dumps full tool call payloads — potentially containing user data, function arguments, PII — into worker logs on every Anthropic tool-use response.

Log Pollution

The library is consumed by other applications. Every console.log in the circuit breaker, factory, and retry manager pollutes the consumer's stdout with no way to:

  • Suppress logs
  • Filter by level
  • Redirect to a custom logger
  • Disable in production

Locations (non-exhaustive)

File Count Examples
factory.ts 14 Provider init, chain selection, failures
circuit-breaker.ts 11 State transitions, decay, reset
base.ts 2 Request success/failure
anthropic.ts 2 SSE parse error, tool call data leak
openai.ts 1 SSE parse error
cerebras.ts 1 SSE parse error
groq.ts 1 SSE parse error
cost-tracker.ts 1 Warning
credit-ledger.ts 2 Restore warning, listener error
retry.ts 1 Retry attempt

Fix

  1. Immediate: Remove console.log at anthropic.ts:492 (data leak)
  2. Structural: Introduce a Logger interface with debug/info/warn/error levels
  3. Accept an optional logger in config, default to no-op
  4. Replace all console.* calls with this.logger.*
interface Logger {
  debug(msg: string, ...args: unknown[]): void;
  info(msg: string, ...args: unknown[]): void;
  warn(msg: string, ...args: unknown[]): void;
  error(msg: string, ...args: unknown[]): void;
}

🤖 Filed by CodeBeast audit

Activity

  1. added
    bug
    P0-critical
    audit
    security
    on Apr 1, 2026
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

    P0-criticalauditbugsecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions