Commit Graph
569 Commits
Author SHA1 Message Date
Rodrigo Cortés Cano 3feeb081af Escape security lists and make template escaping opt-outs explicit (#1172)
fixes potential XSS issue with TOTP exception lists (which need escaping, see also #1185). 

refactors Template escaping to use TemplateEscape enum (rather than the previous boolean).

thanks @TrapoSAMA
2026-11-01 10:41:54 +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
Rodrigo Cortés Cano ca76931f06 Allow configurable mailbox user display-name editing (#1177)
add config setting edit_mailbox_name which can be set to allow users to change their name. 

https://github.com/postfixadmin/postfixadmin/issues/1176#issuecomment-6061535053

Thanks @TrapoSAMA & @pvdv
2026-10-15 19:23:51 +01: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
masterblaster79 eea8021889 Fix password changes with database prefixes (#1155)
Users changing their mailbox password currently hit an unprefixed `mailbox` table lookup when `database_prefix` is configured, causing the password change to fail even though authentication succeeds.

Fixes: #1154

thanks @masterblaster79
2026-09-27 19:52:14 +01:00
8ctopus a2d5a5a94d Fix smarty template did not have noindex (#1161)
discourage search engines from indexing postfixadmin 

thanks @8ctopus
2026-09-25 08:55:59 +01:00
Rodrigo Cortés Cano 24c51277c2 Show inactive domain DNS status in overview (#1146)
Show DNS status for domains to administrators.
Adds new config setting domain_dns_status_check ( 0 - disabled, 1 authoritative zone, 2 usable MX ) 

Document installation, an optional CLI/cron command, permissions, networking, timeouts, and saved-result semantics.

thanks @TrapoSAMA
2026-09-19 15:04:21 +01:00
Rodrigo Cortés Cano 2c8a8893e9 Enforce TOTP policy for XML-RPC login (#1131)
if a user/mailbox has TOTP enabled, block access via XMLRPC (if it's enabled) as the two aren't compatible.

Part of #1128.

thanks @TrapoSAMA
2026-08-29 20:07: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
David Goodwin 1b55dc96e4 security updates (smarty, phpunit)
move to use smarty/smarty ^5.8.4 (see https://github.com/postfixadmin/postfixadmin/security/dependabot/2),
use phpunit ^11.5.50
use only psalm 6
2026-08-16 10:28:44 +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
Goodsoldier fe012648b4 Add korean language (#1102)
Add Korean translation - ko.lang, thanks @GoodSoldier
2026-08-05 09:17:07 +01:00
Rodrigo Cortés Cano 8c6057b54b Distinguish mailbox and domain quota validation errors (#1096)
- distinguish the per-mailbox maximum quota error from insufficient remaining domain quota
- add the domain-quota error message to every language catalog

Thanks @TrapoSAMA
2026-08-02 10:15:08 +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 9a930b61ad Add a read-only database integrity check to setup.php (#1091)
attempt to highlight any orphaned data, see also https://github.com/postfixadmin/postfixadmin/issues/972

thanks @TrapoSAMA
2026-07-24 09:09:03 +01:00
Rodrigo Cortés Cano d60ff99e77 Apply user alias ownership check consistently 2026-07-22 18:13:16 +00:00
Rodrigo Cortés Cano 3ab0104d1a Address forwarding editor review feedback 2026-07-22 18:13:16 +00:00
Rodrigo Cortés Cano 8d631d2ce8 Skip internal vacation target validation 2026-07-22 18:13:16 +00:00
Rodrigo Cortés Cano 9a9078ce21 Unify user and admin forwarding editor 2026-07-22 18:13:16 +00:00
David Goodwin 97e17c41c1 allow users to configure a closure (anonymous function) as a *_struct_hook config setting as well
previously we required a named function, see #1069
2026-07-05 20:06:17 +01:00
Rodrigo Cortés Cano 1b3db6bbd3 Improve Spanish labels and domain quota text (#1051)
Changes:

* Improve Spanish translations for mail, DKIM, logs, quota and Backup MX labels.
* Use a shorter domain-list quota label while keeping the full domain quota label in edit forms. 
* Keep hidden domain-list values available in the domain tooltip without reusing form labels.
* Add explicit labels for max mailbox quota and unmanaged quota state.

Thanks @TrapoSAMA
2026-07-03 18:35:16 +01:00
Rodrigo Cortés Cano 43fbf7e56b UI improvements for virtual form labels and search spacing (#1052)
small UI and translation fixes for virtual/admin forms.

Changes:

- Adds PALANG entry for the domain search placeholder.
- Replaces the hardcoded domain search placeholder in edit forms.
- Shows the Domain label when creating aliases and mailboxes.
- Uses Bootstrap 5 form-select for generated select controls.
- Adds minor spacing for the virtual search field.

Thanks @trapoSAMA
2026-07-03 18:33:55 +01:00
Rodrigo Cortés Cano 42fd9870d4 Improve invalid CSRF token response page (#1067)
Improve CSRF invalid error page

- Replaces the raw hardcoded error with localized PALANG text. 
- Provides a simple Continue link back to main.php

Related to the 4.0 branch fix in PR #1055.
2026-07-03 18:31:55 +01:00
Rodrigo Cortés Cano 730ddcb909 Improve virtual list responsiveness and quota tooltip (#1050)
This PR includes two small UI improvements:

* Add horizontal scroll wrappers to virtual mailbox/alias lists so
action buttons and table content do not overflow narrow desktop/tablet
widths.
* Add a domain quota tooltip showing assigned quota and real used quota,
while preserving the existing visible assigned quota text and
usage-based bar color.
  
Tested locally with PHP lint for DomainHandler.php.

thanks @trapoSAMA
2026-06-28 08:49:53 +01:00
David Goodwin ff73976b72 UI enhancements around quota and icons for domain/mailbox lists
various patches from @trapoSama sent via email -

* Keeps the assigned domain quota text and uses real mailbox usage for
the quota bar color and fill.
* Shows a red count next to a domain when one or more mailboxes exceed
the configured quota alert threshold. Requires patch 1.
* Adds optional configuration to hide mailbox quota and password expiry
columns while retaining those values in the domain tooltip.
 * Corrects the quota-bar markup and aligns domain-list columns.
* Replaces the quota bars in the domain overview and mailbox list with a
unified bar component, preventing the fill, label, and border from
separating. It hides Modified, Backup MX, and Transport progressively on
reduced desktop widths, then uses horizontal scrolling as the final
fallback. 
* Uses icon-only controls with translated tooltips in domain and mailbox
lists: active state, SMTP active state, autoresponder, alias, edit, and
delete. Active-state tooltips show the current value, for example
`Activo: SI` or `Activo: NO`.
2026-06-27 16:22:33 +01:00
Justin Warren 2469e045d8 Add 'description' field to alias and alias_domain tables. (#1042)
Adds a `description` field to the `alias` and `alias_domain` tables, so you can add a comment explaining why the alias exists.

Partially addresses #1036

thanks @jpwarren
2026-06-08 09:08:02 +01:00
David Goodwin 8696f300c5 formatting 2026-05-23 15:10:25 +01:00
Kent Riboe 650a91bd05 Improve DKIM: auto-generate keypair, descriptive signing table (#1029)
Implements the improvements suggested by @fredkilbourn in #1024, cleaned up for current master.

**Changes:**

1. **Auto-generate RSA 2048 keypair** when creating a new DKIM key. Only
generates on the create form, not on list views or edits.

2. **Descriptive signing table dropdown** shows `domain:selector
(description) [id]` instead of just the numeric ID.

3. **Domain:Selector and Description columns** in the signing table list
view via LEFT JOIN.

4. **Order by domain:selector** instead of raw dkim_id.

**Technical notes:**
- Uses `$this->new` check to avoid key generation overhead on list/edit
views
- Handles MySQL (`CONCAT()`) vs SQLite/PostgreSQL (`||`) string
concatenation
- Uses named arguments for `pacol()` per current conventions

Two separate commits. Credit to @fredkilbourn for the original patch.
2026-05-23 14:41:13 +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 c6773f8390 Migrate TOTP exceptions to TotpexceptionHandler class (#1007)
refactor code to use the PFAHandler approach, allowing re-use of list.php and edit.php.
2026-04-18 10:22:54 +01:00
Kent Riboe 8e6a4f0f4b Add developer documentation for Handler classes, update PFAHandler::pacol() params (#1008)
Add DOCUMENTS/HANDLER_CLASSES.md which attempts to document how the Handler classes work and help future developers/contributors. 

Changes spec of PFAHandler::pacol() to discourage the 9th parameter (was: multiopt) from being passed as an array (param renamed to not_in_db). Previous behaviour is maintained, but a deprecation error should be triggered.
2026-04-18 10:10:00 +01:00
Kent Riboe 2c0a06f932 Add Exec class to help refactor/reduce duplication of proc_open calls, update phpunit (see note) (#1009)
* code refactoring (adds Exec class to centralise proc_open like calls). 
* bump phpunit to ^11.0, as this is the last release that supports php8.2. Note, there is not (yet?) a phpunit release for php8.2 that fixes PKSA-z3gr-8qht-p93v or PKSA-5jz8-6tcw-pbk4, so ignore them for now in composer.json
2026-04-18 10:05:35 +01:00
Kent Riboe e546e6d593 Fix privilege check ordering for TotpPf::addException (global admin being treated like admin) (#1012)
* Fix privilege check ordering in TotpPf::addException() (#1012)

Global admins were incorrectly downgraded to regular admins because
authentication_has_role('admin') was checked before 'global-admin',
and global admins have both roles. Reorder to check global-admin first.

* Add missing isset() check on $_GET['abort'] in users/login-mfa.php (#1013)

Matches the admin version at public/login-mfa.php which already has
the isset() check.
2026-04-14 21:17:03 +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
Kent Riboe 291609ae6f Add phpstan, MySQL and PostgreSQL test jobs to CI (#1005)
* Add phpstan for static analysis.
* Run unit tests against MySQL and PostgreSQL databases

Thanks @knofte
2026-04-06 09:01:44 +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 7714aa47a3 always show the mailbox header in the list-virtual page, add title to domain aliases 2026-02-28 20:12:57 +00:00
David Goodwin b4b0f86df0 fix namespace issue (model\Languages etc) 2026-02-28 19:07:00 +00:00
David Goodwin cb91ae64f2 formatting 2026-02-28 16:41:45 +00:00
Copilot 3bdc282289 Upgrade to Bootstrap 5.3.0, add lightmode/darkmode switch, drop datepicker js (use html5 datetime-local) (#987)
* Upgrade to Bootstrap 5.3.0 with Bootstrap Icons
* token improvements to setup.php rendering 
* improve backup page rendering
* move to use html5 datetime-local field for vacation from/to rather than the previous js version
* remove datetimepicker js and bootstrap js and jquery (no longer needed)
* vacation: we load any previous dates in from the database, these could include ancient dates, so default them to now and now+1 if they are before today
* drop bootstrap 3.4.1 css
* bootstrap - add light mode / dark mode switch - taken from https://github.com/404GamerNotFound/bootstrap-5.3-dark-mode-light-mode-switch
2026-02-28 10:17:56 +00:00
Fredrik Boström 902739f96d WIP: TOTP reset for lost secrets (#988)
add TOTP reset for lost secrets - see #924
2026-02-28 10:15:07 +00:00
David Goodwin 0ecc961eb3 make psalm happy 2026-01-29 13:46:21 +00:00
David Goodwin ba404a56f7 remove E_USER_ERROR which makes no sense here really 2026-01-29 13:42:17 +00:00
David Goodwin 8d7e797662 apparently sprintf can not return false, so remove these checks (thanks @copilot) 2026-01-29 13:29:30 +00:00
David Goodwin b092017f9b be more explict over what types class properties should be 2026-01-28 09:50:26 +00:00
David Goodwin 2f905d13ee Revert "if templates_c is not writeable fall back to using sys_get_temp_dir() and add a error_log warning"
This reverts commit 5cc95851886d714fd78a3f85bee16243466ec9be.
2026-01-28 09:50:26 +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 19b47d5f17 if templates_c is not writeable fall back to using sys_get_temp_dir() and add a error_log warning 2026-01-28 09:50:26 +00:00