flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Backend] createStreamSchema Zod validator is still unused; depositedAmount has no MAX_I128 cap

Open K1NGD4VID opened this issue 2 months ago • 7 comments

Labels: backend, bug, security, validation, third-wave-audit File/location: backend/src/validators/stream.validator.ts:36 (createStreamSchema), backend/src/routes/v1/stream.routes.ts:40, backend/src/controllers/stream.controller.ts:102-230 (createStream)

Description: createStreamSchema (with its MAX_I128 bound on ratePerSecond) is defined and unit-tested in isolation but is never imported by any route or controller — router.post('/', requireAuth, streamCreationRateLimiter, createStream) calls the manual ad-hoc BigInt parsing in createStream instead of createStreamSchema.safeParse. That manual path validates ratePerSecond/depositedAmount are positive integers but never caps depositedAmount against MAX_I128 (170141183460469231731687303715884105727), so an oversized depositedAmount string can pass validation and reach BigInt arithmetic / persisted i128 DB columns unchecked.

Acceptance Criteria:

  • [ ] POST /v1/streams rejects a depositedAmount value greater than i128::MAX with a 400 error
  • [ ] createStream either uses createStreamSchema.safeParse or the manual validation path gains an equivalent MAX_I128 check for depositedAmount
  • [ ] A regression test posts a depositedAmount > i128::MAX and asserts a 400 response

Notes: Two prior issues (#452 'Wire createStreamSchema validation into POST /v1/streams' and #1273 'A stricter validation schema exists but is never used') were filed and closed for this exact defect class, but the current code on main still shows the schema unused and the depositedAmount bound missing — worth checking whether the fix regressed or was never actually merged into this code path.

K1NGD4VID avatar Sep 27 '26 21:09 K1NGD4VID

Hi maintainers,

I reviewed this issue and would like to contribute the fix.

Solution overview:

  1. Audit authorization boundaries and enforce defensive validation barriers.
  2. Implement multi-role permission checks and invocation validation.
  3. Write adversarial unit tests simulating edge failure modes and invalid callers.
  4. Ensure zero regressions across existing test suites and CI workflows.

I can deliver a clean, tested PR within 24 hours. Please assign!

Ranjeet2063 avatar Oct 04 '26 19:10 Ranjeet2063

@ejiromowarin has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

I would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @ejiromowarin to this issue.

ejiromowarin avatar Oct 18 '26 03:10 ejiromowarin

@OmniZlatoon has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

KINGDAVID sir, Can I work on this in 3 hours sir?

ℹ️ Repo Maintainers: To accept this application, review their application or assign @OmniZlatoon to this issue.

OmniZlatoon avatar Oct 18 '26 03:10 OmniZlatoon

@fadesany has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer, i would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @fadesany to this issue.

fadesany avatar Oct 18 '26 03:10 fadesany

Congratulations, @fadesany! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @fadesany: 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 🌊

drips-wave[bot] avatar Oct 18 '26 03:10 drips-wave[bot]

🎉 This issue has been marked as completed on GrantFox!

@fadesany's PR #1630 was approved and merged by @K1NGD4VID.

🏆 @fadesany: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,225 total points). Track your full progress on GrantFox.

👏 Great work, @fadesany! Keep contributing to LabsCrypt.

grantfox-oss[bot] avatar Oct 18 '26 04:10 grantfox-oss[bot]

This issue has been completed by @fadesany as part of the Stellar Wave Program's 10th Wave 🥳

😎 @fadesany: 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.

drips-wave[bot] avatar Oct 18 '26 04:10 drips-wave[bot]