Skip to content

fix: restrict Slack approvals to allowlisted users and record who decided (#117) - #148

Merged
OkiriGabriel merged 1 commit into
mainfrom
fix/slack-approvers-117
Oct 29, 2026
Merged

OkiriGabriel merged 1 commit into
mainfrom
fix/slack-approvers-117

Conversation

@OkiriGabriel

Copy link
Copy Markdown
Collaborator

Description

Fixes #117.

/slack/action verified that a click came from Slack, but not who clicked. Any member who could see the approval message (guests, contractors, everyone in a public channel) could approve a rollback, a k8s apply, an nginx write or security updates, and nothing recorded who approved.

Who can approve

  • SLACK_APPROVER_IDS=U012AB3CD,U045EF6GH lists the Slack user IDs allowed to approve.
  • It's read inside the org's credential scope, so it can be set per org with PUT /orgs/{org}/config (added to ORG_CREDENTIAL_KEYS). The org's list overrides the global one, and orgs without their own fall back to the global list.
  • A click from anyone else gets an ephemeral reply ("not an approver for this organization; nothing was run"), with replace_original: false so the buttons stay for a real approver. Nothing is executed.
  • Not set: today's behaviour is kept, so existing setups don't break, but each approval logs a warning to set the list.

Record of every decision

  • Approve, reject and refusal are each stored as an incident log approval-<timestamp>-<decision>.json with Slack user ID, name, org, incident and command, and logged with structlog.
  • A storage failure while recording never blocks the decision.
  • Confirmations now name the person: "✅ Approved by @alice", "❌ Rejected by @bob".

Out of scope (possible follow-ups): approval by Slack user group (needs a bot token and usergroups.users.list), and two-person approval.

Type of Change

  • Bug fix (security; non-breaking: opt-in allowlist)
  • Documentation update

Testing

  • New tests/test_slack_approvers.py (10 tests):
    • no allowlist: approves, names and records the user
    • global list: listed user approves; unlisted user gets ephemeral refusal, nothing runs, refusal recorded with ID and name; a payload without a user is refused
    • per-org: org list overrides global; another org uses global; key is storable through OrgConfig
    • reject recorded with the actor; record failure doesn't block; bad signature returns 401 before anything is recorded
  • Against the old handler, 6 of the 10 fail (all refusal and recording cases).
  • Full suite: 953 passed, 4 skipped. Flake8 critical: 0. Bandit -ll clean.

Docs

.env.example, docs/API_REFERENCE.md (POST /slack/action: who can approve and decision records), SECURITY_GUARANTEES.md.

🤖 Generated with Claude Code

…ided

Any user who could see an approval message in Slack could approve a
production change, and the approver was not recorded (#117).

- SLACK_APPROVER_IDS (global, or per org via PUT /orgs/{org}/config, the
  org's value winning) lists the Slack user IDs that may approve. Anyone
  else gets an ephemeral "not an approver" reply and nothing runs.
- Unset keeps today's behaviour (any channel member) and logs a warning.
- Every approve, reject and refusal is stored as an incident log
  (approval-<ts>-<decision>.json) with Slack user ID, name and command;
  recording failures never block the decision. Confirmations now name
  the approver ("Approved by @alice").

Fixes #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@OkiriGabriel
OkiriGabriel merged commit bc7bf27 into main Oct 29, 2026
12 checks passed
@OkiriGabriel
OkiriGabriel deleted the fix/slack-approvers-117 branch November 26, 2026 10:13
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.

[SECURITY] Any Slack user can approve production changes; approver identity is neither checked nor audited

1 participant