Repository navigation
Bot secrets: fail closed on a missing credentials key; app secrets out of Lambda env (#1594, #1591) - #1627
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
scttfrdmn
force-pushed
the
hardening/1594-1591-bot-secrets
branch
from
November 14, 2026 20:17
c16c99f to
552005f
Compare
…app secrets out of Lambda env (#1594, #1591) botsecret.Field.Seal stored the plaintext, logging once per process, whenever alias/spore-bot-secrets did not exist, so deleting the alias put every new install's tokens in the table in the clear. That case is now an error unless SPORE_BOT_ALLOW_UNSEALED_CREDENTIALS=1, and every write the opt-in lets through is logged with SPORE_BOT_CREDENTIAL_STORED_UNSEALED. The self-hosting spore-bot template moves the five app-level secrets from the function environment into one Secrets Manager secret (BOT_APP_SECRETS_ARN, GetSecretValue on it alone). The bot-side read is spore-host/spore-host#740.
scttfrdmn
force-pushed
the
hardening/1594-1591-bot-secrets
branch
from
November 14, 2026 21:39
552005f to
3c76b0a
Compare
scttfrdmn
marked this pull request as ready for review
November 14, 2026 21:39
Merged
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 #1594
Fixes #1591
What changes
#1594: workspace-credential sealing fails closed.
botsecret.Field.Sealused to store the plaintext, logging once per process, whenever KMS returned NotFound for the default aliasalias/spore-bot-secrets. Removing that alias (a tofuseal_workspace_credentials=falseflip, an accidental delete, or a self-hosted stack without the key) therefore wrote new bot tokens, refresh tokens and webhook URLs tospore-bot-workspacesin the clear. The case is now an error that names the key,SPORE_BOT_SECRETS_KMS_KEYand the opt-in. Plaintext is stored only when the process setsSPORE_BOT_ALLOW_UNSEALED_CREDENTIALS=1(exactly1). Every write that opt-in lets through is logged with the stable markerSPORE_BOT_CREDENTIAL_STORED_UNSEALED, ready for a metric-filter alarm. An explicitly named key that is missing, and every other KMS failure, still refuse regardless of the opt-in. The change is contained inpkg/botsecret. Its writers arespawn notify workspace addand the dashboard's Slack OAuth install and refresh, all behindSPAWN_EXPERIMENTAL_CHAT. Reads of legacy plaintext are unchanged.#1591: app-level secrets leave the Lambda environment in the self-hosting template
deployment/cloudformation/spore-bot.yaml. The template still takes the five NoEcho parameters, but now writes them into oneAWS::SecretsManager::Secret,BotAppSecrets. It is a JSON object keyed by the env var names the bot reads:SLACK_SIGNING_SECRET,BOT_OAUTH_SECRET,SPORE_SLACK_CLIENT_SECRET,TEAMS_APP_SECRET,TWILIO_AUTH_TOKEN. The function getsBOT_APP_SECRETS_ARNandsecretsmanager:GetSecretValueon that secret only. The bot code lives in spore-host, so the read side is spore-host/spore-host#740 (filed with this PR). The template header says to deploy that bot build first or in the same update. The hosted bot is Tofu-managed and being decommissioned, so #740 also covers its Tofu.Tests
pkg/botsecret: a missing default key fails every field and logs nothing. Only=1opts in, sotrue,yesand1do not. With the opt-in, every write is stored and logged with the marker, not once. With the opt-in, the other failures still refuse.bot_app_secrets_test.go: the template's function environment holds none of the five names. The one secret's JSON keys are exactly those names, each from a parameter.BOT_APP_SECRETS_ARNis!Refthat secret, and the onlysecretsmanager:grant isGetSecretValueon it. The test fails against main.cfn-lintis clean.make checkis clean apart from the known space-in-path failures. Semgrep is clean on the changed paths.Deploy steps
SPAWN_EXPERIMENTAL_CHAT. The dashboard-api code (it linkspkg/botsecret) ships with the next code-only deploy.alias/spore-bot-secrets, it now fails instead of writing plaintext. SetSPORE_BOT_ALLOW_UNSEALED_CREDENTIALS=1on that writer only if plaintext is really intended.Live checks for the owner
aws kms describe-key --key-id alias/spore-bot-secrets --region us-east-1in 966362334030: the alias exists and the key is Enabled. If it does not exist, any hosted writer now fails, which is intended.SPORE_BOT_ALLOW_UNSEALED_CREDENTIALS. List key names only (spawn-dashboard-api,spore-bot).aws cloudformation validate-templateon the new template, then deploy into a scratch account with a waitForSSHReady cannot report failure: it returns nothing, so a 120s timeout renders as "✅ Waiting for SSH" and the launch proceeds to SSH-dependent steps #740 bot build. Confirmget-function-configurationlists none of the five names and that a Slack-signed request verifies.