User Tools

Site Tools


wiki:manara:bugs:50

#50 — occurred_at accepts dates outside any valid range (Resolved)

← Back to Manara Bugs · View issue #50 in MantisBT


Reported by: Khaled Tarabay on 2026-07-27T07:52:25+01:00
Assigned to: Claude
Resolved by: Claude on 2026-07-27T08:04:59+01:00
Severity: major
Priority: normal
Reproducibility: always
Category: General

Description: The wallet-transaction occurred_at field has no server-side date range validation transactions were recorded with dates in 2015 and 2099, both accepted. Recorded two wallet transactions via raw POST with occurred_at forced to 2015-01-01 and 2099-01-01. Both were accepted (302) and both appear in the customer's wallet history with their forced dates. This is the same class of bug as BUG-P01 (Payments' paid_at) since wallet history is a date-ordered ledger feeding balance and reporting views, an out-of-range date silently corrupts any date-based read of it.

add a real service-side range validation on occurred at, with a lower bound, upper bound, and apply it server side on actual post handler not just as an HTML attribute

Steps to Reproduce: Go to /wallet/create for any customer, or POST directly to /wallet. Submit a transaction with occurred_at=2015-01-01T00:00. Submit a second transaction with occurred_at=2099-01-01T00:00. Open the customer's wallet history (/wallet/{id}) and confirm both rows appear with their forced, out-of-range dates.

Resolution: FIXED. What: the wallet-transaction occurred_at field had no server-side date RANGE validation – only that the string was a parseable datetime. Transactions with occurred_at forced to 2015-01-01 and 2099-01-01 were both accepted and appeared in the customer's wallet history with those out-of-range dates, corrupting any date-ordered ledger read (balance history, reporting).

Where: app/classes/Core/Validator.php (new dateWithinRange() method, reusable for any other freely-typed historical/scheduled date in the app), app/controllers/WalletController.php (validate() now calls it with a rolling 5-years-back / 1-day-ahead bound), app/views/wallet/form.php (the datetime-local input also gets matching min/max HTML attributes as a UX nicety – NOT the enforcement mechanism itself).

Why: the previous check (DateTime::createFromFormat) only confirmed the STRING was a real calendar date/time – it had no opinion on whether that date made sense for a wallet ledger entry. The bounds are relative to “now” (not a hardcoded literal) so they age correctly with the app: no legitimate wallet entry should be backdated more than 5 years, and +1 day covers timezone slop without allowing a genuinely future-dated entry.

Fix: server-side range check enforced in the actual POST handler (WalletController::validate()), independent of the HTML min/max attributes – verified by posting directly with the HTML attributes bypassed entirely.

Verified live against the local database: direct POSTs with occurred_at=2015-01-01 and occurred_at=2099-01-01 were both correctly rejected with a clear field error (“Date can't be earlier than <date>.” / “Date can't be later than <date>.”). A POST 4 years back (within the 5-year window) succeeded; a POST 6 years back was correctly rejected. Full test suite: 29/29 passing.

Note: Payment's own paid_at field (and a few other freely-typed historical dates elsewhere in the app) has the same latent gap – out of scope for this ticket, flagged in CLAUDE.md as a candidate for a follow-up if it's reported there too.

Activity / Notes

  • 2026-07-27T08:04:56+01:00 - Claude: FIXED. What: the wallet-transaction occurred_at field had no server-side date RANGE validation – only that the string was a parseable datetime. Transactions with occurred_at forced to 2015-01-01 and 2099-01-01 were both accepted and appeared in the customer's wallet history with those out-of-range dates, corrupting any date-ordered ledger read (balance history, reporting).

Where: app/classes/Core/Validator.php (new dateWithinRange() method, reusable for any other freely-typed historical/scheduled date in the app), app/controllers/WalletController.php (validate() now calls it with a rolling 5-years-back / 1-day-ahead bound), app/views/wallet/form.php (the datetime-local input also gets matching min/max HTML attributes as a UX nicety – NOT the enforcement mechanism itself).

Why: the previous check (DateTime::createFromFormat) only confirmed the STRING was a real calendar date/time – it had no opinion on whether that date made sense for a wallet ledger entry. The bounds are relative to “now” (not a hardcoded literal) so they age correctly with the app: no legitimate wallet entry should be backdated more than 5 years, and +1 day covers timezone slop without allowing a genuinely future-dated entry.

Fix: server-side range check enforced in the actual POST handler (WalletController::validate()), independent of the HTML min/max attributes – verified by posting directly with the HTML attributes bypassed entirely.

Verified live against the local database: direct POSTs with occurred_at=2015-01-01 and occurred_at=2099-01-01 were both correctly rejected with a clear field error (“Date can't be earlier than <date>.” / “Date can't be later than <date>.”). A POST 4 years back (within the 5-year window) succeeded; a POST 6 years back was correctly rejected. Full test suite: 29/29 passing.

Note: Payment's own paid_at field (and a few other freely-typed historical dates elsewhere in the app) has the same latent gap – out of scope for this ticket, flagged in CLAUDE.md as a candidate for a follow-up if it's reported there too.

Full History

Date User Field Change
2026-07-27T07:52:25+01:00 Khaled Tarabay issue-new New Issue
2026-07-27T08:04:51+01:00 Claude Assigned To ⇒ Claudine
2026-07-27T08:04:53+01:00 Claude tag-added Tag Attached: done-by-claude
2026-07-27T08:04:56+01:00 Claude note-added Note Added: 0000012
2026-07-27T08:04:59+01:00 Claude Status new ⇒ resolved

Synced automatically from MantisBT issue #50.

wiki/manara/bugs/50.txt · Last modified: by mantisbot