prepare_subprocess_env: remove all passphrase-related env vars and BORGSTORE_REST_PASSWORD - #10341
Merged
ThomasWaldmann merged 1 commit intoSep 9, 2026
Conversation
ThomasWaldmann
force-pushed
the
subprocess-env-secrets
branch
from
September 8, 2026 23:13
7ed4c54 to
2092623
Compare
…RGSTORE_REST_PASSWORD, borgbackup#6480 Only BORG_PASSPHRASE was removed from the environment given to subprocesses (the command given in BORG_PASSCOMMAND, --paths-from-command / --content-from-command commands, tar filter commands, borg with-lock commands, fusermount/umount, fakeroot detection, ssh for legacy borg 1.x repos). Now also remove: - BORG_NEW_PASSPHRASE, BORG_OTHER_PASSPHRASE: secrets, like BORG_PASSPHRASE. - BORG_PASSCOMMAND, BORG_OTHER_PASSCOMMAND: often embed secrets or paths to them. - BORG_PASSPHRASE_FD, BORG_OTHER_PASSPHRASE_FD: the file descriptors are not inherited by the subprocess (Popen closes them), so the numbers would be dangling and misleading there. - BORGSTORE_REST_PASSWORD: borgstore's REST authentication password. The other borg env vars (BORG_REPO, BORG_KEY_FILE, ...) are not secrets and with-lock scripts may rely on them, so they are kept. Also document this in the BORG_PASSPHRASE help text and add tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ThomasWaldmann
force-pushed
the
subprocess-env-secrets
branch
from
September 8, 2026 23:13
2092623 to
b2b1a42
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10341 +/- ##
=======================================
Coverage 87.86% 87.87%
=======================================
Files 103 103
Lines 18876 18878 +2
Branches 2915 2916 +1
=======================================
+ Hits 16586 16589 +3
Misses 1589 1589
+ Partials 701 700 -1 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prepare_subprocess_env()removed onlyBORG_PASSPHRASEfrom the environment it prepares for the subprocesses borg starts (the command given in BORG_PASSCOMMAND,--paths-from-command/--content-from-commandcommands, tar filter commands,borg with-lockcommands,fusermount/umount, fakeroot detection, ssh for legacy borg 1.x repos). This PR extends that to all passphrase-related variables and borgstore's REST password, see the discussion in #6480.Now removed:
BORG_PASSPHRASE,BORG_NEW_PASSPHRASE,BORG_OTHER_PASSPHRASE: secrets.BORG_PASSCOMMAND,BORG_OTHER_PASSCOMMAND: often embed secrets (echo ...) or paths to them.BORG_PASSPHRASE_FD,BORG_OTHER_PASSPHRASE_FD: the file descriptors are not inherited by the subprocess (Popencloses them, nopass_fdsanywhere), so the numbers would be dangling and misleading in the child.BORGSTORE_REST_PASSWORD: borgstore's REST authentication password. It is the only secret among borgstore's env vars (BORGSTORE_RSH,BORGSTORE_REST_USERNAME,BORGSTORE_LATENCY,BORGSTORE_BANDWIDTH,BORGSTORE_RCLONE_DEBUG,RCLONE_BINARY).Reviewed and kept:
BORG_REPO,BORG_OTHER_REPO,BORG_KEY_FILEand all the otherBORG_*variables fromborg help environmentare not secrets, andwith-lockscripts may rely onBORG_REPO. Note that aBORG_REPOREST URL with embeddeduser:password@would still be passed on; credentials belong inBORGSTORE_REST_USERNAME/BORGSTORE_REST_PASSWORD.Also:
BORG_PASSPHRASEhelp text (docs/usage/general/environment.rst.incis generated from it, not regenerated here),prepare_subprocess_env()(there were none),Not in scope here (separate follow-up, see the issue comment): the in-place wipe of the kernel-provided environment block and removing the variables from
os.environearly, so that the ssh process spawned by borgstore's REST-over-ssh backend does not inherit them either.Tests run locally (macOS):
helpers/process_test.py,helpers/passphrase_test.py,archiver/lock_cmds_test.py,archiver/key_cmds_test.py,archiver/tar_cmds_test.py,archiver/create_cmd_test.py -k command; ruff check and format are clean.🤖 Generated with Claude Code