emailengine-app 2.68.0 → 2.68.1
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/.github/codeql/codeql-config.yml +16 -0
- package/.github/workflows/codeql.yml +102 -0
- package/.github/workflows/deploy.yml +6 -0
- package/.github/workflows/test.yml +3 -0
- package/CHANGELOG.md +9 -0
- package/SECURITY.md +80 -0
- package/SECURITY.txt +27 -0
- package/data/google-crawlers.json +7 -1
- package/lib/imapproxy/imap-core/lib/imap-command.js +1 -1
- package/lib/imapproxy/imap-core/lib/imap-connection.js +7 -0
- package/lib/imapproxy/imap-core/lib/imap-server.js +1 -1
- package/lib/imapproxy/imap-server.js +92 -29
- package/lib/tools.js +5 -0
- package/package.json +13 -13
- package/sbom.json +1 -1
- package/server.js +3 -3
- package/static/licenses.html +44 -174
- package/translations/messages.pot +45 -45
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: "EmailEngine CodeQL config"
|
|
2
|
+
|
|
3
|
+
# Exclude code that is not part of the production runtime from analysis.
|
|
4
|
+
# These paths generate only false-positive noise:
|
|
5
|
+
# - test fixtures intentionally disable TLS verification, build shell
|
|
6
|
+
# commands from fixed paths, etc.
|
|
7
|
+
# - vendored third-party browser assets (Bootstrap and other bundles) ship
|
|
8
|
+
# with their own known patterns and are not maintained here
|
|
9
|
+
# - developer helper scripts (e.g. test-token refresh) deliberately print
|
|
10
|
+
# tokens to the console for local debugging
|
|
11
|
+
paths-ignore:
|
|
12
|
+
- test
|
|
13
|
+
- '**/test/**'
|
|
14
|
+
- scripts
|
|
15
|
+
- static/bootstrap-4.6.2-dist
|
|
16
|
+
- static/vendor
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL Advanced"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [ "master" ]
|
|
17
|
+
pull_request:
|
|
18
|
+
branches: [ "master" ]
|
|
19
|
+
schedule:
|
|
20
|
+
- cron: '40 17 * * 6'
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
analyze:
|
|
24
|
+
name: Analyze (${{ matrix.language }})
|
|
25
|
+
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
|
26
|
+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
|
27
|
+
# - https://gh.io/supported-runners-and-hardware-resources
|
|
28
|
+
# - https://gh.io/using-larger-runners (GitHub.com only)
|
|
29
|
+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
|
30
|
+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
|
31
|
+
permissions:
|
|
32
|
+
# required for all workflows
|
|
33
|
+
security-events: write
|
|
34
|
+
|
|
35
|
+
# required to fetch internal or private CodeQL packs
|
|
36
|
+
packages: read
|
|
37
|
+
|
|
38
|
+
# only required for workflows in private repositories
|
|
39
|
+
actions: read
|
|
40
|
+
contents: read
|
|
41
|
+
|
|
42
|
+
strategy:
|
|
43
|
+
fail-fast: false
|
|
44
|
+
matrix:
|
|
45
|
+
include:
|
|
46
|
+
- language: actions
|
|
47
|
+
build-mode: none
|
|
48
|
+
- language: javascript-typescript
|
|
49
|
+
build-mode: none
|
|
50
|
+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
|
|
51
|
+
# Use `c-cpp` to analyze code written in C, C++ or both
|
|
52
|
+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
|
53
|
+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
|
54
|
+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
|
55
|
+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
|
56
|
+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
|
57
|
+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
|
58
|
+
steps:
|
|
59
|
+
- name: Checkout repository
|
|
60
|
+
uses: actions/checkout@v4
|
|
61
|
+
|
|
62
|
+
# Add any setup steps before running the `github/codeql-action/init` action.
|
|
63
|
+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
|
64
|
+
# or others). This is typically only required for manual builds.
|
|
65
|
+
# - name: Setup runtime (example)
|
|
66
|
+
# uses: actions/setup-example@v1
|
|
67
|
+
|
|
68
|
+
# Initializes the CodeQL tools for scanning.
|
|
69
|
+
- name: Initialize CodeQL
|
|
70
|
+
uses: github/codeql-action/init@v4
|
|
71
|
+
with:
|
|
72
|
+
languages: ${{ matrix.language }}
|
|
73
|
+
build-mode: ${{ matrix.build-mode }}
|
|
74
|
+
config-file: ./.github/codeql/codeql-config.yml
|
|
75
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
76
|
+
# By default, queries listed here will override any specified in a config file.
|
|
77
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
78
|
+
|
|
79
|
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
80
|
+
# queries: security-extended,security-and-quality
|
|
81
|
+
|
|
82
|
+
# If the analyze step fails for one of the languages you are analyzing with
|
|
83
|
+
# "We were unable to automatically build your code", modify the matrix above
|
|
84
|
+
# to set the build mode to "manual" for that language. Then modify this step
|
|
85
|
+
# to build your code.
|
|
86
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
87
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
88
|
+
- name: Run manual build steps
|
|
89
|
+
if: matrix.build-mode == 'manual'
|
|
90
|
+
shell: bash
|
|
91
|
+
run: |
|
|
92
|
+
echo 'If you are using a "manual" build mode for one or more of the' \
|
|
93
|
+
'languages you are analyzing, replace this with the commands to build' \
|
|
94
|
+
'your code, for example:'
|
|
95
|
+
echo ' make bootstrap'
|
|
96
|
+
echo ' make release'
|
|
97
|
+
exit 1
|
|
98
|
+
|
|
99
|
+
- name: Perform CodeQL Analysis
|
|
100
|
+
uses: github/codeql-action/analyze@v4
|
|
101
|
+
with:
|
|
102
|
+
category: "/language:${{matrix.language}}"
|
|
@@ -5,6 +5,9 @@ on:
|
|
|
5
5
|
|
|
6
6
|
name: Deploy test instance and Docker image
|
|
7
7
|
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
8
11
|
concurrency:
|
|
9
12
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
13
|
cancel-in-progress: true
|
|
@@ -60,6 +63,9 @@ jobs:
|
|
|
60
63
|
docker:
|
|
61
64
|
name: Build Docker Image
|
|
62
65
|
runs-on: ubuntu-24.04
|
|
66
|
+
permissions:
|
|
67
|
+
contents: read
|
|
68
|
+
packages: write
|
|
63
69
|
|
|
64
70
|
steps:
|
|
65
71
|
- name: Checkout
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.68.1](https://github.com/postalsys/emailengine/compare/v2.68.0...v2.68.1) (2026-06-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* harden mergeObjects and tighten CodeQL scanning ([d35025d](https://github.com/postalsys/emailengine/commit/d35025daabf8fe7b3f5200b0000f52c3a012f4eb))
|
|
9
|
+
* prevent IMAP proxy worker crashes and connection leaks ([#596](https://github.com/postalsys/emailengine/issues/596)) ([4453330](https://github.com/postalsys/emailengine/commit/4453330ad38fb3e64692add1357d48227e1956e0))
|
|
10
|
+
* stop referencing prepared password string in error log ([50cdb89](https://github.com/postalsys/emailengine/commit/50cdb8998e27f33f700f267cb39ddba39e7d32d0))
|
|
11
|
+
|
|
3
12
|
## [2.68.0](https://github.com/postalsys/emailengine/compare/v2.67.3...v2.68.0) (2026-05-26)
|
|
4
13
|
|
|
5
14
|
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
EmailEngine is a self-hosted email integration platform that stores email
|
|
4
|
+
account credentials and proxies access to IMAP/SMTP, the Gmail API, and the
|
|
5
|
+
Microsoft Graph API. Because it handles sensitive credentials and message
|
|
6
|
+
content, we take security reports seriously and aim to respond quickly.
|
|
7
|
+
|
|
8
|
+
## Supported Versions
|
|
9
|
+
|
|
10
|
+
Security fixes are released only against the latest version. We do not backport
|
|
11
|
+
patches to older releases - upgrading to the current release line is the
|
|
12
|
+
supported way to receive security updates.
|
|
13
|
+
|
|
14
|
+
| Version | Supported |
|
|
15
|
+
| ------- | ------------------ |
|
|
16
|
+
| 2.x | :white_check_mark: |
|
|
17
|
+
| < 2.0 | :x: |
|
|
18
|
+
|
|
19
|
+
If you are on an older version, please upgrade. See the release notes at
|
|
20
|
+
<https://github.com/postalsys/emailengine/releases> before updating.
|
|
21
|
+
|
|
22
|
+
## Reporting a Vulnerability
|
|
23
|
+
|
|
24
|
+
**Please do not report security vulnerabilities through public GitHub issues,
|
|
25
|
+
pull requests, or discussions.**
|
|
26
|
+
|
|
27
|
+
Report privately through one of the following channels:
|
|
28
|
+
|
|
29
|
+
1. **GitHub Security Advisories (preferred).** Open a private report at
|
|
30
|
+
<https://github.com/postalsys/emailengine/security/advisories/new>. This keeps
|
|
31
|
+
the discussion private until a fix is published and lets us credit you.
|
|
32
|
+
2. **Email.** Send details to **andris@postalsys.com** (the contact listed in
|
|
33
|
+
[`SECURITY.txt`](SECURITY.txt)). Encrypt sensitive details if possible.
|
|
34
|
+
|
|
35
|
+
When reporting, please include as much of the following as you can:
|
|
36
|
+
|
|
37
|
+
- The affected version(s) and environment (EmailEngine version, Node.js version,
|
|
38
|
+
OS, deployment method - npm, Docker, or prebuilt binary).
|
|
39
|
+
- The component involved (e.g. REST API, admin web UI, OAuth2 flows, IMAP/SMTP
|
|
40
|
+
proxy server, webhook delivery, credential encryption, the export pipeline).
|
|
41
|
+
- A clear description of the issue and its impact (e.g. authentication bypass,
|
|
42
|
+
privilege escalation, credential disclosure, SSRF, injection, information
|
|
43
|
+
disclosure, denial of service).
|
|
44
|
+
- A minimal proof of concept or reproduction steps.
|
|
45
|
+
- Any suggested remediation, if you have one.
|
|
46
|
+
|
|
47
|
+
We are a small team, so there is no guaranteed response time - sometimes reports
|
|
48
|
+
are handled within hours, sometimes they take longer. Accepted issues are fixed
|
|
49
|
+
in a new release and coordinated through a GitHub Security Advisory, and
|
|
50
|
+
reporters who wish to be named are credited.
|
|
51
|
+
|
|
52
|
+
## CVEs
|
|
53
|
+
|
|
54
|
+
We track and disclose vulnerabilities through GitHub Security Advisories. We do
|
|
55
|
+
not request or manage CVE identifiers ourselves. If you need a CVE assigned for a
|
|
56
|
+
reported issue, please request one yourself - for example, through GitHub's own
|
|
57
|
+
CVE request flow on the published advisory, or another CNA.
|
|
58
|
+
|
|
59
|
+
## Scope
|
|
60
|
+
|
|
61
|
+
In scope: the EmailEngine application source in this repository - the REST API
|
|
62
|
+
and admin web UI (authentication, session and token handling, CSRF protection),
|
|
63
|
+
OAuth2 application handling, credential encryption at rest, the IMAP/SMTP and
|
|
64
|
+
IMAP proxy servers, webhook delivery (including custom filter/transform
|
|
65
|
+
functions), the export pipeline, and inter-worker communication.
|
|
66
|
+
|
|
67
|
+
Out of scope:
|
|
68
|
+
|
|
69
|
+
- Vulnerabilities in your own application code that integrates with EmailEngine.
|
|
70
|
+
- Misconfiguration of your deployment - for example, exposing the admin
|
|
71
|
+
interface or REST API to untrusted networks, weak service secrets, an
|
|
72
|
+
unauthenticated or publicly reachable Redis instance, or missing TLS.
|
|
73
|
+
- Issues that require an already-compromised host or pre-existing administrator
|
|
74
|
+
access.
|
|
75
|
+
- Vulnerabilities in third-party email providers and services that EmailEngine
|
|
76
|
+
connects to (Gmail, Microsoft 365, arbitrary IMAP/SMTP servers).
|
|
77
|
+
- Social-engineering reports and missing security headers without a
|
|
78
|
+
demonstrated, concrete impact.
|
|
79
|
+
|
|
80
|
+
Thank you for helping keep EmailEngine and its users safe.
|
package/SECURITY.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-----BEGIN PGP SIGNED MESSAGE-----
|
|
2
|
+
Hash: SHA256
|
|
3
|
+
|
|
4
|
+
Contact: https://github.com/postalsys/emailengine/security/advisories/new
|
|
5
|
+
Contact: mailto:andris@postalsys.com
|
|
6
|
+
Expires: 2027-06-01T00:00:00.000Z
|
|
7
|
+
Encryption: https://keys.openpgp.org/vks/v1/by-fingerprint/5D952A46E1D8C931F6364E01DC6C83F4D584D364
|
|
8
|
+
Preferred-Languages: en, et
|
|
9
|
+
Canonical: https://github.com/postalsys/emailengine/blob/master/SECURITY.txt
|
|
10
|
+
Policy: https://github.com/postalsys/emailengine/blob/master/SECURITY.md
|
|
11
|
+
-----BEGIN PGP SIGNATURE-----
|
|
12
|
+
|
|
13
|
+
iQJPBAEBCAA5FiEEXZUqRuHYyTH2Nk4B3GyD9NWE02QFAmodKpsbFIAAAAAABAAO
|
|
14
|
+
bWFudTIsMi41KzEuMTIsMCwzAAoJENxsg/TVhNNkbcEP/j1v3M9ebklJgaCxkVEl
|
|
15
|
+
xij24q4p+28s1ywf4y/aquBtcVkWd+y6vjG/f4RUUUtaSVChvnI5en14X8QuuSnk
|
|
16
|
+
egsRARvCY9E2dbodMSyDUMWS8slRcFTDczQJhtXBD8Fu+/tWPj1UfQ8xR87ZUZ5b
|
|
17
|
+
nOgCfCFnvSuDh9KBauUKZcSyuLCJ5saBuZ3RACzmz57wpzFE3vi4/q4tQAaBM5Za
|
|
18
|
+
m4293Yx8ioX01S3nR5VRL8dlpdMEFy0dj66v/OFu4p3MjGf+0cpmZ7YKC8U5PhNQ
|
|
19
|
+
FcQMTNkfBtkgc5lj42cKV8BBhCtN2og3u+Bhih0h0XItv4b/o9rWBtivXIQcHdtl
|
|
20
|
+
WyGrrbgfGl503aVj8N0cIQ1eaWAbuRRJVHwF/G11sX6ZvhiLHdHf5YSjOrmyhSmx
|
|
21
|
+
6t2gsKMrrvoODRUOqpu8ll8Rosu6m/EaNWgh9KXJyYqgQqGS+NeQHcC51fWMLjxd
|
|
22
|
+
7zvYrNKqhMEU8e6siyLdJJgqAJCCtl9vS/kLItPz9hBk3KE2/kXfvQc6OF4I4ziU
|
|
23
|
+
3/Edf1v37koEnT07P5HdiGgUo+u4Vo8OUEm5Ih88EWaWijHGLPeJ0NyMfkwsveTw
|
|
24
|
+
n1z7pmCdZ+B9pglRGx3Mae7P8L1s1LeL8cQWo4QZ2nUcA5vtOiWfDAywlrN0mSNv
|
|
25
|
+
lfeE0/subU9kC04LRJ6NUhZp
|
|
26
|
+
=8lqK
|
|
27
|
+
-----END PGP SIGNATURE-----
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"creationTime": "2026-05-
|
|
2
|
+
"creationTime": "2026-05-29T14:45:42.000000",
|
|
3
3
|
"prefixes": [
|
|
4
4
|
{
|
|
5
5
|
"ipv6Prefix": "2001:4860:4801:2008::/64"
|
|
@@ -307,6 +307,9 @@
|
|
|
307
307
|
{
|
|
308
308
|
"ipv6Prefix": "2001:4860:4801:207d::/64"
|
|
309
309
|
},
|
|
310
|
+
{
|
|
311
|
+
"ipv6Prefix": "2001:4860:4801:207e::/64"
|
|
312
|
+
},
|
|
310
313
|
{
|
|
311
314
|
"ipv6Prefix": "2001:4860:4801:2080::/64"
|
|
312
315
|
},
|
|
@@ -790,6 +793,9 @@
|
|
|
790
793
|
{
|
|
791
794
|
"ipv4Prefix": "74.125.219.160/27"
|
|
792
795
|
},
|
|
796
|
+
{
|
|
797
|
+
"ipv4Prefix": "74.125.219.192/27"
|
|
798
|
+
},
|
|
793
799
|
{
|
|
794
800
|
"ipv4Prefix": "74.125.219.32/27"
|
|
795
801
|
},
|
|
@@ -369,7 +369,7 @@ class IMAPCommand {
|
|
|
369
369
|
countBadResponses() {
|
|
370
370
|
this.connection._badCount++;
|
|
371
371
|
if (this.connection._badCount > MAX_BAD_COMMANDS) {
|
|
372
|
-
this.clearNotificationListener();
|
|
372
|
+
this.connection.clearNotificationListener();
|
|
373
373
|
this.connection.send('* BYE Too many protocol errors');
|
|
374
374
|
setImmediate(() => this.connection.close(true));
|
|
375
375
|
return false;
|
|
@@ -210,6 +210,13 @@ class IMAPConnection extends EventEmitter {
|
|
|
210
210
|
this._socket.setTimeout(0, this._onTimeoutHandler);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
// After handoff to proxy mode the connection's own close/end handlers are gone,
|
|
214
|
+
// so _onClose can never run to remove this connection from the server set.
|
|
215
|
+
// Drop it from the set when the handed-off socket finally closes to avoid a leak.
|
|
216
|
+
this._socket.once('close', () => {
|
|
217
|
+
this._server.connections.delete(this);
|
|
218
|
+
});
|
|
219
|
+
|
|
213
220
|
return { socket: this._socket };
|
|
214
221
|
}
|
|
215
222
|
|
|
@@ -71,6 +71,30 @@ async function call(message, transferList) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// Resolve pending call() promises when the main thread answers. Without this any
|
|
75
|
+
// RPC issued from this worker (via the `call` passed into Account) would never settle
|
|
76
|
+
// and would reject on timeout. Mirrors the handlers in workers/imap.js and smtp.js.
|
|
77
|
+
parentPort.on('message', message => {
|
|
78
|
+
if (message && message.cmd === 'resp' && message.mid && callQueue.has(message.mid)) {
|
|
79
|
+
let { resolve, reject, timer } = callQueue.get(message.mid);
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
callQueue.delete(message.mid);
|
|
82
|
+
|
|
83
|
+
if (message.error) {
|
|
84
|
+
let err = new Error(message.error);
|
|
85
|
+
if (message.code) {
|
|
86
|
+
err.code = message.code;
|
|
87
|
+
}
|
|
88
|
+
if (message.statusCode) {
|
|
89
|
+
err.statusCode = message.statusCode;
|
|
90
|
+
}
|
|
91
|
+
return reject(err);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return resolve(message.response);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
74
98
|
async function metrics(logger, key, method, ...args) {
|
|
75
99
|
try {
|
|
76
100
|
parentPort.postMessage({
|
|
@@ -86,7 +110,7 @@ async function metrics(logger, key, method, ...args) {
|
|
|
86
110
|
|
|
87
111
|
const { ImapFlow } = require('imapflow');
|
|
88
112
|
const { IMAPServer, imapHandler } = require('./imap-core/index.js');
|
|
89
|
-
const { PassThrough } = require('
|
|
113
|
+
const { PassThrough } = require('stream');
|
|
90
114
|
|
|
91
115
|
const packageInfo = require('../../package.json');
|
|
92
116
|
const util = require('util');
|
|
@@ -113,7 +137,7 @@ class PassThroughLogger extends PassThrough {
|
|
|
113
137
|
data: chunk.toString('base64'),
|
|
114
138
|
compress: !!this.imapClient._deflate,
|
|
115
139
|
secure: !!this.imapClient.secureConnection,
|
|
116
|
-
cid: this.
|
|
140
|
+
cid: this.cid
|
|
117
141
|
});
|
|
118
142
|
}
|
|
119
143
|
|
|
@@ -361,7 +385,7 @@ const createServer = function (options = {}) {
|
|
|
361
385
|
message = util.format(message, ...args);
|
|
362
386
|
}
|
|
363
387
|
data.msg = message;
|
|
364
|
-
if (typeof
|
|
388
|
+
if (typeof serverLogger[level] === 'function') {
|
|
365
389
|
serverLogger[level](data);
|
|
366
390
|
} else {
|
|
367
391
|
serverLogger.debug(data);
|
|
@@ -408,39 +432,78 @@ const createServer = function (options = {}) {
|
|
|
408
432
|
logger: proxyLogger.child({ src: 'C' })
|
|
409
433
|
});
|
|
410
434
|
|
|
435
|
+
// Idempotent teardown for both legs of the proxy. ImapFlow.close() is
|
|
436
|
+
// safe after unbind(): it sends no LOGOUT, clears timers (including
|
|
437
|
+
// autoidle), removes the deflate/writeSocket error forwarders and
|
|
438
|
+
// destroys the upstream socket. Without it the upstream connection and
|
|
439
|
+
// its idle timer would leak (most visibly with COMPRESS enabled).
|
|
440
|
+
let proxyClosed = false;
|
|
441
|
+
const closeProxy = () => {
|
|
442
|
+
if (proxyClosed) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
proxyClosed = true;
|
|
446
|
+
|
|
447
|
+
try {
|
|
448
|
+
downstream.imapClient.close();
|
|
449
|
+
} catch (err) {
|
|
450
|
+
proxyLogger.error({ msg: 'Failed to close upstream connection', err });
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
try {
|
|
454
|
+
if (upstream.socket && !upstream.socket.destroyed) {
|
|
455
|
+
upstream.socket.end();
|
|
456
|
+
}
|
|
457
|
+
} catch (err) {
|
|
458
|
+
// ignore
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
// Every terminal event from either leg funnels into the idempotent
|
|
463
|
+
// closeProxy(). The helper keeps that wiring declarative; pass a message
|
|
464
|
+
// to log (level defaults to 'error', use 'info' for graceful closes).
|
|
465
|
+
const teardownOn = (emitter, event, msg, level = 'error') => {
|
|
466
|
+
emitter.on(event, err => {
|
|
467
|
+
if (msg) {
|
|
468
|
+
let entry = { msg };
|
|
469
|
+
if (err) {
|
|
470
|
+
entry.err = err;
|
|
471
|
+
}
|
|
472
|
+
proxyLogger[level](entry);
|
|
473
|
+
}
|
|
474
|
+
closeProxy();
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
|
|
411
478
|
downstream.readSocket.pipe(upstreamLogger).pipe(upstream.socket);
|
|
412
479
|
upstream.socket.pipe(downstreamLogger).pipe(downstream.writeSocket);
|
|
413
480
|
|
|
414
|
-
upstreamLogger
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
proxyLogger.error({ msg: 'Server error', err });
|
|
421
|
-
downstream.writeSocket.end();
|
|
422
|
-
downstream.readSocket.end();
|
|
423
|
-
});
|
|
481
|
+
teardownOn(upstreamLogger, 'error', 'Proxy stream error (to client)');
|
|
482
|
+
teardownOn(downstreamLogger, 'error', 'Proxy stream error (to upstream)');
|
|
483
|
+
teardownOn(upstream.socket, 'error', 'Client socket error');
|
|
484
|
+
teardownOn(upstream.socket, 'end', 'Client connection closed', 'info');
|
|
485
|
+
teardownOn(upstream.socket, 'close');
|
|
486
|
+
teardownOn(downstream.readSocket, 'end', 'Upstream connection closed', 'info');
|
|
424
487
|
|
|
425
488
|
downstream.readSocket.on('error', err => {
|
|
426
|
-
proxyLogger.error({ msg: '
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
489
|
+
proxyLogger.error({ msg: 'Upstream read error', err });
|
|
490
|
+
try {
|
|
491
|
+
// best-effort notice to the client before tearing down
|
|
492
|
+
upstream.socket.write('* BYE Upstream connection error\r\n');
|
|
493
|
+
} catch (e) {
|
|
494
|
+
// ignore
|
|
495
|
+
}
|
|
496
|
+
closeProxy();
|
|
433
497
|
});
|
|
434
498
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
});
|
|
499
|
+
// With COMPRESS enabled, readSocket/writeSocket are the inflate/deflate
|
|
500
|
+
// streams, not the raw upstream socket, and unbind() removed ImapFlow's
|
|
501
|
+
// own listeners from that socket. An upstream reset would then emit an
|
|
502
|
+
// 'error' with no listener and crash the worker - guard it explicitly.
|
|
503
|
+
if (downstream.imapClient.socket && downstream.imapClient.socket !== downstream.readSocket) {
|
|
504
|
+
teardownOn(downstream.imapClient.socket, 'error', 'Upstream socket error');
|
|
505
|
+
teardownOn(downstream.imapClient.socket, 'close');
|
|
506
|
+
}
|
|
444
507
|
|
|
445
508
|
proxyLogger.info({ msg: 'Proxy mode enabled' });
|
|
446
509
|
};
|
package/lib/tools.js
CHANGED
|
@@ -1571,6 +1571,11 @@ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV3QUiYsp13nD9suD1/ZkEXnuMoSg
|
|
|
1571
1571
|
|
|
1572
1572
|
mergeObjects(destination, source) {
|
|
1573
1573
|
for (let propKey of Object.keys(source)) {
|
|
1574
|
+
// Guard against prototype pollution from crafted keys in parsed JSON
|
|
1575
|
+
if (propKey === '__proto__' || propKey === 'constructor' || propKey === 'prototype') {
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1574
1579
|
let sourceVal = source[propKey];
|
|
1575
1580
|
|
|
1576
1581
|
if (typeof destination[propKey] === 'undefined') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailengine-app",
|
|
3
|
-
"version": "2.68.
|
|
3
|
+
"version": "2.68.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"productTitle": "EmailEngine",
|
|
6
6
|
"description": "Email Sync Engine",
|
|
@@ -59,18 +59,18 @@
|
|
|
59
59
|
"@postalsys/bounce-classifier": "3.0.0",
|
|
60
60
|
"@postalsys/certs": "1.0.14",
|
|
61
61
|
"@postalsys/ee-client": "1.3.0",
|
|
62
|
-
"@postalsys/email-ai-tools": "1.13.
|
|
63
|
-
"@postalsys/email-text-tools": "2.4.
|
|
62
|
+
"@postalsys/email-ai-tools": "1.13.5",
|
|
63
|
+
"@postalsys/email-text-tools": "2.4.6",
|
|
64
64
|
"@postalsys/gettext": "4.1.1",
|
|
65
65
|
"@postalsys/joi-messages": "1.0.5",
|
|
66
66
|
"@postalsys/templates": "2.0.1",
|
|
67
67
|
"@simplewebauthn/browser": "13.3.0",
|
|
68
|
-
"@simplewebauthn/server": "13.3.
|
|
69
|
-
"@zone-eu/mailsplit": "5.4.
|
|
68
|
+
"@simplewebauthn/server": "13.3.1",
|
|
69
|
+
"@zone-eu/mailsplit": "5.4.12",
|
|
70
70
|
"@zone-eu/wild-config": "1.7.5",
|
|
71
71
|
"ace-builds": "1.44.0",
|
|
72
72
|
"base32.js": "0.1.0",
|
|
73
|
-
"bullmq": "5.77.
|
|
73
|
+
"bullmq": "5.77.7",
|
|
74
74
|
"compare-versions": "6.1.1",
|
|
75
75
|
"dotenv": "17.4.2",
|
|
76
76
|
"encoding-japanese": "2.2.0",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"html-to-text": "10.0.0",
|
|
85
85
|
"ical.js": "1.5.0",
|
|
86
86
|
"iconv-lite": "0.7.2",
|
|
87
|
-
"imapflow": "1.3.
|
|
87
|
+
"imapflow": "1.3.5",
|
|
88
88
|
"ioredfour": "1.4.1",
|
|
89
|
-
"ioredis": "5.
|
|
89
|
+
"ioredis": "5.11.0",
|
|
90
90
|
"ipaddr.js": "2.4.0",
|
|
91
91
|
"joi": "17.13.3",
|
|
92
92
|
"jquery": "4.0.0",
|
|
@@ -94,21 +94,21 @@
|
|
|
94
94
|
"libmime": "5.3.8",
|
|
95
95
|
"libqp": "2.1.1",
|
|
96
96
|
"license-checker": "25.0.1",
|
|
97
|
-
"mailparser": "3.9.
|
|
97
|
+
"mailparser": "3.9.9",
|
|
98
98
|
"marked": "9.1.6",
|
|
99
99
|
"minimist": "1.2.8",
|
|
100
100
|
"msgpack5": "6.0.2",
|
|
101
101
|
"murmurhash": "2.0.1",
|
|
102
102
|
"nanoid": "3.3.8",
|
|
103
|
-
"nodemailer": "8.0.
|
|
103
|
+
"nodemailer": "8.0.10",
|
|
104
104
|
"pino": "10.3.1",
|
|
105
105
|
"popper.js": "1.16.1",
|
|
106
106
|
"prom-client": "15.1.3",
|
|
107
107
|
"psl": "1.15.0",
|
|
108
|
-
"pubface": "1.1.
|
|
108
|
+
"pubface": "1.1.2",
|
|
109
109
|
"punycode.js": "2.3.1",
|
|
110
110
|
"qrcode": "1.5.4",
|
|
111
|
-
"smtp-server": "3.18.
|
|
111
|
+
"smtp-server": "3.18.5",
|
|
112
112
|
"socks": "2.8.9",
|
|
113
113
|
"speakeasy": "2.0.0",
|
|
114
114
|
"startbootstrap-sb-admin-2": "3.3.7",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@eslint/js": "10.0.1",
|
|
121
121
|
"chai": "4.3.10",
|
|
122
122
|
"eerawlog": "1.5.3",
|
|
123
|
-
"eslint": "10.4.
|
|
123
|
+
"eslint": "10.4.1",
|
|
124
124
|
"grunt": "1.6.2",
|
|
125
125
|
"grunt-cli": "1.5.0",
|
|
126
126
|
"grunt-shell-spawn": "0.5.0",
|