fix(email): trust configured authentication results

This commit is contained in:
Xubin Ren committed 2026-09-15 15:26:20 +08:00
1 parent 8c4eb2c807
commit 0282dbac07
20 files changed
+805 -29

No files matched your search

+8
View File
@@ -767,6 +767,13 @@ Give nanobot its own email account. It polls **IMAP** for incoming mail and repl
> - `consentGranted` must be `true` to allow mailbox access. This is a safety gate — set `false` to fully disable.
> - `allowFrom`: Add your email address. Use `["*"]` to accept emails from anyone.
> - `trustedAuthservIds`: Exact `authserv-id` values added by the receiving mail
> service. Required while `verifyDkim` or `verifySpf` is enabled. Gmail normally
> uses `mx.google.com`; inspect a received message's raw headers for other services.
> The service must prepend one consolidated result and remove inbound headers that
> claim the same identity; duplicate trusted results are rejected.
> Existing installations must follow the [v0.3.5 upgrade instructions](guides/email-ai-agent.md#upgrading-to-v035)
> before re-enabling verified email polling.
> - `smtpUseTls` and `smtpUseSsl` default to `true` / `false` respectively, which is correct for Gmail (port 587 + STARTTLS). No need to set them explicitly.
> - Set `"autoReplyEnabled": false` if you only want to read/analyze emails without sending automatic replies.
> - `postAction`: Optional post-processing for processed emails: `"delete"` or `"move"` (default `null`).
@@ -794,6 +801,7 @@ Give nanobot its own email account. It polls **IMAP** for incoming mail and repl
"smtpPassword": "your-app-password",
"fromAddress": "my-nanobot@gmail.com",
"allowFrom": ["your-real-email@gmail.com"],
"trustedAuthservIds": ["mx.google.com"],
"postAction": "move",
"postActionMoveMailbox": "[Gmail]/Trash",
"postActionIgnoreSkipped": true,
+60
View File
@@ -50,6 +50,7 @@ passwords:
"smtpPassword": "your-app-password",
"fromAddress": "my-nanobot@gmail.com",
"allowFrom": ["your-real-email@gmail.com"],
"trustedAuthservIds": ["mx.google.com"],
"autoReplyEnabled": true
}
}
@@ -74,12 +75,71 @@ gateway running long enough for the polling interval to receive it.
- Set `consentGranted` to `false` to fully disable mailbox access.
- Email does not use DM pairing. Keep `allowFrom` narrow; `["*"]` accepts mail
from anyone.
- Keep SPF/DKIM verification enabled and set `trustedAuthservIds` to the exact
`authserv-id` added by your receiving mail service. For Gmail this is normally
`mx.google.com`. The service must prepend one consolidated
`Authentication-Results` header and remove inbound headers claiming the same
identity. nanobot rejects authenticated email when this trust anchor is missing
or appears more than once.
- Use environment variables for mailbox passwords.
- Enable attachment types only when the agent needs them.
## Upgrading to v0.3.5
Email authentication now requires an explicit receiving-service trust anchor.
This is a security-related configuration change: an existing email channel with
`verifySpf` or `verifyDkim` enabled will not start without `trustedAuthservIds`.
Other channels, mailbox credentials, stored messages, and `allowFrom` do not need
to be migrated. Existing values are not automatically rewritten.
1. Back up your configuration and temporarily disable the Email channel while
configuring the receiver. Do not turn off SPF/DKIM verification as an upgrade
workaround.
2. Confirm with your receiving mail service or administrator which exact
`authserv-id` it adds, and that it strips externally supplied headers claiming
that identity. It must provide one consolidated `Authentication-Results`
header. A name visible in a received email is not, by itself, proof of trust;
do not infer it from your IMAP hostname or copy it from an arbitrary message.
3. In Email settings, open **Advanced** and set **Trusted authentication services**,
or merge the following fields into `channels.email` in your existing config:
```json
{
"verifySpf": true,
"verifyDkim": true,
"trustedAuthservIds": ["mx.google.com"]
}
```
The example is for a receiver using `mx.google.com`; use your confirmed
receiver identity instead. JSON uses a list; the WebUI accepts comma-separated
values. Wildcards and URLs are not accepted. Multiple configured identities
are alternatives, not permission to combine multiple trusted result headers.
4. Check the IMAP/SMTP connection, re-enable Email, and restart the gateway after
editing a configuration file. Send one ordinary message from an allowed
address and confirm receipt and reply. A successful connection check verifies
credentials and configuration, not your mail service's header-stripping policy.
Each enabled verification method must pass and identify the visible sender's
domain, or a parent/subdomain of it. DKIM uses `header.d` when present, otherwise
the domain of the receiver-reported `header.i`. This is not a full DMARC policy
implementation, and domain authentication does not independently authenticate
the mailbox local part. Forwarders, mailing lists, or receivers that emit separate
SPF and DKIM result headers may need mail-service changes. Keep Email disabled
if the receiver cannot meet the trust contract.
Authentication failures remain skipped messages. Keep the default
`postActionIgnoreSkipped: true` while checking the migration; setting it to
`false` allows your configured move/delete action to affect skipped mail too.
If the migration cannot be completed, disable Email rather than reverting to an
older authentication policy.
## Troubleshooting
- If login fails, confirm IMAP/SMTP access and app-password setup.
- If Email will not start and reports `trusted_authserv_ids` as missing, complete
the upgrade steps above. A configured receiver still needs to emit compatible,
aligned authentication results for each enabled verification method.
- If the bot reads but does not reply, check `autoReplyEnabled`, SMTP settings,
and allowed sender addresses.
- If attachments are missing, review `allowedAttachmentTypes`, size limits, and