231 Commits
Author SHA1 Message Date
Adam Cooke d96eddbade feat(dkim): make key size configurable and allow keys to be rotated 2026-10-01 12:32:46 +01:00
pplulee ced77a3860 feat: add configurable Postal logger level defaulting to INFO (#3626) 2026-09-13 13:12:57 +01:00
pplulee 3be663dc89 fix: give each worker process a unique locker identity (#3628) 2026-09-13 13:11:42 +01:00
Adam Cooke 11c9814474 fix(http): prevent SSRF in outbound webhook and HTTP endpoint requests
Webhook and HTTP message endpoint deliveries both flow through
Postal::HTTP, which parsed the user-supplied URL and connected to its
host with no address validation. An authenticated user could point a
webhook or endpoint at a private, loopback or link-local address (e.g.
127.0.0.1, 169.254.169.254 cloud metadata, RFC1918 hosts) and make the
server issue requests into its own internal network.

Add Postal::HTTP::AddressGuard, which resolves the destination host and
rejects private/loopback/link-local/reserved/multicast IPv4 and IPv6
addresses, then pins the connection to the validated address so it cannot
be redirected via a DNS-rebinding race. Administrators can permit specific
destinations via the new postal.allowed_request_destinations config option
(hostnames or IP/CIDR ranges).

Address selection only uses families this server can actually reach so we
do not pin to an IPv6 address on a host without IPv6 connectivity; IPv4 is
preferred for predictability. HTTPEndpoint now validates that its URL is a
well-formed HTTP(S) URL with a host.
2026-06-03 15:09:18 +01:00
Adam Cooke 4314a6ec1e fix(message-db): prevent SQL injection via condition keys (GHSA-x2hq-rfpg-3xr5)
The Legacy API message lookup endpoints parsed the request body as JSON and
passed the `id` parameter straight through to the message database. A JSON
object supplied for `id` arrived as a Ruby Hash and was used as a raw set of
SQL `WHERE` conditions. `hash_to_sql` interpolated each Hash key directly
inside backtick identifier quoting while escaping only the value, so a key
containing a backtick could break out of the identifier and inject arbitrary
SQL into the SELECT (blind, time-based) against the message database.

Fixes:

- Escape all identifiers (columns, tables, database names) through a new
  `escape_identifier` helper that wraps in backticks and doubles embedded
  backticks. Applied across hash_to_sql, select, insert, insert_multi,
  update and delete so no caller can inject via an identifier.
- Validate the Legacy API `id` parameter at the controller boundary: reject
  any non-scalar value before it reaches the database and coerce it to an
  integer. Internal Hash-based lookups (e.g. tracking middleware) are
  unaffected.

Adds regression tests at the unit (hash_to_sql / escape_identifier) and
request (legacy messages/deliveries) levels.
2026-06-03 15:06:35 +01:00
Adam Cooke dca7f90b90 refactor(tracking): remove unused src image proxy
The /img/<server>/<message> endpoint accepted a src=<url> query
parameter and proxied the body of that URL back to the caller. Nothing
in the codebase ever produces a src= parameter — the parser only
inserts a plain tracking pixel and rewrites href links — so this branch
is dead code inherited from the original AppMail import.

Drop the src branch: requests with src now return 400. The no-src path
that serves the tracking pixel and records loads is unchanged, and a
spec covers both the pixel-serving path and the removed branch.
2026-04-24 22:24:18 +01:00
Johan Kok e00098b800 fix: update url for v2 config (#3225)
This minor update resolves #3048

Signed-off-by: Johan Kok <johankok@users.noreply.github.com>
2025-10-03 09:40:22 +01:00
Matthieu Barthel 9c5f96ae90 fix: oidc scopes are invalid when concatenated (#3332) 2025-05-08 07:51:46 +01:00
Adam Cooke 4fa88acea0 fix: fix postal version command 2024-06-20 14:27:18 +01:00
Adam Cooke 5a2f31ed77 doc: fix doc for Postal.version 2024-03-21 14:58:11 +00:00
Adam Cooke 07c6b317f2 refactor(versioning): improve how current version and branch is determined and set
Refactor `Postal.version`` and `Postal.branch` and remove `Postal::VERSION`.
2024-03-21 14:55:14 +00:00
Adam Cooke 18236171eb chore(ui): display branch in footer if present 2024-03-20 14:30:32 +00:00
Adam Cooke ea542a0694 feat(worker): scale connection pool with worker threads
This will automatically increase the DB connection pool size if the number of threads needed in a worker is less than the maximum pool size configured.
2024-03-18 08:12:42 +00:00
Adam Cooke 7e2acccd1e feat(worker): allow number of threads to be configured
This allows for more threads to be run. Care needs to be taken to ensure that database connection pool size is appropriate for this.
2024-03-17 18:41:26 +00:00
Adam Cooke 4fcb9e9a2e fix(message-dequeuer): ability to disable batching 2024-03-16 15:31:46 +00:00
Adam Cooke 1c67f72209 chore: hide further config messages 2024-03-13 19:08:59 +00:00
Adam Cooke f760cdb5a1 chore: allow config location message to be suppressed 2024-03-13 19:06:25 +00:00
Adam Cooke 92406129cf fix(smtp-server): fixes proxy protocol 2024-03-13 18:16:08 +00:00
Adam Cooke 58dddebeb8 fix: fixes postal default-dkim-record 2024-03-13 16:54:53 +00:00
Adam Cooke 96d73653d7 feat: add sha256 signatures to outgoing http requests (#2874) 2024-03-13 08:52:29 +00:00
Adam Cooke 5ed94f6f85 feat: openid connect support (#2873) 2024-03-12 17:40:07 +00:00
Adam Cooke d84152eb5d feat: automatically remove queued messages with stale locks (#2872) 2024-03-12 11:37:29 +00:00
Adam Cooke 9399e32234 fix: don't override paths in dockerfile
This allows for these paths to continue to be set in the config file or environment variable while still maintaining the default of having the default paths in the same directory as the postal config file.
2024-03-08 16:40:58 +00:00
Adam Cooke d1e5b68200 fix(smtp-server): listen on all interfaces by default
This is the same behaviour as when using v1 configuration. Unlike the
web server which is proxied, most people are going to need this so having
the default remain seems like the easiest path for upgrades.

see #2852
2024-03-06 13:23:50 +00:00
Adam Cooke 3785c99851 feat: configurable trusted proxies for web requests 2024-03-05 22:54:19 +00:00
Adam Cooke 2c20ba65f6 style(rubocop): use _ when not using a variable in helm config exporter 2024-03-05 22:13:38 +00:00
Adam Cooke 48f6494240 fix: default to listening on all addresses when using legacy config 2024-03-05 19:34:23 +00:00
Adam Cooke 90d3a3f8c9 refactor: be less verbose with message DB migrations 2024-03-04 21:03:15 +00:00
Adam Cooke b35eea6338 feat: add "postal:update" task
this will load the schema if no schema exists or update it if it does
2024-03-04 21:01:31 +00:00
Adam Cooke 893898835d feat: add helm env var config exporter 2024-03-04 20:58:38 +00:00
Adam Cooke ce30c070bd refactor: switch to use SecureRandom for random strings 2024-03-04 17:33:25 +00:00
Adam Cooke 1da1182c23 fix: unescape in URLs which are stored for tracking
closes #2568
closes #907
closes #115
2024-03-04 16:52:36 +00:00
Adam Cooke 658aa71483 fix: remove support for setting the 'ssl' option for app-level smtp use 2024-03-04 15:54:54 +00:00
Adam Cooke 0daa667b55 feat: support for additional SMTP client options 2024-03-04 14:24:24 +00:00
Adam Cooke 2359829e22 Merge pull request #2803 from postalserver/v3
Postal v3
2024-03-04 10:28:51 +00:00
Adam Cooke fadca88f45 fix: raise an error if MX lookup times out during sending
This avoids potentially sending mail to the A record when an MX query times out.

closes #2833
2024-03-01 21:36:07 +00:00
Adam Cooke 694240ddcd fix: truncate output and details in deliveries to 250 characters
closes #2831
2024-03-01 13:14:48 +00:00
Adam Cooke ae30cc7615 fix: ensure encoding is set for message db 2024-02-27 19:04:40 +00:00
Adam Cooke 0163ac3d10 feat: new configuration system (and schema) (#2819) 2024-02-26 12:41:57 +00:00
Adam Cooke 1c5ff5a9a6 feat: add option to delay starting processes until all migrations are run 2024-02-24 15:10:02 +00:00
Adam Cooke 38465de120 refactor: remove unnecessary modules 2024-02-23 22:51:37 +00:00
Adam Cooke b8ad732152 refactor: move tracking middleware 2024-02-23 22:51:37 +00:00
Adam Cooke 64b2704b02 refactor: move lib/postal/user_creator to app/util/user_creator 2024-02-23 22:51:37 +00:00
Adam Cooke e3bc9da253 refactor: move lib/postal/received_header to app/lib/received_header 2024-02-23 22:51:36 +00:00
Adam Cooke 5cc9eb3df7 refactor: move lib/postal/reply_separator to app/lib/reply_separator 2024-02-23 22:51:36 +00:00
Adam Cooke 321ab95936 refactor: move lib/postal/smtp_server to app/lib/smtp_server 2024-02-23 22:51:36 +00:00
Adam Cooke 73a55a5053 refactor: move senders in to app/senders/ 2024-02-23 22:51:36 +00:00
Adam Cooke 93fc120f44 refactor: move worker from lib/worker to app/lib/worker 2024-02-23 22:51:36 +00:00
Adam Cooke a44e1f9081 refactor: refactors message dequeueing (#2810) 2024-02-23 22:51:36 +00:00
Adam Cooke 870b26c2f2 refactor: move Postal::QueryString to app/util/query_string 2024-02-23 22:51:35 +00:00