fix(instagram): enforce webhook signature verification outside production and deduplicate echo events before DB writes
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- postgresql, redis, typescript
調査の方向性
apps/api/src/instagram/instagram.controller.ts の handleWebhook 周辺と、apps/api/src/instagram/services/instagram-webhook-router.service.ts の processEchoMessagingEvent 周辺を読んでください。既存の webhook 署名検証と Redis による重複排除のパターンを確認し、関連する API テストを実行してください。設定済みのシークレットによって署名検証が行われ、重複した echo イベントが会話やフォローアップへの書き込み前に返されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem Description
-
Webhook signature verification is skipped when
NODE_ENV !== 'production':
Inapps/api/src/instagram/instagram.controller.ts(handleWebhook, lines 258-276), Meta'sX-Hub-Signature-256verification is gated behindprocess.env.NODE_ENV === 'production'.
Any staging deployment or misconfigured server whereNODE_ENVis unset or not'production'accepts forged, unauthenticatedPOST /webhooks/instagrampayloads, allowing attackers to inject fake DMs/comments and trigger automations or AI replies. -
Echo webhook mutates state before deduplication:
Inapps/api/src/instagram/services/instagram-webhook-router.service.ts(processEchoMessagingEvent, lines 475-518),conversation.update(deactivating AI and settingautomationPausedUntil = now + 30m) andpendingFollowUp.updateMany(cancelling pending follow-ups) execute beforeredisService.reserveWebhookEvent('echo:' + messageMid)(lines 512-518).
If Meta retries an echo webhook, the conversation's pause window can be re-extended before deduplication runs.
Expected Behavior
POST /webhooks/instagramverifiesX-Hub-Signature-256wheneverINSTAGRAM_APP_SECRETorMETA_APP_SECRETis configured (skipping only if an explicit local dev bypass flag such asALLOW_UNSIGNED_WEBHOOKS=trueis set in non-production).processEchoMessagingEventchecksredisService.reserveWebhookEvent('echo:' + messageMid)first, returning early on duplicates before mutatingconversationorpendingFollowUp.
Where to Look
apps/api/src/instagram/instagram.controller.ts(handleWebhook, lines 258-276)apps/api/src/instagram/services/instagram-webhook-router.service.ts(processEchoMessagingEvent, lines 475-518)
Solution / Implementation Guide
- In
instagram.controller.ts(handleWebhook):- Enforce
X-Hub-Signature-256verification whenever an app secret is configured (instead of gating onNODE_ENV === 'production'), and allow unsigned requests only whenNODE_ENV !== 'production' && process.env.ALLOW_UNSIGNED_WEBHOOKS === 'true'(so local webhook testing tools still work when explicitly enabled).
- Enforce
- In
instagram-webhook-router.service.ts(processEchoMessagingEvent):- Extract
messageMidat the top ofprocessEchoMessagingEventand callredisService.reserveWebhookEvent('echo:' + messageMid)before updatingconversationor cancellingpendingFollowUprecords.
- Extract
- 主要言語
- TypeScript
- スター
- 2
- フォーク
- 1
- 平均マージ
- 6分
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sumamakhan761/tryinstance のほかの issue
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#65 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sumamakhan761/tryinstance#64 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
sumamakhan761/tryinstance#63 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#62 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#60 ·
メンテナーはふだん 1 日以内に返信
sumamakhan761/tryinstance の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
makecindy/cindy#15342 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
kwitsch/claude-code-plugin-tooling#219 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
no-repo-link tool-submission
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100