Skip to content

logger.debug in response.py leaks api_key verbatim via new_kwargs #2265

@e3nemyMine

Description

@e3nemyMine

In instructor/processing/response.py (around line 405), there's a debug log call:

logger.debug(f"Instructor Request: ..., new_kwargs={new_kwargs}")

new_kwargs contains the full request dict including api_key in plaintext. When a downstream project (e.g. cognee) sets its root logger to DEBUG, the API key gets written to stdout/log files.

Impact: Any instructor user running at DEBUG log level with a cloud LLM provider has their API key written to logs. Docker stdout logs are often shipped to centralized logging (Loki, CloudWatch, etc.) and retained long-term.

Suggested fix: Redact known-sensitive keys (api_key, api_secret) from new_kwargs before logging, or log only safe fields.

Discovered in: cognee v0.5.8 + instructor 1.12.0 + Mammouth/Mistral provider. Confirmed: key appeared ~120 times in container stdout during a single cognify run.

Found in cooperation with Claude (Anthropic).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:criticalCritical issue affecting productionstatus:needs-investigationIssue needs investigation to determine scopetype:regressionRegression from previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions