fix(bug-handler): fail closed when BUG_ALLOWED_SENDERS is unset by duyet · Pull Request #2525 · chmonitor/chmonitor · GitHub
Skip to content

fix(bug-handler): fail closed when BUG_ALLOWED_SENDERS is unset - #2525

Merged
duyet merged 1 commit into
mainfrom
improve/85-bug-handler-fail-closed
Jul 10, 2026
Merged

fix(bug-handler): fail closed when BUG_ALLOWED_SENDERS is unset#2525
duyet merged 1 commit into
mainfrom
improve/85-bug-handler-fail-closed

Conversation

@duyet

@duyet duyet commented Jul 10, 2026

Copy link
Copy Markdown
Member

What

isSenderAllowed in apps/bug-handler/src/config.ts failed open: an unset
BUG_ALLOWED_SENDERS (the default, and current production state — it's not
set anywhere in wrangler.toml or CI) let any sender emailing
bug@chmonitor.dev create GitHub issues in the configured repo. SPF only
authenticates the sending domain, not authorization, and the worker's
intended source is Sentry alert mail only.

parseConfig now resolves BUG_ALLOWED_SENDERS to:

Value Resolves to Effect
unset ['@sentry.io', '@notifications.sentry.io'] Sentry-only, fail closed (new default)
"" (explicit empty) [] rejects every sender
"*" ['*'] explicit opt-out — allows every sender
comma list parsed list unchanged

isSenderAllowed([]) now rejects (previously allowed) — the "*" sentinel
is the new explicit "allow all" signal. Rejected senders are logged with
sender + subject at warn level before the message is dropped, so operators
notice misconfiguration or a Sentry sending-domain change.

Why

Issue spam / content injection into the tracker (which coding agents read)
via any sender who discovers the address — see #2502.

Files changed

  • apps/bug-handler/src/config.ts — new default/sentinel constants, updated
    parseConfig and isSenderAllowed semantics
  • apps/bug-handler/src/index.ts — warn-log now includes the subject; Env
    doc comment updated
  • apps/bug-handler/src/config.test.ts, apps/bug-handler/src/index.test.ts
    — extended for the unset/""/"*"/explicit-list cases + the warn-log
    assertion; FULL_ENV's BUG_ALLOWED_SENDERS moved from '' (previously
    "allow all") to the explicit '*' opt-out so unrelated tests keep their
    original "no sender restriction" intent
  • docs/knowledge/bug-handler-email-worker.md — documents the three cases
    and the warn-log signal; bumped updated: date

Verification

  • Ran locally by symlinking the repo-root node_modules (this worktree has
    none) plus a direct link to bun's own postal-mime cache entry
    (~/.bun/install/cache, no install command run) so bun test could
    resolve the worker's one runtime dependency:
    • bun test src/91 pass, 0 fail (up from 82 baseline + 9 new)
    • tsc --noEmit — clean
  • Checked the STOP condition in the plan (production relying on non-Sentry
    senders): BUG_ALLOWED_SENDERS is not set in wrangler.toml or any CI
    workflow, and the repo has zero issues carrying the bot's
    bug+sentry+automated labels — the worker has not created any issue
    in production yet, Sentry or otherwise, so the default change drops no
    real mail.
  • CI (bug-handler's own job) will re-run the full suite.

Closes #2502

https://claude.ai/code/session_018h2h5erikMP3aM7p8YdXfY

The sender allowlist previously failed open: an unset BUG_ALLOWED_SENDERS
let any sender emailing bug@ open GitHub issues in the configured repo.
SPF only authenticates the sending domain, not authorization, and the
worker's intended source is Sentry alert mail only.

parseConfig now resolves BUG_ALLOWED_SENDERS to:
- unset -> built-in Sentry-only default (@sentry.io, notifications.sentry.io)
- "" (explicit empty) -> reject every sender
- "*" -> explicit opt-out, allow every sender
- comma list -> parsed allowlist, unchanged

Rejected senders are now logged with sender + subject at warn level so
operators notice dropped mail (misconfiguration, or Sentry changing its
sending domain). Documented in docs/knowledge/bug-handler-email-worker.md.

Co-Authored-By: duyetbot <bot@duyet.net>
@duyet
duyet enabled auto-merge (squash) July 10, 2026 00:58
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Deployment

App Preview URL
Dashboard https://preview.dash.chmonitor.dev
MCP https://preview.dash.chmonitor.dev/api/mcp
Landing https://preview.chmonitor.dev
Docs https://preview.docs.chmonitor.dev
Property Value
Commit 1ad7bb8
Deployed at 2026-07-10T00:58:17.289Z

Previews are automatically updated on every push to this PR.
Unchanged apps keep their previous preview (path-filtered deploys).

@duyet
duyet merged commit ea30384 into main Jul 10, 2026
15 checks passed
@duyet
duyet deleted the improve/85-bug-handler-fail-closed branch July 10, 2026 00:58
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(bug-handler): sender policy fails open — unset BUG_ALLOWED_SENDERS lets anyone mailing bug@ open GitHub issues

1 participant