fix(alerts): rate limit alert channel test messages and cap channels per workspace

オープン
#771 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
next.js, playwright, postgresql, react, typescript

調査の方向性

Start with src/app/w/[workspace]/alerts/actions.ts and compare the existing email test limit with sendAlertChannelTest; read src/lib/rate-limit/attempts.ts for limit definitions. Follow the api_keys_enforce_limit migration pattern for the workspace cap, then inspect the related pgTAP, unit, and Playwright tests. Done means both limits and the form refusal work, with the stated tests passing; verify the issue is still unclaimed before starting.

索引モデルが issue の本文から書いたものです。

説明

area: alerts area: security bug impact: medium priority: P2 size: XS

Context

Found by the Fable pre-production review on 2026-12-02 (main at cedc1914; every line reference below re-checked on main at cde5aa3b). Source: security and privacy readiness report, new issue 5.

sendAlertChannelTest posts to the channel's URL with no attempt limit (src/app/w/[workspace]/alerts/actions.ts:672-693), while the email test has one (countAttempt("alert-email-test", ...), :515). Private and local addresses are refused (src/lib/notifications/channels.ts:40-110), so this is abuse, not SSRF. There is no cap on alert channels per workspace in the database; DESTINATIONS_LIMIT = 50 only bounds reads (src/lib/data/notification-destinations.ts:50). Other tables enforce a cap with a trigger (api_keys_enforce_limit, supabase/migrations/20261105120320_api_keys.sql:88-116; webhook_endpoints_enforce_limit, 20261116120000_webhook_setup.sql:40-65).

Impact: an owner or admin can add a generic webhook channel pointing at any public HTTPS URL and loop the Server Action, using StackDash as a request relay. Against Slack or Discord this draws rate limits on the egress addresses every workspace's alerts share, so other workspaces' alerts are delayed. Low risk while sign-up is invite only; needed before #143.

The channel cap needs a migration (a limit trigger on notification_destinations), so it is not a code-only change.

Plan

  1. Add countAttempt to sendAlertChannelTest, per user and per IP, with its own limit name, returning a plain refusal with the wait time (same pattern as :515).
  2. Add a migration with a trigger that caps channels per workspace at DESTINATIONS_LIMIT, following api_keys_enforce_limit.
  3. Show the cap's refusal on the add channel form.

Acceptance criteria

  • Channel test sends are limited per user and per IP with a plain refusal message.
  • The database refuses a channel past the per-workspace cap (pgTAP).
  • A unit test covers the test-send refusal.
  • Playwright e2e: the add channel refusal is announced, with an axe scan.

Files and areas

src/app/w/[workspace]/alerts/actions.ts, src/lib/rate-limit/attempts.ts (limit definition), a new migration, pgTAP and unit tests.

Non-goals: connection caps (#85), other alert actions.

Verification

npm run typecheck, npm run lint, npx vitest run src/app/w/[workspace]/alerts, npm run test:db.


Branch: <issue-number>-channel-test-limit

Model: anthropic/claude-opus-5-5 | Reasoning effort: unknown

主要言語
TypeScript
スター
13
フォーク
2
平均マージ
5時間 20分
マージ済み PR(30日)
287

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

eddiejaoude/StackDash のほかの issue

eddiejaoude/StackDash の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。