emailengine-app 2.79.8 → 2.79.9

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.
Files changed (133) hide show
  1. package/.github/dependabot.yml +22 -0
  2. package/.github/workflows/test.yml +39 -0
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +20 -0
  5. package/DOCKER_DEPLOYMENT.md +6 -7
  6. package/Dockerfile +35 -11
  7. package/config/default.toml +2 -1
  8. package/copy-static-files.sh +23 -5
  9. package/data/google-crawlers.json +1 -1
  10. package/lib/account.js +26 -1
  11. package/lib/api-routes/bull-board-routes.js +3 -2
  12. package/lib/api-routes/route-helpers.js +8 -0
  13. package/lib/auth-token.js +73 -2
  14. package/lib/autodetect-imap-settings.js +33 -25
  15. package/lib/consts.js +8 -1
  16. package/lib/egress-fetch.js +133 -0
  17. package/lib/export.js +35 -2
  18. package/lib/handlebars-helpers.js +129 -0
  19. package/lib/imap-proxy-auth.js +41 -21
  20. package/lib/imapproxy/imap-core/README.md +1 -0
  21. package/lib/imapproxy/imap-core/lib/tls-options.js +5 -46
  22. package/lib/imapproxy/imap-server.js +9 -10
  23. package/lib/openapi/index.js +3 -0
  24. package/lib/outbox.js +28 -3
  25. package/lib/rate-limit.js +23 -4
  26. package/lib/schemas.js +10 -3
  27. package/lib/security-headers.js +396 -0
  28. package/lib/sentry.js +36 -4
  29. package/lib/smtp-auth.js +86 -7
  30. package/lib/tools.js +265 -120
  31. package/lib/ui-routes/account-routes.js +4 -3
  32. package/lib/ui-routes/export-routes.js +4 -0
  33. package/lib/ui-routes/mcp-consent-routes.js +7 -0
  34. package/lib/ui-routes/network-config-routes.js +4 -3
  35. package/lib/ui-routes/route-helpers.js +24 -8
  36. package/lib/ui-routes/smtp-test-routes.js +7 -0
  37. package/lib/webhook-egress.js +5 -0
  38. package/package.json +21 -24
  39. package/sbom.json +1 -1
  40. package/server.js +37 -36
  41. package/static/js/ace/css/ace.css +1462 -0
  42. package/static/js/ace/css/kuroir-1.png +0 -0
  43. package/static/js/ace/css/kuroir-2.png +0 -0
  44. package/static/js/ace/css/main-1.png +0 -0
  45. package/static/js/ace/css/main-10.svg +4 -0
  46. package/static/js/ace/css/main-11.svg +5 -0
  47. package/static/js/ace/css/main-12.svg +4 -0
  48. package/static/js/ace/css/main-13.png +0 -0
  49. package/static/js/ace/css/main-14.png +0 -0
  50. package/static/js/ace/css/main-15.png +0 -0
  51. package/static/js/ace/css/main-16.png +0 -0
  52. package/static/js/ace/css/main-17.png +0 -0
  53. package/static/js/ace/css/main-18.png +0 -0
  54. package/static/js/ace/css/main-19.png +0 -0
  55. package/static/js/ace/css/main-2.png +0 -0
  56. package/static/js/ace/css/main-20.png +0 -0
  57. package/static/js/ace/css/main-21.png +0 -0
  58. package/static/js/ace/css/main-22.png +0 -0
  59. package/static/js/ace/css/main-23.png +0 -0
  60. package/static/js/ace/css/main-24.png +0 -0
  61. package/static/js/ace/css/main-25.svg +1 -0
  62. package/static/js/ace/css/main-26.png +0 -0
  63. package/static/js/ace/css/main-3.png +0 -0
  64. package/static/js/ace/css/main-4.png +0 -0
  65. package/static/js/ace/css/main-5.svg +7 -0
  66. package/static/js/ace/css/main-6.svg +9 -0
  67. package/static/js/ace/css/main-7.svg +7 -0
  68. package/static/js/ace/css/main-8.svg +9 -0
  69. package/static/js/ace/css/main-9.svg +6 -0
  70. package/static/js/ace/css/theme/kuroir.css +78 -0
  71. package/static/js/ace/css/theme/tomorrow_night.css +128 -0
  72. package/static/js/ace/css/theme/tomorrow_night_eighties.css +128 -0
  73. package/static/js/ace/css/theme/xcode.css +106 -0
  74. package/static/js/ace/css/tomorrow_night-1.png +0 -0
  75. package/static/js/ace/css/tomorrow_night-2.png +0 -0
  76. package/static/js/ace/css/tomorrow_night_eighties-1.png +0 -0
  77. package/static/js/ace/css/tomorrow_night_eighties-2.png +0 -0
  78. package/static/js/ace/css/xcode-1.png +0 -0
  79. package/static/js/ace/css/xcode-2.png +0 -0
  80. package/static/js/ee-client.js +256 -102
  81. package/static/js/public.js +7 -0
  82. package/static/js/ui.js +32 -0
  83. package/static/licenses.html +331 -291
  84. package/static/vendor/simplewebauthn/browser.min.js +2 -2
  85. package/translations/messages.pot +203 -157
  86. package/views/accounts/account.hbs +15 -37
  87. package/views/accounts/browse.hbs +3 -1
  88. package/views/accounts/edit.hbs +1 -1
  89. package/views/accounts/register/imap-server.hbs +1 -1
  90. package/views/config/ai.hbs +1 -1
  91. package/views/config/branding.hbs +2 -2
  92. package/views/config/document-store/chat.hbs +1 -1
  93. package/views/config/document-store/index.hbs +1 -1
  94. package/views/config/imap-proxy.hbs +1 -1
  95. package/views/config/license.hbs +1 -1
  96. package/views/config/mcp.hbs +1 -1
  97. package/views/config/network.hbs +14 -16
  98. package/views/config/oauth/app.hbs +2 -2
  99. package/views/config/service.hbs +1 -1
  100. package/views/config/smtp.hbs +1 -1
  101. package/views/config/webhooks.hbs +2 -2
  102. package/views/error.hbs +4 -2
  103. package/views/internals/index.hbs +1 -1
  104. package/views/layout/app.hbs +3 -11
  105. package/views/mcp/authorize.hbs +1 -1
  106. package/views/partials/ace_assets.hbs +13 -0
  107. package/views/partials/add_account_modal.hbs +1 -1
  108. package/views/partials/address_list.hbs +4 -4
  109. package/views/partials/filter_editor_js.hbs +2 -2
  110. package/views/partials/gateway_js.hbs +1 -1
  111. package/views/partials/oauth_form.hbs +1 -1
  112. package/views/partials/public_theme_init.hbs +1 -1
  113. package/views/partials/template_form.hbs +2 -2
  114. package/views/partials/test_send.hbs +7 -4
  115. package/views/partials/theme_init.hbs +1 -1
  116. package/views/partials/ui/details.hbs +2 -2
  117. package/views/partials/webhooks_editor_functions.hbs +1 -1
  118. package/views/reference/redirect.hbs +1 -1
  119. package/views/templates/template.hbs +2 -2
  120. package/views/tokens/new.hbs +1 -1
  121. package/views/unsubscribe.hbs +1 -1
  122. package/views/webhooks/webhook.hbs +2 -2
  123. package/workers/api.js +42 -112
  124. package/workers/export.js +1 -5
  125. package/workers/imap.js +1 -3
  126. package/workers/smtp.js +12 -43
  127. package/workers/submit.js +6 -12
  128. package/workers/webhooks.js +6 -17
  129. package/static/front/EmailEngine_logo_horiz.png +0 -0
  130. package/static/front/EmailEngine_logo_vert.png +0 -0
  131. package/static/front/index.html +0 -57
  132. package/static/front/logo.png +0 -0
  133. package/static/vendor/handlebars/handlebars.min-v4.7.9.js +0 -29
@@ -0,0 +1,22 @@
1
+ version: 2
2
+
3
+ updates:
4
+ # The Node base image is the one dependency that goes stale without any diff to review, which is
5
+ # how it ended up 19 months behind. This entry exists to keep the digest current, nothing else.
6
+ - package-ecosystem: docker
7
+ directory: /
8
+ schedule:
9
+ interval: weekly
10
+ commit-message:
11
+ # `fix:` rather than `chore:`, so a base image bump reaches users through the release notes
12
+ # instead of being filtered out of them
13
+ prefix: fix
14
+ # Digest updates only. The Node major is a deliberate choice that has to stay in step with the
15
+ # CI matrix, the pkg targets and the deploy workflow, and it tracks Active LTS rather than
16
+ # Current - left unignored, the first run proposed 24-alpine to 26-alpine, which is exactly the
17
+ # drift this entry is meant to prevent. Moving the major is a manual decision.
18
+ ignore:
19
+ - dependency-name: node
20
+ update-types:
21
+ - version-update:semver-major
22
+ - version-update:semver-minor
@@ -135,6 +135,45 @@ jobs:
135
135
  #
136
136
  # One target, unsigned, uncompressed. Signing and notarization need Apple credentials and
137
137
  # stay on the release machine; neither has any bearing on whether the bundle can be built.
138
+ # The image ships an OS and a Node runtime we do not build, so its vulnerabilities arrive on
139
+ # someone else's schedule rather than in a diff. Nothing watched that before, and the base pin
140
+ # sat unmoved for 19 months while 21 Alpine CVEs accumulated behind it.
141
+ #
142
+ # Scoped to fixed HIGH/CRITICAL on purpose. An unfixed upstream CVE is not actionable here and
143
+ # would block unrelated work at random; once a fix exists, a rebuild picks it up through
144
+ # `apk upgrade`, or the base pin needs moving - both of which are on us.
145
+ docker_scan:
146
+ name: Docker Image Scan
147
+ if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
148
+ runs-on: ubuntu-24.04
149
+ timeout-minutes: 20
150
+ steps:
151
+ - uses: actions/checkout@v6
152
+
153
+ # Single arch: the findings are properties of the base image and the lockfile, neither of
154
+ # which differs per architecture, so scanning both legs would only double the runtime.
155
+ - name: Build the image
156
+ uses: docker/build-push-action@v7
157
+ with:
158
+ context: .
159
+ platforms: linux/amd64
160
+ load: true
161
+ tags: emailengine:scan
162
+
163
+ - name: Scan for known vulnerabilities
164
+ uses: aquasecurity/trivy-action@v0.36.0
165
+ with:
166
+ image-ref: emailengine:scan
167
+ scanners: vuln
168
+ severity: HIGH,CRITICAL
169
+ ignore-unfixed: true
170
+ exit-code: '1'
171
+ format: table
172
+ env:
173
+ # Trivy pulls its database from ghcr.io and is rate limited unauthenticated
174
+ TRIVY_USERNAME: ${{ github.actor }}
175
+ TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
176
+
138
177
  pkg_build:
139
178
  name: Binary Build (linux-x64, unsigned)
140
179
  if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "2.79.8"
2
+ ".": "2.79.9"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.79.9](https://github.com/postalsys/emailengine/compare/v2.79.8...v2.79.9) (2026-09-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **admin-ui:** remove the unreferenced static landing page ([eea5024](https://github.com/postalsys/emailengine/commit/eea5024e701d9633d1d19e14fc16f9512b73327f))
9
+ * **admin-ui:** render the delivery-test and address-list fragments server-side ([4443c32](https://github.com/postalsys/emailengine/commit/4443c3211c76548ac00041752b22ce52b4e6f479))
10
+ * **deps:** collapse the duplicate nodemailer copies onto version 10 ([661a2ed](https://github.com/postalsys/emailengine/commit/661a2ed29325e775ecdbd86861428e1bf26c45a4))
11
+ * **deps:** update dependencies ([2f32929](https://github.com/postalsys/emailengine/commit/2f32929fe2624a393516701aad48b41a13b78c8e))
12
+ * **deps:** update dependencies and collapse the duplicate nodemailer copies ([09553a3](https://github.com/postalsys/emailengine/commit/09553a35817b3da040eca8fa3795ed5b9dcf470a))
13
+ * **deps:** update dependencies and drop the message browser stylesheet exception ([1933e5d](https://github.com/postalsys/emailengine/commit/1933e5d9952fab26fbd3f4a630adfc0ca341717a))
14
+ * **deps:** update dependencies, picking up the dispatcher options of certs and email-ai-tools ([28ecf49](https://github.com/postalsys/emailengine/commit/28ecf499362d02bcfb7c7811e12757093e856667))
15
+ * **docker:** move the image to Node 24 and drop npm from the runtime layer ([ad190d3](https://github.com/postalsys/emailengine/commit/ad190d34972004216a612d25f32403054bd5639e))
16
+ * **proxy:** route every outbound HTTP request through the global proxy ([2ac1fb6](https://github.com/postalsys/emailengine/commit/2ac1fb65bb2db9143747cb160e4c3dc5e8b89086))
17
+ * refuse to start below Node 20, the floor package.json declares ([1bf24eb](https://github.com/postalsys/emailengine/commit/1bf24eb5988164236ced87f64a528b12ac9af9f3))
18
+ * **security:** require a nonce on stylesheets and tag the machine-facing routes ([cbcd4cb](https://github.com/postalsys/emailengine/commit/cbcd4cb16896aac91bce0c58feb112d809828cd5))
19
+ * **security:** send a nonce-based Content-Security-Policy and the remaining security headers ([4f2900e](https://github.com/postalsys/emailengine/commit/4f2900e5de6d6aeac2333d774ea3977793f99e22))
20
+ * **security:** vet autodiscovery egress, throttle proxy logins and add response headers ([74856cf](https://github.com/postalsys/emailengine/commit/74856cf64a0231ee7e38bbfb140639e29632aaa9))
21
+ * **submit:** drop an outbox entry that does not decode to a message ([e7e6618](https://github.com/postalsys/emailengine/commit/e7e6618ec31032c3d88c2bec3f89ffa70c13970d))
22
+
3
23
  ## [2.79.8](https://github.com/postalsys/emailengine/compare/v2.79.7...v2.79.8) (2026-09-02)
4
24
 
5
25
 
@@ -137,10 +137,10 @@ server {
137
137
  ssl_certificate_key /path/to/privkey.pem;
138
138
  ssl_protocols TLSv1.2 TLSv1.3;
139
139
 
140
- # Security headers
141
- add_header Strict-Transport-Security "max-age=31536000" always;
142
- add_header X-Frame-Options "SAMEORIGIN" always;
143
- add_header X-Content-Type-Options "nosniff" always;
140
+ # EmailEngine sends its own security headers (Content-Security-Policy, X-Frame-Options,
141
+ # X-Content-Type-Options, Referrer-Policy, Permissions-Policy), and Strict-Transport-Security
142
+ # once the service URL setting is https. Do not add them here as well: a second copy of a
143
+ # header is at best redundant and, for Content-Security-Policy, the two are both enforced.
144
144
 
145
145
  location / {
146
146
  proxy_pass http://127.0.0.1:3000;
@@ -177,12 +177,11 @@ server {
177
177
  ```caddyfile
178
178
  emailengine.example.com {
179
179
  reverse_proxy localhost:3000
180
- header Strict-Transport-Security "max-age=31536000"
181
- header X-Frame-Options "SAMEORIGIN"
182
- header X-Content-Type-Options "nosniff"
183
180
  }
184
181
  ```
185
182
 
183
+ EmailEngine sets the security headers itself (see the note in the Nginx example), so the Caddyfile needs no `header` lines.
184
+
186
185
  ### Step 3: Firewall Configuration
187
186
 
188
187
  ```bash
package/Dockerfile CHANGED
@@ -1,5 +1,17 @@
1
- # node:22.13.1-alpine
2
- FROM --platform=${TARGETPLATFORM} node@sha256:e2b39f7b64281324929257d0f8004fb6cb4bf0fdfb9aa8cedb235a766aec31da
1
+ # Pinned by tag AND digest: the digest is what actually gets pulled, so a rebuild of an old commit
2
+ # resolves the same Node layer, and the tag next to it keeps the line readable and lets Dependabot
3
+ # parse it (it does not follow an ARG-defined image). Both stages must stay on the same pin.
4
+ #
5
+ # The pin has to be moved deliberately - it sat on node:22.13.1-alpine for 19 months, which is how
6
+ # the image ended up shipping 21 unpatched Alpine CVEs. `apk upgrade` below covers the drift between
7
+ # pin bumps, and the docker_scan job in .github/workflows/test.yml fails the build once a fix for a
8
+ # HIGH/CRITICAL exists but is not picked up.
9
+
10
+ # Build stage. Everything that needs a package manager, a shell or a writable source tree happens
11
+ # here; the runtime stage below copies out only the finished tree, so npm and its dependencies never
12
+ # reach the published image. npm accounted for 38 of the 59 HIGH/CRITICAL findings in the old image
13
+ # (a vendored tar, pacote, sigstore, minimatch) and nothing at runtime ever invokes it.
14
+ FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS builder
3
15
 
4
16
  ARG BUILDPLATFORM
5
17
  ARG TARGETPLATFORM
@@ -12,11 +24,6 @@ RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \
12
24
  && printf "With uname -s : " && uname -s \
13
25
  && printf "and uname -m : " && uname -mm
14
26
 
15
- RUN apk add --no-cache dumb-init
16
-
17
- # Create a non-root user and group
18
- RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegroup
19
-
20
27
  WORKDIR /emailengine
21
28
 
22
29
  # Install dependencies before copying any source. npm ci is by far the slowest step in this
@@ -51,12 +58,29 @@ COPY server.js server.js
51
58
  RUN mkdir -p .git/refs/heads
52
59
  COPY .git/refs/heads/master .git/refs/heads/master
53
60
 
61
+ # version-info.json is generated here and the inputs are dropped again, so neither the git ref nor
62
+ # the script itself ends up in the runtime image.
54
63
  COPY update-info.sh update-info.sh
55
- RUN chmod +x ./update-info.sh
56
- RUN ./update-info.sh
64
+ RUN chmod +x ./update-info.sh \
65
+ && ./update-info.sh \
66
+ && rm -rf .git update-info.sh
67
+
68
+ # Runtime stage.
69
+ FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf
70
+
71
+ # `apk upgrade` patches the Alpine packages that the base image itself lags on - at the time of
72
+ # writing node:24-alpine still carries an openssl below 3.5.8-r0. dumb-init reaps zombies as PID 1.
73
+ # npm is removed outright: it is a build-time tool, and leaving it in only adds scan surface.
74
+ RUN apk add --no-cache dumb-init \
75
+ && apk upgrade --no-cache \
76
+ && rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx
77
+
78
+ # Create a non-root user and group
79
+ RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegroup
80
+
81
+ WORKDIR /emailengine
57
82
 
58
- # Ensure permissions are set correctly for the non-root user
59
- RUN chown -R emailengineuser:emailenginegroup /emailengine
83
+ COPY --from=builder --chown=emailengineuser:emailenginegroup /emailengine /emailengine
60
84
 
61
85
  RUN node -e "console.log('node arch: ' + os.arch())"
62
86
  RUN node -e "console.log(process.versions)"
@@ -27,6 +27,7 @@ maxSize = "5M" # maximum size of an attachment when submitting or uploading
27
27
  #maxBodySize = "50M" # maximum size of an API request body
28
28
  #maxPayloadTimeout = "10s" # how long to wait for a request body to arrive
29
29
  #proxy = false # trust X-Forwarded-For from a reverse proxy (restrict the peers with EENGINE_API_PROXY_ADDRESSES)
30
+ #cspMode = "enforce" # Content-Security-Policy delivery: "enforce", "report-only" (violations are only reported to the browser console) or "off"
30
31
  # Serve the API over HTTPS by pointing at a certificate and key
31
32
  #[api.tls]
32
33
  #certPath = "/path/to/cert.pem"
@@ -36,7 +37,7 @@ maxSize = "5M" # maximum size of an attachment when submitting or uploading
36
37
  enabled = false
37
38
  port = 2525
38
39
  host = "127.0.0.1"
39
- secret = "" # client password, if not set allows any password
40
+ secret = "" # shared client password; when unset, clients authenticate with an API token that has the "smtp" scope
40
41
  proxy = false # Set to true if using HAProxy with send-proxy option
41
42
  #maxMessageSize = "25M" # maximum message size accepted by SMTP server (default: 25MB)
42
43
  #maxClients = 100 # concurrent SMTP server connections; excess connections are refused with a 421 (default: 100)
@@ -13,11 +13,6 @@ cp node_modules/ace-builds/src-min/mode-html.js static/js/ace/
13
13
  cp node_modules/ace-builds/src-min/mode-json.js static/js/ace/
14
14
  cp node_modules/ace-builds/src-min/mode-javascript.js static/js/ace/
15
15
  cp node_modules/ace-builds/src-min/mode-markdown.js static/js/ace/
16
- cp node_modules/ace-builds/src-min/theme-xcode.js static/js/ace/
17
- cp node_modules/ace-builds/src-min/theme-kuroir.js static/js/ace/
18
- # dark-theme counterparts applied by uiAceEditor/uiAcePreview (static/js/ui.js)
19
- cp node_modules/ace-builds/src-min/theme-tomorrow_night.js static/js/ace/
20
- cp node_modules/ace-builds/src-min/theme-tomorrow_night_eighties.js static/js/ace/
21
16
  cp node_modules/ace-builds/src-min/worker-html.js static/js/ace/
22
17
  cp node_modules/ace-builds/src-min/worker-json.js static/js/ace/
23
18
  cp node_modules/ace-builds/src-min/worker-javascript.js static/js/ace/
@@ -25,8 +20,31 @@ cp node_modules/ace-builds/src-min/snippets/javascript.js static/js/ace/snippets
25
20
  cp node_modules/ace-builds/src-min/snippets/markdown.js static/js/ace/snippets
26
21
  cp node_modules/ace-builds/src-min/ext-searchbox.js static/js/ace/ext-searchbox.js
27
22
 
23
+ # ACE stylesheets, linked by views/partials/ace_assets.hbs. That partial also puts ACE in
24
+ # strict-CSP mode, so it injects no <style> elements of its own and the admin
25
+ # Content-Security-Policy can require a nonce on every stylesheet.
26
+ mkdir -p static/js/ace/css/theme
27
+ cp node_modules/ace-builds/css/ace.css static/js/ace/css/
28
+
29
+ # The light/dark pairs uiAceEditor and uiAcePreview switch between (static/js/ui.js). Each theme
30
+ # needs its module (for the cssClass and isDark ACE reads from it) and its stylesheet.
31
+ for theme in xcode kuroir tomorrow_night tomorrow_night_eighties; do
32
+ cp node_modules/ace-builds/src-min/theme-$theme.js static/js/ace/
33
+ cp node_modules/ace-builds/css/theme/$theme.css static/js/ace/css/theme/
34
+ done
35
+
36
+ # The images the sheets reference. Both bases land in css/ - ace.css uses ./, a theme uses ../ -
37
+ # so one pass over the copied sheets covers them.
38
+ for image in $(grep -oh 'url("[^"]*")' static/js/ace/css/ace.css static/js/ace/css/theme/*.css | sed 's/^url("//; s/")$//; s/^\.\.\///; s/^\.\///' | sort -u); do
39
+ cp node_modules/ace-builds/css/$image static/js/ace/css/
40
+ done
41
+
28
42
  cp node_modules/\@postalsys/ee-client/index.js static/js/ee-client.js
29
43
 
44
+ # SimpleWebAuthn browser bundle, kept at the same version as @simplewebauthn/server (the
45
+ # devDependency exists only to be vendored here; login-passkey.js and passkey-register.js load it)
46
+ cp node_modules/\@simplewebauthn/browser/dist/bundle/index.umd.min.js static/vendor/simplewebauthn/browser.min.js
47
+
30
48
  # FlyonUI browser bundle (vendored like ace above; committed and bundled by pkg)
31
49
  cp node_modules/flyonui/flyonui.js static/js/flyonui.js
32
50
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "creationTime": "2026-09-01T14:46:55.000000",
2
+ "creationTime": "2026-09-04T14:45:59.000000",
3
3
  "prefixes": [
4
4
  {
5
5
  "ipv6Prefix": "2001:4860:4801:2008::/64"
package/lib/account.js CHANGED
@@ -3141,6 +3141,8 @@ class Account {
3141
3141
  async invalidateAccessToken() {
3142
3142
  let accountData = await this.loadAccountData(this.account, false);
3143
3143
  if (accountData.oauth2) {
3144
+ // Rewinding the expiry is the whole encoding of "invalidated", and isAccessTokenInvalidated()
3145
+ // below is its decoder: change one and change the other
3144
3146
  accountData.oauth2.expires = new Date(Date.now() - 24 * 3600 * 1000).toISOString();
3145
3147
  await this.update({ account: accountData.account, oauth2: accountData.oauth2 });
3146
3148
  this.logger.info({ msg: 'Invalidated the OAuth2 access token', account: this.account, expires: accountData.oauth2.expires });
@@ -3369,4 +3371,27 @@ async function accountSummary(redis, account) {
3369
3371
  return { account, name: name || '', email: email || '', state: state || 'init' };
3370
3372
  }
3371
3373
 
3372
- module.exports = { Account, accountExists, accountsExist, accountSummary, authFailureDisabledAt, isAuthFailureDisabled, isOperatorDisabled };
3374
+ /**
3375
+ * Tells whether an account's access token was invalidated by Account#invalidateAccessToken().
3376
+ *
3377
+ * The invalidation rewinds `expires` by a day and leaves `generated` alone, so the token reads
3378
+ * as a validity window that ends before it starts. A live token can never have that shape (a
3379
+ * renewal writes both fields from the same clock), which makes the inversion the marker.
3380
+ *
3381
+ * @param {Object} oauth2 - The parsed oauth2 record of an account (dates as Date objects)
3382
+ * @returns {boolean}
3383
+ */
3384
+ function isAccessTokenInvalidated(oauth2) {
3385
+ return !!(oauth2 && oauth2.expires && oauth2.generated && oauth2.expires < oauth2.generated);
3386
+ }
3387
+
3388
+ module.exports = {
3389
+ Account,
3390
+ accountExists,
3391
+ accountsExist,
3392
+ accountSummary,
3393
+ authFailureDisabledAt,
3394
+ isAuthFailureDisabled,
3395
+ isOperatorDisabled,
3396
+ isAccessTokenInvalidated
3397
+ };
@@ -4,6 +4,7 @@ const { createBullBoard } = require('@bull-board/api');
4
4
  const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
5
5
  const { HapiAdapter } = require('@bull-board/hapi');
6
6
  const { notifyQueue, submitQueue, documentsQueue } = require('../db');
7
+ const { BULL_BOARD_BASE_PATH } = require('../consts');
7
8
 
8
9
  async function init(args) {
9
10
  const { server } = args;
@@ -51,9 +52,9 @@ async function init(args) {
51
52
  }
52
53
  });
53
54
 
54
- serverAdapter.setBasePath('/admin/bull-board');
55
+ serverAdapter.setBasePath(BULL_BOARD_BASE_PATH);
55
56
  await server.register(serverAdapter.registerPlugin(), {
56
- routes: { prefix: '/admin/bull-board' }
57
+ routes: { prefix: BULL_BOARD_BASE_PATH }
57
58
  });
58
59
  }
59
60
 
@@ -224,6 +224,14 @@ function maskSecrets(entry) {
224
224
  }
225
225
  }
226
226
 
227
+ // A failed delivery records the target it was aimed at on the webhook route, the account or
228
+ // the settings. The worker stores it with the credentials already stripped, but a flag written
229
+ // by an older release still carries the raw URL - the same one field over from the masked
230
+ // `targetUrl` / `webhooks` beside it, readable by any token that can list webhook routes.
231
+ if (entry.webhookErrorFlag && typeof entry.webhookErrorFlag === 'object' && entry.webhookErrorFlag.url) {
232
+ entry.webhookErrorFlag.url = maskUrlPassword(entry.webhookErrorFlag.url);
233
+ }
234
+
227
235
  return entry;
228
236
  }
229
237
 
package/lib/auth-token.js CHANGED
@@ -12,6 +12,7 @@ const tokenPermissions = require('./token-permissions');
12
12
  const tokenAuditLog = require('./token-audit-log');
13
13
  const { SURFACE_GRANTS } = require('./api-routes/permission-map');
14
14
  const { matchIp } = require('./utils/network');
15
+ const { checkRateLimit, peekRateLimit } = require('./rate-limit');
15
16
 
16
17
  // Reason-specific denial messages, shared verbatim by both auth handlers. The
17
18
  // generic "failed to authenticate" fallback and any protocol-specific error
@@ -20,9 +21,72 @@ const REASON_MESSAGES = {
20
21
  username: 'Access denied, invalid username',
21
22
  scope: 'Access denied, invalid scope',
22
23
  ip: 'Access denied, traffic not accepted from this IP',
23
- permissions: 'Access denied, token permissions do not allow this'
24
+ permissions: 'Access denied, token permissions do not allow this',
25
+ limited: 'Too many failed authentication attempts, try again later'
24
26
  };
25
27
 
28
+ // Failed logins a client address may accumulate against one username before the surface stops
29
+ // answering that pair for the rest of the window. The guard exists for the shared server
30
+ // password, which is operator-chosen with no entropy requirement and was guessable at the full
31
+ // speed of a Redis lookup; the 64-hex API tokens are not guessable at any rate this allows.
32
+ //
33
+ // Keyed on address AND username on purpose. The submission surfaces are typically driven by one
34
+ // application host sending for many accounts, and a single stale credential in that host's
35
+ // configuration must not lock its other accounts out. The username buys an attacker nothing:
36
+ // a guess needs a real account id either way, and each id they know only adds one more budget.
37
+ //
38
+ // Only failures count. A busy sender authenticating on every connection would exhaust an
39
+ // attempt-based budget by itself.
40
+ const AUTH_FAILURE_LIMIT = 20;
41
+ const AUTH_FAILURE_WINDOW = 5 * 60; // seconds
42
+
43
+ const authFailureKey = (remoteAddress, account) => `auth:fail:${remoteAddress || 'unknown'}:${account || ''}`;
44
+
45
+ /**
46
+ * Runs a credential check under the client's failed-login budget.
47
+ *
48
+ * Looks before the attempt (a peek, so an accepted login spends nothing) and records only a
49
+ * refusal. Everything `attempt` throws counts as one: the caller decides what belongs inside
50
+ * the budget by what it puts in the function, so a refusal that is about the account rather
51
+ * than the credential (an API-only account on the IMAP proxy) is left outside it.
52
+ *
53
+ * @param {Object} client
54
+ * @param {String} client.remoteAddress - client IP
55
+ * @param {String} client.account - username the client is authenticating as
56
+ * @param {Function} attempt - async () => result; the credential check
57
+ * @param {Function} limitedError - () => Error; the protocol-specific refusal for a spent budget
58
+ * @returns {Promise<*>} whatever `attempt` resolves with
59
+ */
60
+ async function withAuthFailureBudget({ remoteAddress, account }, attempt, limitedError) {
61
+ const key = authFailureKey(remoteAddress, account);
62
+
63
+ let limit = await peekRateLimit(key, AUTH_FAILURE_LIMIT, AUTH_FAILURE_WINDOW);
64
+ if (!limit.success) {
65
+ logger.warn({
66
+ msg: 'Refusing authentication attempt, failure limit reached',
67
+ remoteAddress,
68
+ account,
69
+ count: limit.count,
70
+ allowed: limit.allowed,
71
+ ttlReset: limit.ttlReset
72
+ });
73
+ throw limitedError();
74
+ }
75
+
76
+ try {
77
+ return await attempt();
78
+ } catch (err) {
79
+ // Never masks the refusal: a counter that could not be written is logged, and the
80
+ // client still gets the error the attempt raised
81
+ try {
82
+ await checkRateLimit(key, 1, AUTH_FAILURE_LIMIT, AUTH_FAILURE_WINDOW);
83
+ } catch (recordErr) {
84
+ logger.error({ msg: 'Failed to record authentication failure', remoteAddress, account, err: recordErr });
85
+ }
86
+ throw err;
87
+ }
88
+ }
89
+
26
90
  /**
27
91
  * Validates a 64-char hex API token supplied as a server password.
28
92
  *
@@ -152,4 +216,11 @@ async function validateAuthToken({ password, account, requiredScope, remoteAddre
152
216
  return { authenticated: true, reason: null };
153
217
  }
154
218
 
155
- module.exports = { validateAuthToken, REASON_MESSAGES };
219
+ module.exports = {
220
+ validateAuthToken,
221
+ withAuthFailureBudget,
222
+ authFailureKey,
223
+ AUTH_FAILURE_LIMIT,
224
+ AUTH_FAILURE_WINDOW,
225
+ REASON_MESSAGES
226
+ };
@@ -40,6 +40,8 @@ function parseXml(text) {
40
40
 
41
41
  const { fetch: fetchCmd } = require('undici');
42
42
  const { httpAgent } = require('./tools');
43
+ const { fetchWithVettedRedirects } = require('./egress-fetch');
44
+ const { validateWebhookTarget } = require('./webhook-egress');
43
45
 
44
46
  const RESOLV_TIMEOUT = 5 * 1000;
45
47
 
@@ -255,6 +257,29 @@ async function processAutoconfigFile(email, domain, text, source) {
255
257
  return { imap, smtp, _source: source };
256
258
  }
257
259
 
260
+ // Every HTTP lookup below reaches a destination derived from the email address a caller typed:
261
+ // autoconfig.<domain>, <domain>/.well-known, an autodiscover host a DNS SRV record names, port
262
+ // included. That is the same class of destination as a webhook target, so the requests go through
263
+ // the same egress policy (lib/webhook-egress.js): the policy-bound dispatcher resolves the name at
264
+ // connect time, the pre-check refuses a blocked address up front, and each redirect hop is vetted
265
+ // before it is taken. Without this, a DNS record under the caller's control pointed the lookup at
266
+ // the cloud metadata service or at whatever else the host can route to.
267
+ //
268
+ // Not the retrying dispatcher: a lookup that fails is skipped in favor of the next resolver, and
269
+ // the retry agent would only stretch the timeout budget of a dead one.
270
+ async function fetchAutodiscoveryResource(url, opts) {
271
+ opts = opts || {};
272
+ return await fetchWithVettedRedirects(
273
+ fetchCmd,
274
+ url,
275
+ Object.assign({}, opts, {
276
+ headers: Object.assign({ 'User-Agent': `${packageData.name}/${packageData.version} (+${packageData.homepage})` }, opts.headers),
277
+ dispatcher: httpAgent.webhook,
278
+ validateTarget: validateWebhookTarget
279
+ })
280
+ );
281
+ }
282
+
258
283
  async function resolveUsingMozillaDirectory(email, domain, source) {
259
284
  domain = domain || email.split('@').pop().trim().toLowerCase();
260
285
 
@@ -264,12 +289,7 @@ async function resolveUsingMozillaDirectory(email, domain, source) {
264
289
  //ignore
265
290
  }
266
291
 
267
- let res = await fetchCmd(`https://autoconfig.thunderbird.net/v1.1/${domain}`, {
268
- headers: {
269
- 'User-Agent': `${packageData.name}/${packageData.version} (+${packageData.homepage})`
270
- },
271
- dispatcher: httpAgent.retry
272
- });
292
+ let res = await fetchAutodiscoveryResource(`https://autoconfig.thunderbird.net/v1.1/${domain}`);
273
293
 
274
294
  if (!res.ok) {
275
295
  throw new Error('Invalid response');
@@ -289,12 +309,9 @@ async function resolveUsingAutoconfig(email, domain, source) {
289
309
  //ignore
290
310
  }
291
311
 
292
- let res = await fetchCmd(`https://autoconfig.${encodeURIComponent(domain)}/mail/config-v1.1.xml?emailaddress=${encodeURIComponent(email)}`, {
293
- headers: {
294
- 'User-Agent': `${packageData.name}/${packageData.version} (+${packageData.homepage})`
295
- },
296
- dispatcher: httpAgent.retry
297
- });
312
+ let res = await fetchAutodiscoveryResource(
313
+ `https://autoconfig.${encodeURIComponent(domain)}/mail/config-v1.1.xml?emailaddress=${encodeURIComponent(email)}`
314
+ );
298
315
 
299
316
  if (!res.ok) {
300
317
  throw new Error('Invalid response');
@@ -314,12 +331,7 @@ async function resolveUsingWellKnown(email, domain, source) {
314
331
  //ignore
315
332
  }
316
333
 
317
- let res = await fetchCmd(`http://${encodeURIComponent(domain)}/.well-known/autoconfig/mail/config-v1.1.xml`, {
318
- headers: {
319
- 'User-Agent': `${packageData.name}/${packageData.version} (+${packageData.homepage})`
320
- },
321
- dispatcher: httpAgent.retry
322
- });
334
+ let res = await fetchAutodiscoveryResource(`http://${encodeURIComponent(domain)}/.well-known/autoconfig/mail/config-v1.1.xml`);
323
335
 
324
336
  if (!res.ok) {
325
337
  throw new Error('Invalid response');
@@ -700,14 +712,10 @@ async function resolveUsingAutodiscovery(email, domain, source) {
700
712
 
701
713
  let discoveryUrl = `https://${discoveryDomain}/autodiscover/autodiscover.xml`;
702
714
 
703
- let res = await fetchCmd(discoveryUrl, {
715
+ let res = await fetchAutodiscoveryResource(discoveryUrl, {
704
716
  method: 'post',
705
- headers: {
706
- 'User-Agent': `${packageData.name}/${packageData.version} (+${packageData.homepage})`,
707
- 'Content-type': 'application/xml'
708
- },
709
- body,
710
- dispatcher: httpAgent.retry
717
+ headers: { 'Content-type': 'application/xml' },
718
+ body
711
719
  });
712
720
 
713
721
  if (!res.ok) {
package/lib/consts.js CHANGED
@@ -244,6 +244,10 @@ module.exports = {
244
244
 
245
245
  NONCE_BYTES: 16,
246
246
 
247
+ // Where the bull-board queue browser is mounted (lib/api-routes/bull-board-routes.js); the
248
+ // security headers key their bull-board profile on it
249
+ BULL_BOARD_BASE_PATH: '/admin/bull-board',
250
+
247
251
  // Longest account id EmailEngine accepts. Defined here rather than only on `accountIdSchema`
248
252
  // because the token audit log truncates to it while writing, before route validation has had a
249
253
  // chance to reject a longer one, and the two have to agree: a log that trimmed at a different
@@ -344,7 +348,10 @@ module.exports = {
344
348
  'req.query.access_token',
345
349
  'err.rawPacket',
346
350
  'err._original',
347
- 'err.details[*].context.value'
351
+ 'err.details[*].context.value',
352
+ // the WHATWG URL parser attaches the string it rejected, and a stored proxy or webhook URL
353
+ // carries its credentials inline
354
+ 'err.input'
348
355
  ],
349
356
 
350
357
  generateWebhookTable() {