@bobfrankston/rmfmail 1.2.280 → 1.2.281
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/.commitmsg +63 -19
- package/client/android-bootstrap.bundle.js +145 -0
- package/client/android-bootstrap.bundle.js.map +3 -3
- package/client/app.bundle.js +16 -0
- package/client/app.bundle.js.map +3 -3
- package/client/components/message-viewer.js +27 -1
- package/client/components/message-viewer.js.map +1 -1
- package/client/components/message-viewer.ts +29 -1
- package/client/styles/components.css +46 -0
- package/npmchanges.md +22 -0
- package/package.json +1 -1
- package/packages/mailx-imap/package-lock.json +2 -2
- package/packages/mailx-imap/package.json +1 -1
- package/packages/mailx-settings/docs/editor.md +29 -3
- package/packages/mailx-settings/docs/preferences.md +2 -1
- package/packages/mailx-settings/package.json +1 -1
- package/packages/mailx-store/package.json +1 -1
- package/packages/mailx-store/store.d.ts +4 -0
- package/packages/mailx-store/store.d.ts.map +1 -1
- package/packages/mailx-store/store.js +18 -1
- package/packages/mailx-store/store.js.map +1 -1
- package/packages/mailx-store/store.ts +22 -1
- package/packages/mailx-store-web/package.json +1 -1
- package/packages/mailx-types/index.d.ts +2 -0
- package/packages/mailx-types/index.d.ts.map +1 -1
- package/packages/mailx-types/index.js +18 -0
- package/packages/mailx-types/index.js.map +1 -1
- package/packages/mailx-types/index.ts +20 -0
- package/packages/mailx-types/package.json +1 -1
- package/packages/mailx-types/trust.d.ts +66 -0
- package/packages/mailx-types/trust.d.ts.map +1 -0
- package/packages/mailx-types/trust.js +228 -0
- package/packages/mailx-types/trust.js.map +1 -0
- package/packages/mailx-types/trust.ts +239 -0
- /package/packages/mailx-imap/{node_modules.npmglobalize-stash-18028 → node_modules.npmglobalize-stash-65528}/.package-lock.json +0 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a message looks forged.
|
|
3
|
+
*
|
|
4
|
+
* Not a spam filter — a spam filter guesses, and a guess that fires on real
|
|
5
|
+
* mail teaches you to click past it. Everything here is EVIDENCE: a verdict
|
|
6
|
+
* your own mail server already reached, or a construct in the message that
|
|
7
|
+
* legitimate mail does not contain. Each finding names what was found and what
|
|
8
|
+
* it means, so the reader can check it rather than trust a score.
|
|
9
|
+
*
|
|
10
|
+
* Written 2026-08-25 after two phishes landed looking clean in the reader
|
|
11
|
+
* (Bob: "this is an attack — could you do a better job of identifying it as
|
|
12
|
+
* bogus?"). Both carried all of the following, and mailx surfaced NONE of it:
|
|
13
|
+
*
|
|
14
|
+
* X-Spam-Flag: YES <- his own server, score 6.7/4.5
|
|
15
|
+
* Authentication-Results: ... spf=fail
|
|
16
|
+
* From: bobip@bobf.frankston.com <- his own address, forged
|
|
17
|
+
* To: bobip@bobf.frankston.com
|
|
18
|
+
* Return-Path: <3EDTkWNvbY@visionsurveysqld.com.au>
|
|
19
|
+
* <area coords="0,0,10000,10000" href="http://.../redirect.php?newurl=...">
|
|
20
|
+
*
|
|
21
|
+
* No header in that list was read anywhere in the codebase, and the one
|
|
22
|
+
* impersonation check that existed (displayNameClaimsOtherAddress) needs a
|
|
23
|
+
* display name, which these messages did not have. The whole visible card was
|
|
24
|
+
* one hidden link through an open redirector, with the victim's own address
|
|
25
|
+
* base64'd into the fragment so the landing page could prefill it.
|
|
26
|
+
*
|
|
27
|
+
* Deliberately NOT included: bare SPF failure on mail that isn't claiming to
|
|
28
|
+
* be you. Forwarded mail fails SPF constantly, and flagging that would be
|
|
29
|
+
* exactly the cry-wolf banner this is trying not to be.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** One piece of evidence that a message is not what it claims to be. */
|
|
33
|
+
export interface TrustFinding {
|
|
34
|
+
/** Stable identifier — for tests, logs, and any future suppression UI. */
|
|
35
|
+
id: "server-spam-verdict" | "self-spoof" | "hidden-link-overlay" | "redirector-link";
|
|
36
|
+
/** `danger`: near-certain forgery. `caution`: worth a second look. */
|
|
37
|
+
severity: "danger" | "caution";
|
|
38
|
+
/** One line, naming what was found. Never "this message is suspicious". */
|
|
39
|
+
text: string;
|
|
40
|
+
/** The specific evidence — a header value, a host, a score. */
|
|
41
|
+
detail: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TrustInput {
|
|
45
|
+
/** Every header line, in order, as mailparser's `headerLines`. Repeated
|
|
46
|
+
* headers matter: Authentication-Results and Received both appear more
|
|
47
|
+
* than once and the interesting one is not always the first. */
|
|
48
|
+
headerLines: { key: string; line: string }[];
|
|
49
|
+
/** Envelope From address. */
|
|
50
|
+
fromAddress: string;
|
|
51
|
+
/** Addresses belonging to the reader — their own aliases. Used only to
|
|
52
|
+
* recognise a message claiming to BE them. */
|
|
53
|
+
ownAddresses: string[];
|
|
54
|
+
/** Sanitized HTML body, for the link-construct checks. */
|
|
55
|
+
bodyHtml: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** First value of a header, case-insensitive. */
|
|
59
|
+
function header(lines: TrustInput["headerLines"], name: string): string {
|
|
60
|
+
const want = name.toLowerCase();
|
|
61
|
+
for (const h of lines) {
|
|
62
|
+
if ((h.key || "").toLowerCase() !== want) continue;
|
|
63
|
+
const colon = h.line.indexOf(":");
|
|
64
|
+
return colon < 0 ? "" : h.line.slice(colon + 1).trim();
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** All values of a repeated header. */
|
|
70
|
+
function headerAll(lines: TrustInput["headerLines"], name: string): string[] {
|
|
71
|
+
const want = name.toLowerCase();
|
|
72
|
+
const out: string[] = [];
|
|
73
|
+
for (const h of lines) {
|
|
74
|
+
if ((h.key || "").toLowerCase() !== want) continue;
|
|
75
|
+
const colon = h.line.indexOf(":");
|
|
76
|
+
if (colon >= 0) out.push(h.line.slice(colon + 1).trim());
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function bare(addr: string): string {
|
|
82
|
+
const m = (addr || "").match(/[^\s<>,;]+@[^\s<>,;]+/);
|
|
83
|
+
return (m ? m[0] : addr || "").toLowerCase().replace(/[.,;]+$/, "");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Did the receiving server's spam filter already say yes?
|
|
88
|
+
*
|
|
89
|
+
* The highest-value signal available, and it costs nothing: the mail server
|
|
90
|
+
* ran SpamAssassin before delivery and wrote the answer into the message.
|
|
91
|
+
* mailx was throwing it away.
|
|
92
|
+
*
|
|
93
|
+
* Only a POSITIVE verdict is trusted, never a negative one. Anyone can inject
|
|
94
|
+
* `X-Spam-Flag: NO` into a message they send, and treating that as a clean
|
|
95
|
+
* bill of health would hand attackers a switch for turning the check off. A
|
|
96
|
+
* forged YES only flags the forger's own mail, so the asymmetry is safe.
|
|
97
|
+
*/
|
|
98
|
+
function serverSpamVerdict(lines: TrustInput["headerLines"]): TrustFinding {
|
|
99
|
+
const flag = header(lines, "x-spam-flag");
|
|
100
|
+
const status = header(lines, "x-spam-status");
|
|
101
|
+
if (!/^yes/i.test(flag) && !/^yes/i.test(status)) return null;
|
|
102
|
+
|
|
103
|
+
// "Yes, score=6.7 required=4.5 tests=..." — quote the numbers when they
|
|
104
|
+
// are there, so the reader sees how emphatic the verdict was.
|
|
105
|
+
const score = status.match(/score=([-\d.]+)/)?.[1];
|
|
106
|
+
const required = status.match(/required=([-\d.]+)/)?.[1];
|
|
107
|
+
return {
|
|
108
|
+
id: "server-spam-verdict",
|
|
109
|
+
severity: "danger",
|
|
110
|
+
text: "Your mail server classified this as spam before delivering it.",
|
|
111
|
+
detail: score && required
|
|
112
|
+
? `SpamAssassin score ${score}, threshold ${required}`
|
|
113
|
+
: (status || flag || "X-Spam-Flag: YES"),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Does the message claim to come from the reader themselves, while failing the
|
|
119
|
+
* authentication that would prove it?
|
|
120
|
+
*
|
|
121
|
+
* Either half alone is ordinary — people really do mail themselves notes, and
|
|
122
|
+
* forwarded mail really does fail SPF. Together they are not: mail genuinely
|
|
123
|
+
* from your own account authenticates as your own account. This is the most
|
|
124
|
+
* common shape of targeted phish, because a From line showing your own address
|
|
125
|
+
* defeats every visual check a reader makes.
|
|
126
|
+
*
|
|
127
|
+
* Requires an EXPLICIT failure. A message with no Authentication-Results at
|
|
128
|
+
* all (internal mail that never crossed a trust boundary) is not evidence of
|
|
129
|
+
* anything and must not fire this.
|
|
130
|
+
*/
|
|
131
|
+
function selfSpoof(input: TrustInput): TrustFinding {
|
|
132
|
+
const from = bare(input.fromAddress);
|
|
133
|
+
if (!from) return null;
|
|
134
|
+
const own = new Set(input.ownAddresses.map(bare).filter(Boolean));
|
|
135
|
+
if (!own.has(from)) return null;
|
|
136
|
+
|
|
137
|
+
const auth = headerAll(input.headerLines, "authentication-results").join(" ; ");
|
|
138
|
+
const failed = [
|
|
139
|
+
/\bspf=(fail|softfail)\b/i.test(auth) ? "SPF" : "",
|
|
140
|
+
/\bdkim=(fail|permerror)\b/i.test(auth) ? "DKIM" : "",
|
|
141
|
+
/\bdmarc=(fail|permerror)\b/i.test(auth) ? "DMARC" : "",
|
|
142
|
+
].filter(Boolean);
|
|
143
|
+
if (!failed.length) return null;
|
|
144
|
+
|
|
145
|
+
// Name the envelope sender when it disagrees — that is the address that
|
|
146
|
+
// actually sent this, and seeing it beside the claim is the whole story.
|
|
147
|
+
const envelope = bare(header(input.headerLines, "return-path"));
|
|
148
|
+
const envelopeNote = envelope && envelope !== from ? `; actually sent by ${envelope}` : "";
|
|
149
|
+
return {
|
|
150
|
+
id: "self-spoof",
|
|
151
|
+
severity: "danger",
|
|
152
|
+
text: `This claims to be from your own address, ${from}, but it did not come from your account.`,
|
|
153
|
+
detail: `${failed.join(" and ")} authentication failed${envelopeNote}`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Bigger than any real image. An honest layout never needs a hotspot this
|
|
158
|
+
* large; a forger picks an absurd number so they don't have to know the
|
|
159
|
+
* rendered size. Not a tuned threshold — a sanity bound. */
|
|
160
|
+
const OVERLAY_MIN_EDGE_PX = 2000;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Is an entire image covered by one invisible link?
|
|
164
|
+
*
|
|
165
|
+
* `<area coords="0,0,10000,10000">` turns every pixel of an image into a link
|
|
166
|
+
* with no underlined text, no visible URL, and no safe area to click. Real
|
|
167
|
+
* mail uses image maps almost never, and never at that size.
|
|
168
|
+
*/
|
|
169
|
+
function hiddenLinkOverlay(bodyHtml: string): TrustFinding {
|
|
170
|
+
for (const m of bodyHtml.matchAll(/<area\b[^>]*>/gi)) {
|
|
171
|
+
const tag = m[0];
|
|
172
|
+
const href = tag.match(/href\s*=\s*["']([^"']+)["']/i)?.[1];
|
|
173
|
+
if (!href) continue;
|
|
174
|
+
const coords = (tag.match(/coords\s*=\s*["']([^"']+)["']/i)?.[1] || "")
|
|
175
|
+
.split(/[,\s]+/).map(Number).filter(n => Number.isFinite(n));
|
|
176
|
+
if (coords.length < 4) continue;
|
|
177
|
+
const width = Math.abs(coords[2] - coords[0]);
|
|
178
|
+
const height = Math.abs(coords[3] - coords[1]);
|
|
179
|
+
if (width < OVERLAY_MIN_EDGE_PX || height < OVERLAY_MIN_EDGE_PX) continue;
|
|
180
|
+
let host = href;
|
|
181
|
+
try { host = new URL(href).hostname; } catch { /* keep the raw href */ }
|
|
182
|
+
return {
|
|
183
|
+
id: "hidden-link-overlay",
|
|
184
|
+
severity: "danger",
|
|
185
|
+
text: "The picture in this message is one large hidden link — clicking anywhere on it goes to the same place.",
|
|
186
|
+
detail: `${width}x${height} clickable area over the image, pointing at ${host}`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Does a link route through a redirector carrying its real destination in the
|
|
194
|
+
* query string?
|
|
195
|
+
*
|
|
196
|
+
* `castanet-sa.fr/modules/babel/redirect.php?newurl=https%3A%2F%2Fevil.example`
|
|
197
|
+
* borrows a real site's reputation: the visible host is a legitimate business
|
|
198
|
+
* whose redirect script was left open, and the destination appears only
|
|
199
|
+
* percent-encoded inside a parameter. Reporting the ENDPOINT is the point — a
|
|
200
|
+
* reader cannot be expected to URL-decode a query string.
|
|
201
|
+
*/
|
|
202
|
+
function redirectorLink(bodyHtml: string): TrustFinding {
|
|
203
|
+
for (const m of bodyHtml.matchAll(/href\s*=\s*["']([^"']+)["']/gi)) {
|
|
204
|
+
let url: URL;
|
|
205
|
+
try { url = new URL(m[1]); } catch { continue; }
|
|
206
|
+
if (!/^https?:$/.test(url.protocol)) continue;
|
|
207
|
+
for (const [, value] of url.searchParams) {
|
|
208
|
+
let target: URL;
|
|
209
|
+
try { target = new URL(value); } catch { continue; }
|
|
210
|
+
if (!/^https?:$/.test(target.protocol)) continue;
|
|
211
|
+
if (target.hostname === url.hostname) continue; // same-site, not laundering
|
|
212
|
+
return {
|
|
213
|
+
id: "redirector-link",
|
|
214
|
+
severity: "caution",
|
|
215
|
+
text: `A link hides where it goes: it passes through ${url.hostname} and ends at ${target.hostname}.`,
|
|
216
|
+
detail: `${url.hostname} -> ${target.hostname}`,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Everything findable about this message, worst first.
|
|
225
|
+
*
|
|
226
|
+
* Returns an empty array for ordinary mail — the caller then shows nothing,
|
|
227
|
+
* rather than a reassuring "looks fine" this cannot support. Absence of
|
|
228
|
+
* evidence is not a clean bill of health.
|
|
229
|
+
*/
|
|
230
|
+
export function assessMessageTrust(input: TrustInput): TrustFinding[] {
|
|
231
|
+
const findings = [
|
|
232
|
+
serverSpamVerdict(input.headerLines),
|
|
233
|
+
selfSpoof(input),
|
|
234
|
+
hiddenLinkOverlay(input.bodyHtml || ""),
|
|
235
|
+
redirectorLink(input.bodyHtml || ""),
|
|
236
|
+
].filter(Boolean);
|
|
237
|
+
const rank = { danger: 0, caution: 1 };
|
|
238
|
+
return findings.sort((a, b) => rank[a.severity] - rank[b.severity]);
|
|
239
|
+
}
|