Ensure Gateway ID validation consistency in ProcessWebhook
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
Hướng nghiên cứu
Bắt đầu với payment/service.go, tập trung vào ProcessWebhook và khối giao dịch quanh các dòng 278–323; so sánh các bước kiểm tra gateway của nó với luồng ValidateReference. Chạy các bài kiểm thử thanh toán liên quan và bổ sung kiểm thử cho webhook có ID gateway khác với giao dịch đã lưu. Hoàn thành khi các gateway không khớp không thể thay đổi trạng thái giao dịch và các bài kiểm thử đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue: Missing Gateway Validation in Webhook Processing
Description
In the payment package, incoming webhook requests are processed via the ProcessWebhook method in payment/service.go. Currently, this method retrieves a transaction using only the parsed reference number from the webhook payload. However, it does not verify that the transaction's stored GatewayID matches the gatewayID parameter provided in the URL route (/api/v1/payments/:gatewayID/webhook).
This omission allows one payment gateway (or any client spoofing that gateway's route) to potentially alter or settle transaction records belonging to another gateway, creating a data integrity risk and security vulnerability.
Similar validation is correctly performed in the ValidateReference flow (used for real-time reference checking).
Impact
- Cross-Gateway Mutation: A webhook routed to
/api/v1/payments/gateway-a/webhookcould succeed in marking a transaction as successful even if that transaction was initialized undergateway-b. - Security & Auditing: Weakens the separation of duties and trust boundaries between different payment providers.
Code References
- Target File: service.go
- Location: Inside the repository transaction block in
ProcessWebhook: service.go#L278-L323
Proposed Solution
Add a validation check inside the RunInTransaction block in ProcessWebhook to ensure the gateway identifiers match before modifying the transaction state.
// Inside ProcessWebhook in service.go
err = s.repo.RunInTransaction(ctx, func(repo PaymentRepository) error {
tx, err := repo.GetByReferenceNumberForUpdate(ctx, gwPayload.ReferenceNumber)
if err != nil {
return fmt.Errorf("failed to retrieve transaction by reference: %w", err)
}
if tx == nil {
return fmt.Errorf("reference %s: %w", gwPayload.ReferenceNumber, ErrTransactionNotFound)
}
// NEW VALIDATION: Ensure the webhook matches the gateway configured for this transaction
if tx.GatewayID != gatewayID {
return fmt.Errorf("gateway mismatch for transaction %s: expected %s, got %s: %w",
tx.ReferenceNumber, tx.GatewayID, gatewayID, ErrTransactionNotFound)
}
// ... existing status and amount checks ...
})
By returning ErrTransactionNotFound (or a similar error), the HTTP handler will return a 404 Not Found (or 422 Unprocessable Entity), signaling to the gateway to stop retrying the mismatched payload.
- Ngôn ngữ chính
- Go
- Star
- 6
- Fork
- 8
- Merge trung bình
- 21 giờ 36 phút
- Pull request đã merge (30 ngày)
- 42
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 OpenNSW/core
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
payment: test fixtures hardcode real gateway names (govpay/lankapay) instead of generic placeholdersĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
nsw-sl cleanup Type/Improvement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
remote: let the host inject a logger, and log with one consistent policyCó thể đã có người làm @mushrafmim đã nhận 5 ngày trước. Đang mởType/Improvement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
-
taskflow: run extensions through one dispatcher and tell them which phase they run inCó thể đã có người làm @mushrafmim đã nhận 11 ngày trước. Đang mởType/Improvement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
☢️ Bug v3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/import-export area/projects concern/ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
go-vikunja/vikunja#4455 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Dependabot PRs no longer merge automaticallyCó thể đã có người làm @dwisiswant0 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
projectdiscovery/urlfinder#160 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
database
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
chnm/legal-modernism#450 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày