Ensure Gateway ID validation consistency in ProcessWebhook
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia da payment/service.go, concentrandoti su ProcessWebhook e sul relativo blocco di transazione intorno alle righe 278–323; confronta i controlli del gateway con il flusso di ValidateReference. Esegui i test di pagamento pertinenti e aggiungi una copertura per un webhook il cui ID gateway differisce da quello della transazione memorizzata. Il lavoro è completato quando i gateway non corrispondenti non possono modificare lo stato della transazione e i test passano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Go
- Stelle
- 6
- Fork
- 8
- Merge medio
- 21h 36m
- PR unite (30g)
- 42
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di OpenNSW/core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
payment: test fixtures hardcode real gateway names (govpay/lankapay) instead of generic placeholdersAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
nsw-sl cleanup Type/Improvement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
remote: let the host inject a logger, and log with one consistent policyForse già presa @mushrafmim l’ha presa 5 giorni fa. ApertaType/Improvement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
I maintainer di solito rispondono entro 1 giorno
-
taskflow: run extensions through one dispatcher and tell them which phase they run inForse già presa @mushrafmim l’ha presa 11 giorni fa. ApertaType/Improvement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di OpenNSW/core
Issue simili
-
☢️ Bug v3
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area/import-export area/projects concern/ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
go-vikunja/vikunja#4455 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Dependabot PRs no longer merge automaticallyForse già presa @dwisiswant0 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
projectdiscovery/urlfinder#160 ·
I maintainer di solito rispondono entro 1 giorno
-
database
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
chnm/legal-modernism#450 ·
I maintainer di solito rispondono entro 1 giorno
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno