21 Commits
Author SHA1 Message Date
Rodrigo Cortés Cano 907117b4b8 Queue broadcast messages for background sending (#1054)
When doing a broadcast message, create a list of pending recipients in new db tables, and processes each message in turn. Jobs can be cancelled/retried. Locking is in place to try and stop multiple concurrent jobs being run. 

Adds db tables: broadcast_job, broadcast_job_domain and broadcast_recipient. 

thanks @TrapoSAMA
2026-11-20 20:20:34 +00:00
David Goodwin ae85e51f6e Security fixes (master only) (#1165)
Someone wishing to remain anonymous emailed @cboltz a number of security issues, summarised below.

1. fix sql injection bug in getPageBrowser - search keys bypass the field filter, due to 2a6f27c3 / #1127
2. when performing a password change, do not start the session before the new password has been validated for compexity etc - as things stand someone with a recovery code gets logged in even if their password gets
rejected. Also invalid recovery code on failure.
3. broadcast-message.php was using smtp_mail() with incorrect args, and passing the SMTP password in as the mail body. - probably related to commit 7f1d78e and 42a664e9c2
4. a regular (non-admin) user could submit an arbitrary username in the POST data and create/edit a TOTP exception for another user or entire domain

PR includes refactoring of the password change code (into PasswordChangeAttempt) to make it easier to test/verify.
2026-10-17 09:27:59 +01:00
Copilot ae7339afd4 Use native booleans for prepared SQL params; stop binding db_get_boolean() values (#1019)
Prepared statements were binding DB-specific boolean literals (`'t'/'f'`) produced by `db_get_boolean()`, which breaks PostgreSQL parameter typing in some paths (notably mailbox creation via handler flows). 

This change standardizes bound boolean parameters to native PHP `true`/`false` (which are then cast to 0/1 which seems to work fine within PDO/PostgreSQL).

fixes https://github.com/postfixadmin/postfixadmin/issues/1017
2026-04-23 19:28:01 +01:00
Kent Riboe 26530c5d0b Replace escape_string() concatenation with parameterized queries (#1004)
* Replace most escape_string() usages with parameterized queries (reducing the chance of SQL injection), see also #1003 

thanks @knofte
2026-04-06 20:47:34 +01:00
David Goodwin 8a1f9a11af CSRF protection - support multiple tokens (#985)
possible fix for https://github.com/postfixadmin/postfixadmin/issues/967

CSRF Token changes : rather than have one PFA_Token value in $_SESSION, store a list of them, where each value has a time stamp it was issued on. The aim is to allow the user to have multiple browser tabs open at once - and not have the last tab that loaded trample on others. Tokens expire after 1 hour.

Adds a Smarty helper function `{CSRF_Token}` which will output `<input type=hidden name=CSRF_Token value=asdf123>` or `{CSRF_Token type=url}` which outputs a literal string like 'asdf123' suitable for placing in a URL.

Adds a PHP exception handler in public/common.php, which could be used to display a more friendly error message/response (but at the moment is fairly minimal).

Removes most uses of `die()` within the codebase, and instead moves to throw an exception
2026-03-01 19:30:16 +00:00
David Goodwin 52794bede7 misc fixes for psalm after allowing it to be updated 2026-01-28 09:50:26 +00:00
David Goodwin 460c624275 remove more references to sourceforge 2025-07-13 18:29:37 +01:00
David Goodwin 759304ecb8 apparently these all need reformatting 2024-12-05 14:33:41 +00:00
David Goodwin f01274ec94 try relaxing composer dependencies to allow php8.2 dev support, reformat so composer format passes 2024-04-22 21:02:01 +01:00
David Goodwin 0565cde6f3 ensure POST[domains] is not empty 2021-03-02 21:25:49 +00:00
Gianluca Giacometti 79284ddff8 Call to the template fixed
The name ogìf the template is missing the prefix "broadcast-"
2021-01-29 22:24:51 +01:00
David Goodwin f6f62180e8 remove some global variables 2020-09-27 11:02:58 +01:00
Felix Ableitner 600248e955 Add option to use smtp password when sending admin emails (fixes #272) 2019-07-02 13:41:58 +02:00
David Goodwin 803e2342f8 fix psalm issues; reformat; rename new db functions 2019-01-06 21:32:58 +00:00
David Goodwin ea33d9951a try migrating to pdo 2019-01-06 21:32:58 +00:00
David Goodwin 4fcdba9cf4 run php-cs-fixer (code reforamt) 2018-12-28 19:31:43 +00:00
David Goodwin 74002bbf57 psalm fixes 2018-12-27 21:43:11 +00:00
David Goodwin c147eb053b move to use db_assoc() rather than db_array() (code assumes assoc. array) 2018-02-10 21:08:29 +00:00
David Goodwin 2615b6fece see #132 - better broadcast mail format, perhaps 2018-02-08 16:11:57 +00:00
Adrien Crivelli 15df6c1d7b Reformat everything with PHP-Cs-Fixer 2018-01-26 23:54:37 +09:00
David Goodwin 99147d51eb move public facing stuff into public/, this allows us to stop exposing templates_c/ etc to the world 2018-01-25 20:27:09 +00:00