Finding (input validation / data integrity — low severity)
RecordSaleCommandValidator requires QuantitySold > 0 (good — blocks negative/zero manipulation), but sets no upper bound. RecordSaleCommandHandler does item.QuantitySold += request.QuantitySold where item.QuantitySold is an int. A caller (the fundraiser's own owner — ownership is enforced) could record an absurd quantity near int.MaxValue; a second such sale overflows the accumulated int, wrapping it negative and corrupting the fundraiser's TotalRaisedCents.
Scope is limited: ownership is checked (can only affect one's OWN fundraiser), pricing is server-side (SellingPriceCents from the item, not the client — no price manipulation), and the money math itself is overflow-safe (SellingPriceCents is long, so long * int is computed in long). So this is a data-integrity robustness gap, not a security exploit — but absurd quantities shouldn't be accepted.
Fix (this PR)
Add QuantitySold.LessThanOrEqualTo(1_000_000) to the validator (a single sale recording of >1M units is not a legitimate input; incremental recording is expected). Prevents the int overflow / absurd totals. Added a validator test for the new bound.
## Finding (input validation / data integrity — low severity)
`RecordSaleCommandValidator` requires `QuantitySold > 0` (good — blocks negative/zero manipulation), but sets **no upper bound**. `RecordSaleCommandHandler` does `item.QuantitySold += request.QuantitySold` where `item.QuantitySold` is an `int`. A caller (the fundraiser's own owner — ownership is enforced) could record an absurd quantity near `int.MaxValue`; a second such sale overflows the accumulated `int`, wrapping it negative and corrupting the fundraiser's `TotalRaisedCents`.
Scope is limited: ownership is checked (can only affect one's OWN fundraiser), pricing is server-side (`SellingPriceCents` from the item, not the client — no price manipulation), and the money math itself is overflow-safe (`SellingPriceCents` is `long`, so `long * int` is computed in long). So this is a data-integrity robustness gap, not a security exploit — but absurd quantities shouldn't be accepted.
## Fix (this PR)
Add `QuantitySold.LessThanOrEqualTo(1_000_000)` to the validator (a single sale recording of >1M units is not a legitimate input; incremental recording is expected). Prevents the int overflow / absurd totals. Added a validator test for the new bound.
Resolved in spikersoft-backend PR #390 (merged to master). Capped RecordSale QuantitySold at 1,000,000 in the validator so absurd values can't overflow the accumulated int total. 7 validator tests pass. Closing.
Resolved in spikersoft-backend PR #390 (merged to `master`). Capped RecordSale QuantitySold at 1,000,000 in the validator so absurd values can't overflow the accumulated int total. 7 validator tests pass. Closing.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Finding (input validation / data integrity — low severity)
RecordSaleCommandValidatorrequiresQuantitySold > 0(good — blocks negative/zero manipulation), but sets no upper bound.RecordSaleCommandHandlerdoesitem.QuantitySold += request.QuantitySoldwhereitem.QuantitySoldis anint. A caller (the fundraiser's own owner — ownership is enforced) could record an absurd quantity nearint.MaxValue; a second such sale overflows the accumulatedint, wrapping it negative and corrupting the fundraiser'sTotalRaisedCents.Scope is limited: ownership is checked (can only affect one's OWN fundraiser), pricing is server-side (
SellingPriceCentsfrom the item, not the client — no price manipulation), and the money math itself is overflow-safe (SellingPriceCentsislong, solong * intis computed in long). So this is a data-integrity robustness gap, not a security exploit — but absurd quantities shouldn't be accepted.Fix (this PR)
Add
QuantitySold.LessThanOrEqualTo(1_000_000)to the validator (a single sale recording of >1M units is not a legitimate input; incremental recording is expected). Prevents the int overflow / absurd totals. Added a validator test for the new bound.Resolved in spikersoft-backend PR #390 (merged to
master). Capped RecordSale QuantitySold at 1,000,000 in the validator so absurd values can't overflow the accumulated int total. 7 validator tests pass. Closing.