Clear sensitive env variables before spawning tentacle process - #1275
Merged
wlthomson merged 1 commit intoJul 28, 2026
Merged
Conversation
LukeButters
approved these changes
Jul 27, 2026
xwipeoutx
approved these changes
Jul 27, 2026
wlthomson
deleted the
wlthomson/scrub-sensitive-env-vars-after-configuration
branch
July 28, 2026 00:59
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.
Fixes FD-620.
Background
The
octopusdeploy/tentacleDocker image accepts registration credentials (ServerApiKey,BearerToken,ServerUsername,ServerPassword) via environment variables which are used once byconfigure-tentacle.shto register the machine with Octopus Server. As these variables are not unset before the entrypointexecs into the long-running Tentacle process, they currently persist in that process's environment (and/proc/1/environ) for the container's entire lifetime.This has non-trivial security implications: any deployment or runbook script that runs on that target/worker inherits these variables as a child process of Tentacle, effectively exposing a full Octopus Server credential to anyone who can get a script executed on the machine, regardless of how narrowly their actual deployment permissions are scoped (e.g. a deploy-only user restricted to a single project can end up with a credential that reaches every space on the instance).
This is not just a theoretical vulnerability: during testing I was able to exploit this to succesfully perform a privilege escalation attack by using a script step to echo out the sensitive variables from
/proc/1/environ.Results
Each entrypoint now clears the credential variables after registration is complete and before handing off to the long-running Tentacle process:
unset ServerApiKey BearerToken ServerUsername ServerPasswordinserted betweenconfigure-tentacle.shandexec run-tentacle.sh.unset, inserted after the registrationif/elseblock (covers both the "already registered" and "fresh registration" paths) and before the finalexec tentacle agent.Remove-Item Env:\...for all four variables, inserted betweenconfigure-tentacle.ps1andrun-tentacle.ps1.Manually tested by rebuilding the Tentacle image and unsuccessfully attempting to replicate the same privilege escalation attack as described previously.
NOTE: sensitive variables remain exposed to anyone with access to the Tentacle container via
docker inspect/docker exec/kubectl describe pod. Whether this is an issue, and how we plan to fix it, is deliberately left as out-of-scope here.Pre-requisites