domma-cms 1.8.15 → 1.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/CLAUDE.md +6 -0
- package/admin/css/admin.css +1 -1
- package/admin/js/lib/block-tags.js +1 -0
- package/admin/js/lib/editor-hop-arrange.js +1 -0
- package/admin/js/lib/editor-hop.js +19 -0
- package/admin/js/lib/shortcode-context-menu.js +2 -2
- package/admin/js/lib/shortcode-form.js +3 -3
- package/admin/js/lib/shortcode-tags.js +1 -1
- package/admin/js/templates/block-editor.html +2 -5
- package/admin/js/templates/page-editor.html +5 -7
- package/admin/js/views/block-editor.js +5 -5
- package/admin/js/views/page-editor.js +8 -8
- package/docs/markdown-shortcodes.md +17 -0
- package/package.json +1 -1
- package/plugins/_lib/mail/hostGuard.js +96 -12
- package/plugins/_lib/mail/imapPool.js +26 -4
- package/plugins/_lib/mail/poller.js +2 -1
- package/plugins/_lib/mail/readRoutes.js +4 -4
- package/plugins/_lib/mail/scheduler.js +7 -4
- package/plugins/_lib/mail/send.js +67 -18
- package/plugins/free-tier.lock.json +6 -5
- package/plugins/security/CLAUDE.md +9 -1
- package/plugins/security/plugin.json +2 -2
- package/plugins/security/server/facts.js +105 -29
- package/plugins/security/tests/facts.test.js +109 -0
- package/server/routes/api/blocks.js +57 -2
- package/server/routes/api/forms.js +4 -2
- package/server/routes/api/settings.js +22 -6
- package/server/services/email.js +98 -8
- package/server/services/mailHost.js +100 -0
- package/server/services/notification-sources.js +2 -1
|
@@ -11,14 +11,22 @@
|
|
|
11
11
|
* the admin chose) or `allowPrivateMailHosts` is set for a site whose mail
|
|
12
12
|
* server really is on its LAN.
|
|
13
13
|
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
14
|
+
* The address rules are core's (services/outbound.js `isBlockedAddress`, and
|
|
15
|
+
* services/mailHost.js on a signed-only site, where nothing above lifts them);
|
|
16
|
+
* `isLocalName` is unsubscribe.js's. Checking a name and then connecting by
|
|
17
|
+
* name lets a second DNS answer point the connection inward, so the
|
|
18
|
+
* connections themselves (imapPool.js, send.js) go through `pinMailHost()`:
|
|
19
|
+
* checked again, and connected to the address that was checked.
|
|
16
20
|
*
|
|
17
21
|
* @module _lib/mail/hostGuard
|
|
18
22
|
*/
|
|
19
23
|
import dns from 'node:dns/promises';
|
|
20
24
|
import net from 'node:net';
|
|
21
|
-
import {
|
|
25
|
+
import {getConfig} from '../../../server/config.js';
|
|
26
|
+
import {isBlockedAddress} from '../../../server/services/outbound.js';
|
|
27
|
+
import {MailHostRefused, normaliseMailHost, resolveMailHost} from '../../../server/services/mailHost.js';
|
|
28
|
+
import {signedOnly} from '../../../server/services/codePolicy.js';
|
|
29
|
+
import {isLocalName} from './unsubscribe.js';
|
|
22
30
|
|
|
23
31
|
const REFUSED = 'That server is on this machine\'s own network, so the site will not connect to it. '
|
|
24
32
|
+ 'Use the mail server\'s public name, or ask the site administrator to allow private mail hosts.';
|
|
@@ -30,33 +38,58 @@ const REFUSED = 'That server is on this machine\'s own network, so the site will
|
|
|
30
38
|
* @returns {string}
|
|
31
39
|
*/
|
|
32
40
|
export function normaliseHost(host) {
|
|
33
|
-
return
|
|
41
|
+
return normaliseMailHost(host);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Does `allowPrivate` / `ownSmtpHost` let this (self-hosted) site reach the name anywhere? */
|
|
45
|
+
function exempt(name, {allowPrivate, ownSmtpHost}) {
|
|
46
|
+
return allowPrivate === true || (!!ownSmtpHost && normaliseHost(ownSmtpHost) === name);
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
/**
|
|
37
|
-
* Check one host.
|
|
50
|
+
* Check one host (the save and "test these details" routes).
|
|
51
|
+
*
|
|
52
|
+
* On a signed-only (hosted) site the rules are core's services/mailHost.js and
|
|
53
|
+
* nothing the site's admin sets lifts them: loopback names or public servers,
|
|
54
|
+
* on the mail ports when `port` is given. `allowPrivate` and `ownSmtpHost`
|
|
55
|
+
* count on self-hosted sites only.
|
|
56
|
+
*
|
|
57
|
+
* Passing is not the end of it: every connection checks again and connects to
|
|
58
|
+
* the address it checked (`pinMailHost`), so a name that resolves differently
|
|
59
|
+
* later (DNS rebinding) is caught there.
|
|
38
60
|
*
|
|
39
61
|
* @param {string} host
|
|
40
62
|
* @param {object} [options]
|
|
41
63
|
* @param {boolean} [options.allowPrivate] - the site's `allowPrivateMailHosts` setting
|
|
42
64
|
* @param {string} [options.ownSmtpHost] - the site's configured outgoing server; always allowed
|
|
43
|
-
* @param {
|
|
65
|
+
* @param {number} [options.port] - checked against the mail ports on a signed-only site
|
|
66
|
+
* @param {'smtp'|'imap'} [options.kind] - which mail ports
|
|
67
|
+
* @param {boolean} [options.signed] - codePolicy.signedOnly() when omitted
|
|
68
|
+
* @param {Function} [options.lookup] - DNS, injectable
|
|
44
69
|
* @returns {Promise<{ok: true} | {ok: false, error: string}>}
|
|
45
70
|
*/
|
|
46
|
-
export async function checkMailHost(host, {allowPrivate = false, ownSmtpHost = '', lookup} = {}) {
|
|
71
|
+
export async function checkMailHost(host, {allowPrivate = false, ownSmtpHost = '', lookup, port, kind = 'imap', signed} = {}) {
|
|
47
72
|
const name = normaliseHost(host);
|
|
48
73
|
if (!name) return {ok: false, error: 'A server is required.'};
|
|
49
|
-
if (
|
|
50
|
-
|
|
74
|
+
if (signed ?? signedOnly()) {
|
|
75
|
+
try {
|
|
76
|
+
await resolveMailHost(name, port, {kind, signed: true, anyPort: port === undefined, ...(lookup && {lookup})});
|
|
77
|
+
return {ok: true};
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err.mailHostRefused) return {ok: false, error: err.message};
|
|
80
|
+
return {ok: true}; // unresolvable: the connection attempt says so
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (exempt(name, {allowPrivate, ownSmtpHost})) return {ok: true};
|
|
51
84
|
|
|
52
85
|
if (net.isIP(name)) {
|
|
53
|
-
return
|
|
86
|
+
return isBlockedAddress(name) ? {ok: false, error: REFUSED} : {ok: true};
|
|
54
87
|
}
|
|
55
88
|
if (isLocalName(name)) return {ok: false, error: REFUSED};
|
|
56
89
|
|
|
57
90
|
let answers;
|
|
58
91
|
try {
|
|
59
|
-
answers = await (lookup ?? ((h) => dns.lookup(h, {all: true})))(name);
|
|
92
|
+
answers = await (lookup ?? ((h) => dns.lookup(h, {all: true, verbatim: true})))(name, {all: true, verbatim: true});
|
|
60
93
|
} catch {
|
|
61
94
|
// Unresolvable: let the connection attempt say so in its own words.
|
|
62
95
|
// The check is about where a name points, not whether it exists.
|
|
@@ -65,10 +98,61 @@ export async function checkMailHost(host, {allowPrivate = false, ownSmtpHost = '
|
|
|
65
98
|
// Every answer must be public: a name with one private A record among
|
|
66
99
|
// public ones is exactly the rebinding trick the check exists for.
|
|
67
100
|
const addresses = (answers ?? []).map(a => (typeof a === 'string' ? a : a?.address)).filter(Boolean);
|
|
68
|
-
if (addresses.some(
|
|
101
|
+
if (addresses.some(isBlockedAddress)) return {ok: false, error: REFUSED};
|
|
69
102
|
return {ok: true};
|
|
70
103
|
}
|
|
71
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Is `allowPrivateMailHosts` on for a mail plugin on this site? Read from
|
|
107
|
+
* config/plugins.json for the connections made without a plugin's config in
|
|
108
|
+
* hand (email-pro's SMTP test). Never consulted on a signed-only site.
|
|
109
|
+
*
|
|
110
|
+
* @returns {boolean}
|
|
111
|
+
*/
|
|
112
|
+
export function pluginsAllowPrivate() {
|
|
113
|
+
try {
|
|
114
|
+
const plugins = getConfig('plugins') || {};
|
|
115
|
+
return ['mail-reader', 'email-pro'].some(n => plugins[n]?.settings?.allowPrivateMailHosts === true);
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Check a host at the moment of connecting, and say which address to connect
|
|
123
|
+
* to - the address that was checked, so a second DNS answer cannot swap an
|
|
124
|
+
* internal one in (DNS rebinding). The name is returned as `servername` for
|
|
125
|
+
* TLS (SNI and the certificate check).
|
|
126
|
+
*
|
|
127
|
+
* @param {string} host
|
|
128
|
+
* @param {number} port
|
|
129
|
+
* @param {object} [options]
|
|
130
|
+
* @param {'smtp'|'imap'} [options.kind='imap']
|
|
131
|
+
* @param {boolean} [options.allowPrivate] - pluginsAllowPrivate() when omitted
|
|
132
|
+
* @param {string} [options.ownSmtpHost] - siteSmtpHost(getConfig) when omitted
|
|
133
|
+
* @param {boolean} [options.signed]
|
|
134
|
+
* @param {Function} [options.lookup]
|
|
135
|
+
* @returns {Promise<{address: string, family: number, servername: string|undefined}>}
|
|
136
|
+
* @throws {Error} MailHostRefused (`mailHostRefused`), or code ENOTFOUND
|
|
137
|
+
*/
|
|
138
|
+
export async function pinMailHost(host, port, {kind = 'imap', allowPrivate, ownSmtpHost, signed, lookup} = {}) {
|
|
139
|
+
const name = normaliseHost(host);
|
|
140
|
+
const isSigned = signed ?? signedOnly();
|
|
141
|
+
const opts = {kind, signed: isSigned, ...(lookup && {lookup})};
|
|
142
|
+
if (isSigned) return resolveMailHost(name, port, opts);
|
|
143
|
+
const free = exempt(name, {
|
|
144
|
+
allowPrivate: allowPrivate ?? pluginsAllowPrivate(),
|
|
145
|
+
ownSmtpHost: ownSmtpHost ?? siteSmtpHost(getConfig)
|
|
146
|
+
});
|
|
147
|
+
if (!free && !net.isIP(name) && isLocalName(name)) throw new MailHostRefused(REFUSED);
|
|
148
|
+
try {
|
|
149
|
+
return await resolveMailHost(name, port, {...opts, checkAddresses: !free});
|
|
150
|
+
} catch (err) {
|
|
151
|
+
if (err.mailHostRefused) throw new MailHostRefused(REFUSED);
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
72
156
|
/**
|
|
73
157
|
* The site's own outgoing server, from config/site.json `smtp.host` (what
|
|
74
158
|
* core `createTransport` sends with), read through a getter so a test can
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* @module mail-reader/services/imapPool
|
|
28
28
|
*/
|
|
29
29
|
import {ImapFlow} from 'imapflow';
|
|
30
|
+
import {pinMailHost} from './hostGuard.js';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Identify a connection's target. A change to any of these means the cached
|
|
@@ -98,8 +99,16 @@ export function createPool(config) {
|
|
|
98
99
|
auth = {user: auth.user, accessToken: r.accessToken};
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
// Checked here, at every connect, and connected to the checked address
|
|
103
|
+
// (the name kept for TLS) - see hostGuard.js pinMailHost.
|
|
104
|
+
const pinned = await pinMailHost(connection.host, connection.port, {kind: 'imap', allowPrivate: config.allowPrivateMailHosts === true});
|
|
105
|
+
|
|
101
106
|
const attempt = async (withAuth) => {
|
|
102
|
-
const client = new ImapFlow(
|
|
107
|
+
const client = new ImapFlow({
|
|
108
|
+
...clientOptions({...connection, auth: withAuth}),
|
|
109
|
+
host: pinned.address,
|
|
110
|
+
...(pinned.servername && {servername: pinned.servername})
|
|
111
|
+
});
|
|
103
112
|
prepare(client);
|
|
104
113
|
try {
|
|
105
114
|
await client.connect();
|
|
@@ -300,7 +309,10 @@ export function createPool(config) {
|
|
|
300
309
|
// Never hold the process open on account of an idle mail connection.
|
|
301
310
|
reaper.unref?.();
|
|
302
311
|
|
|
303
|
-
return {withClient, withMailbox, test, release, releaseUser, closeAll, connectClient,
|
|
312
|
+
return {withClient, withMailbox, test, release, releaseUser, closeAll, connectClient,
|
|
313
|
+
// What send.js passes to hostGuard.js pinMailHost for this plugin's outgoing servers.
|
|
314
|
+
mailHostOptions: {allowPrivate: config.allowPrivateMailHosts === true},
|
|
315
|
+
get size() {
|
|
304
316
|
return pool.size;
|
|
305
317
|
}};
|
|
306
318
|
}
|
|
@@ -321,7 +333,7 @@ export function createPool(config) {
|
|
|
321
333
|
*/
|
|
322
334
|
export function describeError(err, connection = {}) {
|
|
323
335
|
if (!err) return 'Unknown error.';
|
|
324
|
-
if (err.needsReconnect) return err.message;
|
|
336
|
+
if (err.needsReconnect || err.mailHostRefused) return err.message;
|
|
325
337
|
// A signed-in (OAuth2) mailbox has no password to blame.
|
|
326
338
|
if ((err.authenticationFailed || err.code === 'EAUTH' || err.code === 'EOAUTH2') && (connection.auth?.accessToken !== undefined || connection.auth?.type === 'OAuth2')) {
|
|
327
339
|
return 'The mail server refused the sign-in. If it keeps happening, Reconnect the mailbox.';
|
|
@@ -366,6 +378,16 @@ export function describeError(err, connection = {}) {
|
|
|
366
378
|
case 'ECONNRESET':
|
|
367
379
|
return 'The mail server did not respond in time.';
|
|
368
380
|
default:
|
|
369
|
-
|
|
381
|
+
// Words that are ours, or a mail server's answer to a command after
|
|
382
|
+
// it greeted and (for IMAP) signed us in - those say nothing about
|
|
383
|
+
// what else listens on a host and port.
|
|
384
|
+
if (err.name === 'MailKeyError' || err.responseStatus === 'NO' || err.responseStatus === 'BAD'
|
|
385
|
+
|| err.code === 'EENVELOPE' || err.code === 'EMESSAGE') {
|
|
386
|
+
return err.message || 'The mail server connection failed.';
|
|
387
|
+
}
|
|
388
|
+
// Anything else stays out of the browser: a greeting, a banner or a
|
|
389
|
+
// socket error is exactly what a port scan reads. The log has it.
|
|
390
|
+
console.warn(`[mail] connection to ${connection.host || 'the mail server'}:${connection.port || '?'} failed${err.code ? ` (${err.code})` : ''}: ${err.message || err}`);
|
|
391
|
+
return 'The mail server connection failed. Check the server settings.';
|
|
370
392
|
}
|
|
371
393
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @module _lib/mail/poller
|
|
14
14
|
*/
|
|
15
15
|
import {selectDuePolls} from './pollSchedule.js';
|
|
16
|
+
import {describeError} from './imapPool.js';
|
|
16
17
|
|
|
17
18
|
/** How often the ticker looks for work. Finer than any poll interval. */
|
|
18
19
|
const TICK_MS = 30_000;
|
|
@@ -49,7 +50,7 @@ export function createPoller({listAccounts, syncAccount, defaultMinutes, logger,
|
|
|
49
50
|
} catch (err) {
|
|
50
51
|
const failures = (entry.failures ?? 0) + 1;
|
|
51
52
|
state.set(account.id, {
|
|
52
|
-
lastAttemptAt: Date.now(), failures, running: false, lastError: err
|
|
53
|
+
lastAttemptAt: Date.now(), failures, running: false, lastError: describeError(err)
|
|
53
54
|
});
|
|
54
55
|
// Warn, not error: a mail server being unreachable is an ordinary
|
|
55
56
|
// condition, and the backoff already handles it.
|
|
@@ -240,7 +240,7 @@ export function registerReadRoutes(fastify, {auth, hooks, config, pool, pluginNa
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/** Where this server may be asked to connect - see hostGuard.js. */
|
|
243
|
-
const guardHost = (host) => checkMailHost(host, {allowPrivate: config.allowPrivateMailHosts === true, ownSmtpHost: siteSmtpHost(getConfig)});
|
|
243
|
+
const guardHost = (host, port) => checkMailHost(host, {allowPrivate: config.allowPrivateMailHosts === true, ownSmtpHost: siteSmtpHost(getConfig), port, kind: 'imap'});
|
|
244
244
|
// Each test is a connection attempt whose answer says what is listening: a few a minute per address is plenty.
|
|
245
245
|
const testLimit = {config: {rateLimit: {max: 10, timeWindow: '1 minute'}}};
|
|
246
246
|
|
|
@@ -258,7 +258,7 @@ export function registerReadRoutes(fastify, {auth, hooks, config, pool, pluginNa
|
|
|
258
258
|
|
|
259
259
|
const result = accounts.validate(request.body ?? {}, null);
|
|
260
260
|
if (!result.ok) return reply.code(400).send({error: result.error});
|
|
261
|
-
const where = await guardHost(result.value.host);
|
|
261
|
+
const where = await guardHost(result.value.host, result.value.port);
|
|
262
262
|
if (!where.ok) return reply.code(400).send({error: where.error});
|
|
263
263
|
|
|
264
264
|
const saved = await accounts.saveAccount(uid, null, result.value);
|
|
@@ -277,7 +277,7 @@ export function registerReadRoutes(fastify, {auth, hooks, config, pool, pluginNa
|
|
|
277
277
|
const result = accounts.validate(request.body ?? {}, existing);
|
|
278
278
|
if (!result.ok) return reply.code(400).send({error: result.error});
|
|
279
279
|
// A signed-in mailbox's servers are the provider's and cannot be edited here.
|
|
280
|
-
const where = result.value.oauth ? {ok: true} : await guardHost(result.value.host);
|
|
280
|
+
const where = result.value.oauth ? {ok: true} : await guardHost(result.value.host, result.value.port);
|
|
281
281
|
if (!where.ok) return reply.code(400).send({error: where.error});
|
|
282
282
|
|
|
283
283
|
const saved = await accounts.saveAccount(uid, request.params.id, result.value);
|
|
@@ -343,7 +343,7 @@ export function registerReadRoutes(fastify, {auth, hooks, config, pool, pluginNa
|
|
|
343
343
|
throw err;
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
|
-
const where = await guardHost(result.value.host);
|
|
346
|
+
const where = await guardHost(result.value.host, result.value.port);
|
|
347
347
|
if (!where.ok) return reply.code(400).send({error: where.error});
|
|
348
348
|
|
|
349
349
|
let pass = result.value.password;
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import * as accounts from './accounts.js';
|
|
26
26
|
import {sendMessage} from './send.js';
|
|
27
|
+
import {describeError} from './imapPool.js';
|
|
27
28
|
|
|
28
29
|
/** How often the ticker looks for work. */
|
|
29
30
|
const TICK_MS = 5_000;
|
|
@@ -118,11 +119,13 @@ export function createScheduler({store, pool, config, logger, tickMs = TICK_MS})
|
|
|
118
119
|
// the sender is told (the send-failed notice) instead of waiting.
|
|
119
120
|
const giveUp = err?.needsReconnect || (item.attempts ?? 1) >= MAX_ATTEMPTS;
|
|
120
121
|
await store.finishSend(item._id, giveUp
|
|
121
|
-
|
|
122
|
+
// describeError: a queue item is read in the browser, and the mail
|
|
123
|
+
// server's own words are for the log (they say what listens on a port).
|
|
124
|
+
? {status: 'failed', error: err?.needsReconnect ? reconnectReason(err) : describeError(err)}
|
|
122
125
|
// Back to pending, a little later. `finishedAt` is set either
|
|
123
126
|
// way, which is harmless on a retry and is what tells a
|
|
124
127
|
// screen when the last attempt was.
|
|
125
|
-
: {status: 'pending', at: new Date(Date.now() + RETRY_MS), error: err
|
|
128
|
+
: {status: 'pending', at: new Date(Date.now() + RETRY_MS), error: describeError(err)});
|
|
126
129
|
|
|
127
130
|
logger.warn(
|
|
128
131
|
`[mail] queued send ${item._id} failed (attempt ${item.attempts}): ${err.message}`
|
|
@@ -186,8 +189,8 @@ export function createScheduler({store, pool, config, logger, tickMs = TICK_MS})
|
|
|
186
189
|
const attempts = (item.attempts ?? 0) + 1;
|
|
187
190
|
const giveUp = err?.needsReconnect || attempts >= MAX_ATTEMPTS;
|
|
188
191
|
await store.finishSnooze(item._id, giveUp
|
|
189
|
-
? {status: 'failed', error: err?.needsReconnect ? `${reconnectReason(err)} The message is still in ${item.folder}.` : err
|
|
190
|
-
: {status: 'pending', at: new Date(Date.now() + RETRY_MS), error: err
|
|
192
|
+
? {status: 'failed', error: err?.needsReconnect ? `${reconnectReason(err)} The message is still in ${item.folder}.` : describeError(err), attempts}
|
|
193
|
+
: {status: 'pending', at: new Date(Date.now() + RETRY_MS), error: describeError(err), attempts});
|
|
191
194
|
logger.warn(
|
|
192
195
|
`[mail] could not wake snoozed message ${item._id} (attempt ${attempts}): ${err.message}`
|
|
193
196
|
);
|
|
@@ -14,6 +14,7 @@ import nodemailer from 'nodemailer';
|
|
|
14
14
|
|
|
15
15
|
import {bareAddress, formatFrom} from '../admin/mail/identity.js';
|
|
16
16
|
import {describeError} from './imapPool.js';
|
|
17
|
+
import {pinMailHost} from './hostGuard.js';
|
|
17
18
|
import {normalisePriority, priorityHeaders} from './priority.js';
|
|
18
19
|
import {normaliseMessageSource, recordMessageAction, SOURCE_HEADER} from './message-action.js';
|
|
19
20
|
|
|
@@ -213,22 +214,31 @@ export async function sendMessage({
|
|
|
213
214
|
// running its own mail server with a self-signed certificate has the same
|
|
214
215
|
// problem in both directions, and two switches for one decision is how
|
|
215
216
|
// one of them ends up wrong.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
217
|
+
// The mail server's own words never leave as the error (they say what
|
|
218
|
+
// listens on a port): describeError's plain text, the detail in the log.
|
|
219
|
+
let transport;
|
|
220
|
+
let info;
|
|
221
|
+
try {
|
|
222
|
+
transport = nodemailer.createTransport({
|
|
223
|
+
...await pinnedTransport(smtp.transport, pool?.mailHostOptions),
|
|
224
|
+
tls: {rejectUnauthorized: !allowInsecureTLS}
|
|
225
|
+
});
|
|
226
|
+
info = await transport.sendMail({
|
|
227
|
+
envelope: {
|
|
228
|
+
// Bare, always. A display name here is not decoration the server
|
|
229
|
+
// ignores - it is a MAIL FROM the server rejects, and `smtp.from`
|
|
230
|
+
// is a free-text field somebody may well have typed a name into.
|
|
231
|
+
from: bareAddress(smtp.from),
|
|
232
|
+
to: [...addresses(draft.to), ...addresses(draft.cc), ...addresses(draft.bcc)]
|
|
233
|
+
.map(a => a.address)
|
|
234
|
+
},
|
|
235
|
+
raw
|
|
236
|
+
});
|
|
237
|
+
} catch (err) {
|
|
238
|
+
throw plainSendError(err, smtp.transport);
|
|
239
|
+
} finally {
|
|
240
|
+
transport?.close();
|
|
241
|
+
}
|
|
232
242
|
|
|
233
243
|
const messageAction = await recordMessageAction({
|
|
234
244
|
source: draft.sourceMessage, account, pool, poolKey, connection, store
|
|
@@ -383,15 +393,54 @@ async function findSentFolder(pool, poolKey, connection) {
|
|
|
383
393
|
return findSpecialFolder(pool, poolKey, connection, '\\Sent');
|
|
384
394
|
}
|
|
385
395
|
|
|
396
|
+
/**
|
|
397
|
+
* A send failure as plain words. Our own errors (a refused host, a mailbox that
|
|
398
|
+
* needs signing in again) pass as they are; anything from the server or the
|
|
399
|
+
* library becomes describeError()'s text, keeping `code` so a caller can still
|
|
400
|
+
* tell an authentication failure from the rest.
|
|
401
|
+
*
|
|
402
|
+
* @param {Error} err
|
|
403
|
+
* @param {object} transportConfig
|
|
404
|
+
* @returns {Error}
|
|
405
|
+
*/
|
|
406
|
+
export function plainSendError(err, transportConfig = {}) {
|
|
407
|
+
if (!err || err.needsReconnect || err.mailHostRefused || err.name === 'MailKeyError') return err;
|
|
408
|
+
const plain = new Error(describeError(err, transportConfig));
|
|
409
|
+
if (err.code) plain.code = err.code;
|
|
410
|
+
if (err.responseCode) plain.responseCode = err.responseCode;
|
|
411
|
+
return plain;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A mailbox's transport settings with the host checked and pinned: connect to
|
|
416
|
+
* the address hostGuard.js checked, keep the name for TLS. Throws when the
|
|
417
|
+
* host or port is refused, or the name does not resolve.
|
|
418
|
+
*
|
|
419
|
+
* @param {object} transportConfig - {host, port, ...}
|
|
420
|
+
* @param {{allowPrivate?: boolean}} [guard] - the plugin's allowPrivateMailHosts, when the caller has it
|
|
421
|
+
* @returns {Promise<object>}
|
|
422
|
+
*/
|
|
423
|
+
export async function pinnedTransport(transportConfig, guard = {}) {
|
|
424
|
+
const port = Number(transportConfig.port) || (transportConfig.secure ? 465 : 587);
|
|
425
|
+
const {address, servername} = await pinMailHost(transportConfig.host, port, {kind: 'smtp', ...(guard || {})});
|
|
426
|
+
return {...transportConfig, port, host: address, ...(servername && {servername})};
|
|
427
|
+
}
|
|
428
|
+
|
|
386
429
|
/**
|
|
387
430
|
* Try the outgoing server without sending anything.
|
|
388
431
|
*
|
|
389
432
|
* @param {object} transportConfig
|
|
390
433
|
* @returns {Promise<{ok: boolean, error?: string}>}
|
|
391
434
|
*/
|
|
392
|
-
export async function verifySmtp(transportConfig, allowInsecureTLS = false) {
|
|
435
|
+
export async function verifySmtp(transportConfig, allowInsecureTLS = false, guard = undefined) {
|
|
436
|
+
let pinned;
|
|
437
|
+
try {
|
|
438
|
+
pinned = await pinnedTransport(transportConfig, guard);
|
|
439
|
+
} catch (err) {
|
|
440
|
+
return {ok: false, error: describeError(err, transportConfig)};
|
|
441
|
+
}
|
|
393
442
|
const transport = nodemailer.createTransport({
|
|
394
|
-
...
|
|
443
|
+
...pinned,
|
|
395
444
|
connectionTimeout: 10_000,
|
|
396
445
|
tls: {rejectUnauthorized: !allowInsecureTLS}
|
|
397
446
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
|
|
3
|
-
"source": "dcms-marketplace@
|
|
3
|
+
"source": "dcms-marketplace@af8baa8",
|
|
4
4
|
"plugins": {
|
|
5
5
|
"blog": {
|
|
6
6
|
"version": "1.10.1",
|
|
@@ -165,9 +165,9 @@
|
|
|
165
165
|
}
|
|
166
166
|
},
|
|
167
167
|
"security": {
|
|
168
|
-
"version": "1.2.
|
|
168
|
+
"version": "1.2.1",
|
|
169
169
|
"files": {
|
|
170
|
-
"CLAUDE.md": "
|
|
170
|
+
"CLAUDE.md": "1aabef04e77d9bd10ead195851a75c358b5c6657a57ad217495cf7b5b0d63538",
|
|
171
171
|
"admin/lib/blocks.js": "5ef346b7de751518f8beb9212e3b89b270ae236560ae3d8a1f40d129c50918ff",
|
|
172
172
|
"admin/lib/health.js": "3b233a3d29b2d69c333321602c13233b8221cfe1114aa03903739d9ae8ad65d5",
|
|
173
173
|
"admin/lib/ip.js": "cf33be4fa2e2cad37bafd12ebec17f293891a88de402caad1bf9c9a57ce87680",
|
|
@@ -183,11 +183,12 @@
|
|
|
183
183
|
"config.js": "e6a00f7816637687d6a68ebbac65a71489246a926c28523c2a78d859e75b7ae0",
|
|
184
184
|
"docs/guide.md": "a27d5303f9146057fd79c2093d7476ada1a5ee4fd14d34df7f94ad8555d88ca0",
|
|
185
185
|
"plugin.js": "9d3a2e8b56dd637407c8abd93252dda9f67042231bc79d35771f766a62022c14",
|
|
186
|
-
"plugin.json": "
|
|
186
|
+
"plugin.json": "c7ebf55a71048e914ca8e6d2f042fb099123367e1e6fd694cfbf9eb2e4146852",
|
|
187
187
|
"server/common-passwords.NOTICE": "3b148a49a569bfa24feaa7879db602da8f0607fa61ab6c52b7a62391fc7c009a",
|
|
188
188
|
"server/common-passwords.txt": "68782d6a4a19a4768d5f15dd66bd534e7a33055cc755411e33f16d18c50fdcce",
|
|
189
|
-
"server/facts.js": "
|
|
189
|
+
"server/facts.js": "8dbf6802acd9103fe4ca8d5e7d2dfc97c169df6d47bea72b33411cd22fee597b",
|
|
190
190
|
"server/state.js": "1319b322e94a4aec176948990b2d674b28dfece761eef4d5685df474037bfc4a",
|
|
191
|
+
"tests/facts.test.js": "dc59d307033c7a9887b4d522bccd9e9d4986b6ed5cb4ffe1287282a93f54cb11",
|
|
191
192
|
"tests/screen-state.test.js": "5349273cf7cfe526a05f929115a6e4e66287e6fb05b252ea859e182e88e3925e",
|
|
192
193
|
"tests/security.test.js": "f0cb70dcb28bc8b3de8d3b39064616296382c5b0f97bfd615ee8e24fe3b031bc"
|
|
193
194
|
}
|
|
@@ -24,7 +24,10 @@ Ships with the engine (free tier, `make sync-free-tier`); switched ON when it fi
|
|
|
24
24
|
`kind: 'reset'` lines - their `ok` is not a sign-in. Older engines never emit the event: nothing changes there.
|
|
25
25
|
- **Health check**: `server/facts.js` gathers (users, engine vs npm latest, certificate via tls, security headers of the
|
|
26
26
|
public home page, private paths fetched LOCALLY, TRUST_PROXY, bind, SMTP, licences); `admin/lib/health.js` judges.
|
|
27
|
-
Unknown = 'info', never a pass.
|
|
27
|
+
Unknown = 'info', never a pass. The public checks (headers, HTTPS, certificate) connect ONLY to `publicTarget()`:
|
|
28
|
+
site.json `baseUrl`/`url` when it is a public name (every DNS answer public), else the admin's own Host but only
|
|
29
|
+
when it resolves to one of this server's public interface addresses - never a host a visitor names (1.2.1). The
|
|
30
|
+
connection is pinned to the checked address (no second DNS lookup). Cached 10 min; the sidebar badge (`/count`) = checks needing attention, red only
|
|
28
31
|
when a failing check is critical.
|
|
29
32
|
- Engines before 0.83 have no sign-in checks: the plugin logs it, the screen says so, lockout/rules are off.
|
|
30
33
|
- plugin.json `minCmsVersion: "0.83.0"` (1.1.1) states that floor; core enforces it at install/update from the release after 0.92.1,
|
|
@@ -63,3 +66,8 @@ what strangers typed). Public data (emails, addresses, user-agents) only through
|
|
|
63
66
|
`security.rule-draft.<user>`. Pure parts in `admin/lib/screen-state.js` (Pro's copy adds Audit and 2FA).
|
|
64
67
|
- Every list: click/Enter/Shift+F10/right-click/⋮ open the row menu (a check row opens its details on click). Filter
|
|
65
68
|
counts follow the search; skeletons; help popovers started after mount. Keep this screen alike with Security Pro's.
|
|
69
|
+
|
|
70
|
+
## 1.2.1 (2026-10-16)
|
|
71
|
+
|
|
72
|
+
- Health check: the headers/certificate fetch no longer goes to whatever Host / X-Forwarded-Host a request carried
|
|
73
|
+
(a forged one made the server connect anywhere). `publicTarget()` in server/facts.js; `tests/facts.test.js`.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "security",
|
|
3
3
|
"displayName": "Security",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.1",
|
|
5
5
|
"tier": "free",
|
|
6
6
|
"description": "Keeps a Domma CMS site safe: a health check of what is weak and how to fix it, sign-in lockout after repeated wrong passwords, password rules, a log of every sign-in, and blocking of the scanners that probe every site for WordPress, .env files and the like.",
|
|
7
7
|
"author": "Domma CMS",
|
|
8
|
-
"date": "2026-10-
|
|
8
|
+
"date": "2026-10-16",
|
|
9
9
|
"minCmsVersion": "0.83.0",
|
|
10
10
|
"icon": "shield",
|
|
11
11
|
"permissions": [
|