[Audit] Duplicate/retried withdraw requests double-count `withdrawnAmount`
Filed from the second-wave repository audit (issue 14/100). See the audit summary for full category context.
- Location:
backend/src/routes/v1/streams/withdraw.ts:106-144 - Problem:
sorobanWithdrawreturns a deterministic, non-uniquetxHash('simulated-withdraw-' + streamId), so theStreamEventupsert (keyed ontransactionHash+eventType) correctly no-ops on a retry — but the adjacentprisma.stream.updatethat incrementswithdrawnAmountis not guarded by the same dedup check and runs unconditionally on every call. - Evidence:
StreamEventupsert has anupdate: {}no-op branch; thestream.updateabove it has no equivalent guard. - Suggested implementation: Wrap both writes in one transaction gated by the same duplicate-event check, or make the balance update itself idempotent (compute from indexed on-chain state rather than incrementing).
- Acceptance criteria: Calling withdraw twice for the same claimable window increases
withdrawnAmountby the claimed amount exactly once, verified by a new integration test. - Difficulty: M
- Expected impact: Fixes a real fund-accounting bug reachable via a simple double-click or client retry.
@Martinsbab has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
Hi maintainer, I would love to work on this issue
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Martinsbab to this issue.
@akinerin has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
I would love to work on this issue, please assign it to me
ℹ️ Repo Maintainers: To accept this application, review their application or assign @akinerin to this issue.
@Rafiat30 has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
i would love to work on this
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Rafiat30 to this issue.
@Hamda-gbade has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
I can handle this if assigned to me
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Hamda-gbade to this issue.
@ayomustap has applied to work on this issue as part of the Stellar Wave Program's 8th wave.
Hi maintainer, I would love to work on this issue. I can get started on it right away.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @ayomustap to this issue.
Congratulations, @Martinsbab! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.
🧑💻 @Martinsbab: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
🎉 This issue has been marked as completed on GrantFox!
@Martinsbab's PR #1410 was approved and merged by @K1NGD4VID.
🏆 @Martinsbab: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (245 total points). Track your full progress on GrantFox.
👏 Great work, @Martinsbab! Keep contributing to LabsCrypt.
This issue has been completed by @Martinsbab as part of the Stellar Wave Program's 11th Wave 🥳
😎 @Martinsbab: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.