← Back to Manara Bugs · View issue #79 in MantisBT
Reported by: Khaled Tarabay on 2026-07-27T12:06:43+01:00
Assigned to: Claude
Resolved by: Claude on 2026-07-27T12:46:42+01:00
Severity: major
Priority: normal
Reproducibility: always
Category: General
Description: The Record Payment form's Paid At field accepts arbitrary dates with no server-side range validation, allowing payments to be backdated before the invoice existed or postdated decades into the future. The paid_at field on /payments/create has no min/max attribute client-side, and testing confirms the same holds server-side. Two payments were recorded against the same invoice with paid_at set to 2020-01-01 (before the invoice was ever created) and 2099-12-31 (73 years in the future) both were accepted (HTTP 302, both amounts summed correctly into PAID). Since Paid At drives date-based financial views (Reconciliation, monthly/daily revenue reports, dashboards), a bad or malicious date here silently corrupts those downstream numbers with no error, warning, or audit flag.
Steps to Reproduce: Create and Issue any invoice with a line item (e.g. $20.00). Go to /payments/create?invoice_id={id}, or POST directly to /payments. Submit a payment with paid_at=2020-01-01T00:00 (or any date before the invoice's creation date). Observe it is accepted and appears on the invoice and in the Payments list dated 2020. Submit a second payment on the same invoice with paid_at=2099-12-31T23:59. Observe it is also accepted. Confirm both entries show in /payments with their forced dates, and the invoice's PAID total includes both.
Resolution: FIXED. What: the Record Payment form's Paid At field had no server-side range validation at all — a payment could be backdated before the invoice it's against ever existed, or postdated decades into the future, and both silently summed correctly into the invoice's PAID total with no warning.
Where: app/controllers/PaymentController.php (validate()) — reuses the Validator::dateWithinRange() helper already added elsewhere in this codebase for the identical class of bug (wallet occurred_at, reconciliation business_date, subscription dates).
Why: paid_at was only checked for being a well-formed date/time, never bounded against anything. Since Paid At drives every date-based financial view (Reconciliation, revenue reports, dashboards), an out-of-range date silently corrupts those with no error or flag — exactly as the ticket described.
Fix: Paid At now can't be earlier than the invoice's own issued_at (a payment can't predate the invoice it's against), and can't be more than a day in the future (a small buffer for timezone slop, same convention used elsewhere in this app).
Verified live against the local database: the ticket's exact repro (paid_at=2020-01-01 against a 2026-issued invoice, and paid_at=2099-12-31) were both correctly rejected, each naming the real bound (“Paid At can't be earlier than 2026-07-27.” / “…can't be later than 2026-07-28.”); a same-day, in-range payment still succeeds normally. Full test suite: 29/29 passing. Test invoice/payment removed afterward.
Where: app/controllers/PaymentController.php (validate()) — reuses the Validator::dateWithinRange() helper already added elsewhere in this codebase for the identical class of bug (wallet occurred_at, reconciliation business_date, subscription dates).
Why: paid_at was only checked for being a well-formed date/time, never bounded against anything. Since Paid At drives every date-based financial view (Reconciliation, revenue reports, dashboards), an out-of-range date silently corrupts those with no error or flag — exactly as the ticket described.
Fix: Paid At now can't be earlier than the invoice's own issued_at (a payment can't predate the invoice it's against), and can't be more than a day in the future (a small buffer for timezone slop, same convention used elsewhere in this app).
Verified live against the local database: the ticket's exact repro (paid_at=2020-01-01 against a 2026-issued invoice, and paid_at=2099-12-31) were both correctly rejected, each naming the real bound (“Paid At can't be earlier than 2026-07-27.” / “…can't be later than 2026-07-28.”); a same-day, in-range payment still succeeds normally. Full test suite: 29/29 passing. Test invoice/payment removed afterward.
| Date | User | Field | Change |
|---|---|---|---|
| 2026-07-27T12:06:43+01:00 | Khaled Tarabay | issue-new | New Issue |
| 2026-07-27T12:46:36+01:00 | Claude | Assigned To | ⇒ Claudine |
| 2026-07-27T12:46:38+01:00 | Claude | tag-added | Tag Attached: done-by-claude |
| 2026-07-27T12:46:40+01:00 | Claude | note-added | Note Added: 0000038 |
| 2026-07-27T12:46:42+01:00 | Claude | Status | new ⇒ resolved |
Synced automatically from MantisBT issue #79.