Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At debug log level API requests to OpenAI get logged with all headers, including an API key, in plaintext #1196

Open
1 task done
kives-nu opened this issue Feb 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@kives-nu
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

When sending a request using the library, line 439 of

/openai/openai-python/blob/main/src/openai/_base_client.py

Will log all request headers in plain text, including API keys.

While I understand this only happens in debug logging level, it still feels like a potential security issue. These logs should probably be filtered to remove this sensitive header.

To Reproduce

  1. Run an application with DEBUG log level that communicates with OpenAI using an API key
  2. Observe that the API key is printed in the logs in plain text

Code snippets

if log.isEnabledFor(logging.DEBUG):
      log.debug("Request options: %s", model_dump(options, exclude_unset=True))

OS

macOS

Python version

Python 3.11.6

Library version

openai v1.3.7

@kives-nu kives-nu added the bug Something isn't working label Feb 26, 2024
@stdweird
Copy link

👍 i was very surprised to find this.

@artdent
Copy link

artdent commented Mar 8, 2024

Also reported as #1082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants