fix(instagram): enforce webhook signature verification outside production and deduplicate echo events before DB writes
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- postgresql, redis, typescript
- Lĩnh vực
- backend-api-design, databases, security
Hướng nghiên cứu
Đọc phần quanh handleWebhook trong apps/api/src/instagram/instagram.controller.ts và phần quanh processEchoMessagingEvent trong apps/api/src/instagram/services/instagram-webhook-router.service.ts. Kiểm tra các mẫu hiện có về xác minh chữ ký webhook và loại bỏ trùng lặp bằng Redis, sau đó chạy các bài kiểm thử API liên quan. Công việc hoàn tất khi các secret đã cấu hình kích hoạt việc xác minh chữ ký và các sự kiện echo trùng lặp được trả về trước khi ghi vào hội thoại hoặc phần theo dõi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 2
- Fork
- 1
- Merge trung bình
- 6 phút
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sumamakhan761/tryinstance
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sumamakhan761/tryinstance#65 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
sumamakhan761/tryinstance#64 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
sumamakhan761/tryinstance#63 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sumamakhan761/tryinstance#62 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sumamakhan761/tryinstance#60 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của sumamakhan761/tryinstance
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
makecindy/cindy#15342 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
kwitsch/claude-code-plugin-tooling#219 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
no-repo-link tool-submission
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100