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

Better secret scrubber #3832

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Better secret scrubber #3832

wants to merge 11 commits into from

Conversation

cbeauchesne
Copy link
Collaborator

@cbeauchesne cbeauchesne commented Jan 15, 2025

Motivation

Better harness against secrets leakages.

Changes

Rather than scrubbing secrets every time we write a file (and exposing ourself to forget to call this when logging a new file), this PR instrument the python open method to scrub any written data, picking all the known environment variable names that store secrets.

It will offer a secure-by-design solution for any write operations (including logging method)

Though, it's not a silver bullet, here a non exhaustive list on how to continue leaking secrets, any idea to address those is welcome :

  • encode the secret. For instance, if it's in a JSON file, and the secret contains a ", it will be encoded, defeating the replace method
  • assert os.environ is False -> will fail, and will print in stdout the value of os.environ
  • print(os.environ) in a failed test will also print os.environ
  • store the secret no in os.environ (though, .env file is supported)
  • forget to add a new var name
  • execute a subprocess that is not in python, or in python, but not importing scrubber.py, and this subprocess write a file with the leaked secret. For instance, read/write volumes mounted in the docker container ...

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes (if something not related to your task is failing, you can ignore it)
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner. We're working on refining the codeowners file quickly.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • If PR title starts with [<language>], double-check that only <language> is impacted by the change
  • No system-tests internal is modified. Otherwise, I have the approval from R&P team
  • CI is green, or failing jobs are not related to this change (and you are 100% sure about this statement)
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added (or removed)?

@cbeauchesne cbeauchesne marked this pull request as ready for review January 16, 2025 08:49
@cbeauchesne cbeauchesne requested a review from a team as a code owner January 16, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants