Commit Graph
500 Commits
Author SHA1 Message Date
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
Rodrigo Cortés Cano 8995ee7b55 Support multiple recipient delimiters (#1178)
- treat recipient_delimiter as a set of alternative characters, matching Postfix semantics
- centralize recipient-extension removal so alias status and mailbox classification cannot diverge
- restrict delimiter matching to the local part and document multi-character configuration
- add focused unit and alias-status regression coverage

See #1143
Thanks @TrapoSAMA
2026-10-15 19:26:09 +01:00
Rodrigo Cortés Cano 01747fda26 Revoke stale XML-RPC authorization across web login and MFA (#1173)
Stop someone sharing a session cookie between xmlrpc and normal logins, and using it to avoid TOTP auth. 

thanks @TrapoSAMA
2026-10-13 17:10:21 +01:00
Rodrigo Cortés Cano 59e02ea7f6 Restore SMTP delivery without authentication (#1174)
fix regression in smtp_mail() so only do SMTP AUTH if $CONF['admin_smtp_password'] is a non-empty string

(used by password recovery, broadcast message, mailbox post-creation etc)


Thanks @TrapoSAMA
2026-10-07 19:39:04 +01:00
Christian Boltz 047bf192fb db_where_clause(): fix Exception message
... to mention the correct function name
2026-10-04 18:20:08 +02:00
Rodrigo Cortés Cano ff0ae9ddbe Clarify alias destination status indicators (#1150)
Alias destinations absent from local records previously shared the misleading “maybe UNDELIVERABLE” indicator, including valid external addresses such as Gmail. The indicator now distinguishes “Check local destination” (red) from “External destination” (blue), with short explanatory tooltips. An alias with both kinds of destinations can show
both indicators.


thanks @TrapoSAMA
2026-10-03 11:20:28 +01:00
David Goodwin 2c05ff950c Totp fixes (#1153)
Wenhao Wu emailed with the following security report, this affects master and postfixadmin-4.0.

High — mailbox takeover of mail flow for a 2FA-enrolled account by a password holder. CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N ≈ 8.1 (PR:L models possession of the first factor; impact is limited to the attacker's own mailbox account). CWE-308 (Use of Single-Factor Authentication with Two Factors), secondary CWE-287. Not related to the fixed TOTP-exception issue #1014.

....
With `$CONF['totp']='YES'` and a mailbox that has TOTP enrolled, logging in with **only the mailbox password** creates an MFA-incomplete session (`username` set, `roles=[]`, `mfa_complete=false`) that is parked at `users/login-mfa.php`. That half-session cannot open `users/main.php` (it has no `user` role), but `public/edit.php` never checks MFA completion:

- `public/edit.php:30` — `authentication_get_username()` (comment "enforce login") treats any session with a username as logged in; it never calls `authentication_mfa_incomplete()`.
- `public/edit.php:57-63` — for a non-admin session with a handler that has `user_hardcoded_field`, `require_role('admin')` is skipped entirely.
....

Wenhao Wu, Southeast University

thanks @d3do-23 (@cboltz and TrapoSAMA for reviewing etc)
2026-09-26 09:39:53 +01:00
Rodrigo Cortés Cano cd67f20b4e Enforce SMTP protocol state (#1132)
Improve SMTP connection handling + writing ( smtp_mail() )

Refs #1128

thanks @TrapoSAMA
2026-09-02 20:14:30 +01:00
Rodrigo Cortés Cano 54be5e3828 Fix legacy md5crypt compatibility (#1125)
- restore `md5crypt` as the PostfixAdmin 3.x-compatible alias for MD5-CRYPT
- verify stored unprefixed MD5-CRYPT, prefixed MD5-CRYPT, bcrypt, and SHA512 crypt hashes from their stored format
- document the canonical `MD5-CRYPT` setting, the legacy alias, and the 3.x upgrade implications

This addresses #1123 on `master`. The `postfixadmin_4.0` correction is in #1126 so each maintained branch can be reviewed and tested against its own PHP requirements.

thanks @TrapoSAMA
2026-08-29 15:11:54 +01:00
Rodrigo Cortés Cano 2a6f27c3c4 Use shared pagination in generic lists (#1127)
Extend bootstrap pagination to list.php

#1090, #1093, and this PR cover all three pagination surfaces tracked in #1064.

thanks @TrapoSAMA
2026-08-29 15:09:23 +01:00
Rodrigo Cortés Cano e638095d58 Harden password recovery requests (#1130)
Require a validated canonical site_url for recovery links, keep responses uniform, and persist a five-minute per-account request limit.

The token update is atomic across supported database engines and performs the same password hashing work for unknown accounts.

Refs #1128

thanks @TrapoSAMA
2026-08-29 14:55:49 +01:00
Rodrigo Cortés Cano a9b561506d doveadm: accept valid results with stderr warnings (#1121)
When using dovecot: passwords, and calling the doveadm binary,, ignore stderr as long as the exit code is 0.
Switch _pacrypt_dovecot() to use the Exec class (instead of calling proc_popen directly).

fixes #1119

thanks @TrapoSAMA
2026-08-22 15:07:33 +01:00
Rodrigo Cortés Cano ab0a4d1357 Fix password expiration handling and visibility (#1109)
- validate domain password-expiration policies as whole numbers from 0 through 36500 days
- make password expiration optional and disabled by default
- make 0 consistently mean that passwords in the domain do not expire
- align administrator, recovery, mailbox-user, and XML-RPC password changes
- show each mailbox password-expiration state in lists and CSV output
- add the new labels to every language file
- document how to enable the feature in `config.local.php`

thanks @TrapoSAMA
2026-08-10 09:19:35 +01:00
mkocustos 513542370d Let admins store a default for the alias "To" (goto) field (#1061)
adds new db table admin_preferences to store a default goto for aliases etc, which when populated will prefil the forward form with that value.


thanks @mkocustos
2026-07-25 10:56:40 +01:00
Rodrigo Cortés Cano 755f6c3990 Reconcile 3.3 MySQL upgrades on master (#1089)
fix regression in MySQL database update order. See #971

thanks @TrapoSAMA and @csware
2026-07-23 09:31:31 +01:00
Kent Riboe 0f68dee15c viewlog: per-page selector + Bootstrap 5 pager, fix footer layout (#1062) (#1063)
Improve pagination on viewlog page (make page size configurable, use bootstrap 5 pager) 

Closes #1062. Thanks @knofte
2026-07-05 20:21:19 +01:00
Kent Riboe d6aabd7745 viewlog: add "All domains" option to the log viewer (#1059) (#1060)
Adds an **"All domains"** option to the View Log domain dropdown, so an
admin managing many domains can see log entries across all of them in
one view instead of picking each domain individually.

Closes #1059.

Thanks @knofte
2026-07-01 16:22:21 +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 2cce49a657 Add tests for db_where_clause() and db_delete() with additional params (#1021)
Adds test coverage for the core query-building functions refactored in #1004:
 - db_where_clause()
 - db_delete()
2026-04-22 13:41:47 +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 b4b0f86df0 fix namespace issue (model\Languages etc) 2026-02-28 19:07:00 +00:00
David Goodwin 0ecc961eb3 make psalm happy 2026-01-29 13:46:21 +00:00
David Goodwin 8d67fb4bdd formatting 2026-01-29 13:42:34 +00:00
David Goodwin db1f495f9b main.php: use db_in_clause() instead (thanks @copilot) 2026-01-29 13:41:04 +00:00
David Goodwin a82177c7c0 simplify salt creation (rely on random_bytes() rather than other means) (thanks @copilot) 2026-01-29 13:38:15 +00:00
David Goodwin 8ef6bfe603 php 8.2 does not support array const things 2026-01-28 09:50:26 +00:00
David Goodwin ff0a3d7636 psalm stuff, add Languages class, token refactor 2026-01-28 09:50:26 +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 0c24b067e8 minor code refactoring (login / TotpPf) 2026-01-28 09:50:26 +00:00
David Goodwin 90d407b5fe token renames (a variable called SESSID_USERNAME makes me think it is reserved by PHP or something, which I do not think it actually is, so just user a more meaningful $username 2026-01-28 09:50:26 +00:00
Sven Strickroth da5dc01de3 No need to specify charset in connection string and then set it explicitly using "SET NAMES" again
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2026-01-25 11:20:57 +01:00
David Goodwin 7f1d78e2cd fix issues from merging #958 - no longer provide smtp_password to smtp_mail(..) call, as it does it internally now 2026-01-01 13:40:17 +00:00
David Goodwin 5196a823ba formatting 2026-01-01 13:33:05 +00:00
arymaynart 5d48dd375c Refactor smtp_mail function for improved clarity
Need to do a tweak to work with broadcast messages
2025-12-19 18:26:03 -03:00
arymaynart 42a664e9c2 Refactor smtp_mail for better SMTP support
Refactor smtp_mail function to improve SMTP handling and error logging.
2025-12-19 17:19:48 -03:00
Christian Boltz 4b20d2be2b Fix hardcoded table name mailbox_app_password
... which exploded when using custom table names.
2025-09-11 22:39:57 +02:00
David Goodwin 460c624275 remove more references to sourceforge 2025-07-13 18:29:37 +01:00
David Goodwin 0d5edbf099 move pacol() into PFAHandler class, I think it makes more sense for it to be there given the dependency between the two 2025-07-13 10:12:22 +01:00
David Goodwin 066d6d10a8 bump db min version 2025-07-12 19:28:39 +01:00
David Goodwin ab0f7897fd drop support for legacy 2a bcrypt variants as we do not support PHP before <= 5.3.7 any longer 2025-06-01 15:43:15 +01:00
David Goodwin b56d0082ff token refactoring 2025-06-01 15:42:50 +01:00
David Goodwin ace5624508 change generate_password() to allow for repeated characaters, which probably provides more entropy. 2025-06-01 15:42:09 +01:00
David Goodwin 06a2cda24b this should be a better PFA_Cookie random token value 2025-06-01 15:41:30 +01:00
David Goodwin 293e318200 remove unused/dead code 2025-06-01 15:39:56 +01:00
David Goodwin 65db542ad2 php type hint and phpdoc changes 2025-06-01 15:39:03 +01:00
David Goodwin 999bfcfc54 drop support for mysql_encrypt, given MySQL after 5.7 has dropped it and we had not wired it into the pacrypt() function anyway, try and improve docs in config.inc.php 2025-05-28 09:41:22 +01:00
David Goodwin 798e8b269c Topt app passwords fixes (WIP) (#805)
various improvements to the TOTP code see also:  #802
2025-05-16 20:31:20 +01:00
David Goodwin 759304ecb8 apparently these all need reformatting 2024-12-05 14:33:41 +00:00
David Goodwin c32f344b9d formatting? 2024-05-31 19:27:12 +01:00