Skip to content

Commit b7fcda6

Browse files
committed
Don't accidentally send the token to logs on startup
The elastic stack sends its startup logs to the `/buildkite/elastic-stack/{instance_id}` log group in cloudwatch, which is basically a bash script with `set -x` enabled. As part of this process, we fetch the token from SSM Parameter store, but this is included in the output, meaning that the token gets leaked into cloudwatch logs, which are potentially much less privileged than the agent tokens themselves. This PR disables set -x while we do secret things, and then turns it back on afterwards
1 parent 4400a2e commit b7fcda6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packer/linux/conf/bin/bk-install-elastic-stack.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ then
161161
fi
162162
chown buildkite-agent: "${BUILDKITE_AGENT_BUILD_PATH}"
163163

164+
set +x # Don't leak the agent token into logs
165+
echo "Setting \$BUILDKITE_AGENT_TOKEN to the value stored in the SSM Parameter $BUILDKITE_AGENT_TOKEN_PATH"
164166
BUILDKITE_AGENT_TOKEN="$(aws ssm get-parameter --name "${BUILDKITE_AGENT_TOKEN_PATH}" --with-decryption --query Parameter.Value --output text)"
167+
set -x
165168

166169
cat << EOF > /etc/buildkite-agent/buildkite-agent.cfg
167170
name="${BUILDKITE_STACK_NAME}-${INSTANCE_ID}-%spawn"

0 commit comments

Comments
 (0)