Security and sender trust
Inbound risk assessment, reason codes, the checks of attachments and links in both directions, sender standings, security policies and presets, held mail, outbound send guards, rule conditions and policy previews.
On this page
- Defense in depth for agent mail
- How inbound mail is rated
- Attachments and links
- Reason catalogue
- Sender standing and sender rules
- Security policy, presets and enforcement modes
- Held mail, release, discard and feedback
- Outbound guards and who may loosen protection
- Sends that wait for the owner
- Policy preview and rule conditions
- Security error codes
Defense in depth for agent mail
Anyone can send mail to an inbox, while the agent reading it holds private data and can send mail back. Prompt advice and text fences help, yet no filter catches every prompt injection or social-engineering lure. Doorman pairs inbound risk scoring and held-mail quarantine with sender standing and outbound send guards so that even if an instruction slips past detection, what an agent can reply to or where it can write remains bounded.
Every assessed inbound message carries a RiskAssessment on Message.risk and on the message.received payload, and each Thread carries riskLevel, the highest level among its inbound messages that the owner has not marked safe.
{
"score": 6,
"level": "low",
"labels": [],
"reasons": [],
"sender": {
"standing": "known",
"authenticated": true
},
"action": "delivered",
"analysis": "full",
"review": null
}How inbound mail is rated
Before a message is committed to storage, Doorman evaluates it in two bounded layers and produces a score from 0 to 100, a level (low from 0, medium from 30, high from 60, critical from 85), labels (prompt_injection, phishing, scam, impersonation, spam, malware), strongest-first reasons (at most 12), and analysis (signals or full).
- Layer 1: deterministic signals
- Always runs. Inspects sender authentication (DMARC, SPF, DKIM), Reply-To and envelope alignment, display-name and look-alike domain impersonation, trusted senders without authentication, senders whose mail stopped authenticating, HTML/CSS hidden text, plain-versus-HTML divergence, invisible or direction-changing characters, mixed-script homographs, encoded text blocks, forged fence or role markers, link target mismatches and links a reader would not see, the bytes of every attachment (below), extracted attachment text, agent-directed instructions, and phishing, scam and bulk spam markers.
- Layer 2: bounded model judge
- Runs through the deployment's AI gateway when configured (
modelAnalysisAvailable: true) and enabled on the account (modelAnalysis: true, the default), within a few seconds and a per-account daily budget. It is skipped when Layer 1 already scored critical, or when the sender is trusted, DMARC-authenticated and unflagged with no structural or injection signals. Because the judge reads untrusted mail too, its verdict can raise a score and never lower what Layer 1 found. - Fail-safe
- Assessing never drops mail. If an assessment cannot finish, an observing deployment stores the message with
risk: null, and an enforcing deployment rates ithigh(assessment_failed) so the policy warns about or holds it for human review.
Attachments and links
An attachment is judged by its bytes, whatever it is called, in both directions. Every Attachment of assessed mail carries a scan (AttachmentScan): a status (clean, suspicious, malicious, unscanned), the sha256 of the bytes, the detectedType and the findings as reason codes.
{
"status": "clean",
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"detectedType": "pdf",
"findings": []
}clean- Nothing known to be dangerous was found. It is not a guarantee.
suspicious- The file carries something that can act when it is opened, such as macros or script (
macro_document,active_document). malicious- A program dressed as another kind of file, an archive built to exhaust whoever unpacks it, or a file the malware engine knows (
executable_content,type_mismatch,archive_bomb,malware_detected). A key or an app token cannot download it, and its text is never extracted. unscanned- The file is locked or damaged, so what is inside could not be read (
encrypted_archive,corrupt_attachment).
scan is absent on mail stored before the check existed and where the deployment does not assess mail. Absent means not checked, never clean.
Two further checks run where a deployment has them (SecuritySettings.deepScanAvailable) and the policy leaves them on:
- The malware engine (
deepScan) - Every attachment, inbound and outbound, goes to a signature engine in an isolated scanner of the same deployment. The bytes are not kept and go to no third party.
- The link sandbox (
linkSandbox) - The most suspect links of a message, at most 5, are opened in an isolated browser that loads the page and does nothing else. What it saw becomes reason codes:
link_malicious,link_download,link_credential_page,link_redirect_chain. A link is opened only when something about it or its sender is suspect (a shortener, a look-alike name, text that names another site, a link a reader would not see, an unauthenticated or new sender). What the sandbox saw of a link is reused for 6 hours.
In enforce mode, a message that needs the engine or the sandbox waits before it is delivered: it is stored where no key or app token can read it, with no event, and message.received (or message.held) fires once with the final assessment. That usually takes seconds. No new attempt starts 3 minutes after arrival: the message is then finished without the answer and carries scan_incomplete. In observe mode nothing waits; the message is delivered at once and the result is added to its risk and its attachments afterwards, with no second event.
What could not be checked, an encrypted_archive or a scan_incomplete, gets at least what the policy's unscannable says: deliver, warn, hold.
Reason catalogue
Every code in risk.reasons comes from RISK_REASONS in @doorman/inbox-api and is also published as data under x-doorman-risk-reasons in https://api.doorman.fyi/openapi.json, so clients in any language can render the plain-language explanation without copying strings.
| Code | Family | Label | Meaning |
|---|---|---|---|
dmarc_fail | identity | impersonation | The message failed the check the sender's own domain publishes for its mail. |
spf_fail | identity | score only | The server that sent the message is not one the sender's domain allows. |
dkim_fail | identity | score only | The message's signature did not match its content. |
auth_missing | identity | score only | Nothing proves the message comes from the domain it names. |
reply_to_mismatch | identity | phishing | A reply would go to a different domain than the one the message says it is from. |
envelope_mismatch | identity | score only | The address the message was sent from is not the one it shows. |
display_name_address | identity | impersonation | The sender's name is written to look like a different email address. |
display_name_impersonation | identity | impersonation | The sender uses the name of someone this address knows, from a different address. |
lookalike_domain | identity | impersonation | The sender's domain imitates one this address trusts. |
trusted_sender_unauthenticated | identity | impersonation | The message claims to be from a trusted sender, but nothing proves it. |
self_spoof | identity | impersonation | The message claims to come from this address or its own domain, without proof. |
sender_authentication_dropped | identity | impersonation | Earlier mail from this sender proved where it came from, and this message does not. |
first_time_sender | identity | score only | This address has never heard from this sender before. |
hidden_text | structure | prompt_injection | The message carries text a person reading it would not see. |
text_html_mismatch | structure | prompt_injection | The plain version and the formatted version of the message say different things. |
invisible_characters | structure | prompt_injection | The message uses invisible or direction-changing characters. |
mixed_script | structure | phishing | Words in the message mix alphabets to look like other words. |
fence_forgery | structure | prompt_injection | The message imitates the markers that separate mail from an agent's own instructions. |
role_tags | structure | prompt_injection | The message imitates instructions from a system or an assistant. |
encoded_payload | structure | score only | The message carries a block of encoded text. |
instruction_override | injection | prompt_injection | The message tells its reader to ignore or replace the instructions it was given. |
role_reassignment | injection | prompt_injection | The message tries to give its reader a new role. |
system_prompt_probe | injection | prompt_injection | The message asks its reader to reveal its instructions or its setup. |
tool_request | injection | prompt_injection | The message asks its reader to act by itself: to forward, send, delete or run something. |
exfiltration_request | injection | prompt_injection | The message asks for other mail, passwords or private data to be sent out. |
secrecy_request | injection | prompt_injection | The message asks its reader to hide what it does from the person it works for. |
addresses_ai | injection | score only | The message speaks to an AI assistant, not to a person. |
credential_request | deception | phishing | The message asks for a password, a code or sign-in details. |
payment_request | deception | scam | The message asks for a payment, a transfer or a change of payment details. |
urgency_pressure | deception | score only | The message presses for action right away. |
link_mismatch | deception | phishing | A link shows one destination and leads to another. |
suspicious_link | deception | phishing | A link hides where it leads, behind a shortener, a bare number or a look-alike name. |
risky_attachment | deception | malware | An attachment is of a kind often used to carry harmful software. |
attachment_disguise | deception | malware | An attachment's name hides what it really is. |
executable_content | deception | malware | An attachment is a program, or carries one. |
type_mismatch | deception | malware | An attachment is not the kind of file its name or its type says it is. |
macro_document | deception | malware | An attached document carries macros, which run when it is opened. |
active_document | deception | malware | An attached document carries script or a form that acts when it is opened. |
archive_bomb | deception | malware | An attached archive is built to unpack into far more data than it holds. |
encrypted_archive | deception | score only | An attachment is locked with a password, so what is inside could not be checked. |
corrupt_attachment | deception | score only | An attachment is empty, cut short or damaged. |
hidden_link | deception | phishing | The message carries a link a person reading it would not see. |
malware_detected | deception | malware | An attachment matches known harmful software. |
link_malicious | deception | malware | A link was opened in isolation and delivered known harmful software. |
link_download | deception | malware | A link was opened in isolation and started a download by itself. |
link_credential_page | deception | phishing | A link was opened in isolation and led to a page that asks for a password, on a site that is not the sender's. |
link_redirect_chain | deception | phishing | A link was opened in isolation and passed through other sites to end somewhere it did not name. |
spam_flagged | bulk | spam | A mail system on the way marked the message as junk. |
bulk_unsolicited | bulk | spam | The message is bulk mail from a sender this address has no history with. |
model_injection | analysis | prompt_injection | Reading the content, Doorman judged it an attempt to instruct an AI agent. |
model_phishing | analysis | phishing | Reading the content, Doorman judged it an attempt to steal sign-in details or data. |
model_scam | analysis | scam | Reading the content, Doorman judged it an attempt to obtain money or goods by deceit. |
model_impersonation | analysis | impersonation | Reading the content, Doorman judged that the sender pretends to be someone else. |
model_spam | analysis | spam | Reading the content, Doorman judged it junk mail. |
scan_incomplete | analysis | score only | The check of this message's attachments or links could not be finished, so it was delivered without it. |
assessment_failed | analysis | score only | Doorman could not finish checking this message, so it is treated with caution. |
protected_information | analysis | score only | The message carries information that this account's healthcare guardrails hold for a person to look at first. |
Sender standing and sender rules
Each inbox remembers who writes to it and who it writes to (GET /v1/inboxes/{inboxId}/senders). A sender's standing is one of trusted, known, new, blocked:
trusted- Set by an owner rule (
POST /v1/sender-rules) for an email address or a domain, across the account or for one inbox. Lowers non-structural risk and lifts the reply guard only when the message passes DMARC; an unauthenticated message claiming a trusted address is flagged as impersonation. The shared inbox domain cannot be trusted as a whole. known- Earned automatically per inbox once the inbox sends a message to the address (excluding rule-generated mail), or once the sender delivers 3 DMARC-passing messages spanning at least 7 days with zero flags. Any warning, hold or
unsafefeedback revokesknown. new- Every other sender.
blocked- Set by an owner rule for an address or domain. In
enforcemode, mail from a blocked sender is refused at SMTP on the shared domain and dropped on custom domains.
An inbox's own rule overrides an account-wide rule, and an address rule overrides a domain rule. An account holds up to 2,000 rules (GET /v1/sender-rules, DELETE /v1/sender-rules/{senderRuleId}).
Security policy, presets and enforcement modes
A SecurityPolicy resolves from the inbox override (GET /v1/inboxes/{inboxId}/security, PATCH, DELETE) to the account policy (GET /v1/security, PATCH). New accounts start on balanced; accounts created before risk assessment were seeded on relaxed.
| Preset | Warn at | Hold at | Hold unauthenticated new senders | Reply guard | Recipients | Unscannable |
|---|---|---|---|---|---|---|
relaxed | 60 | never | no | off | any | deliver |
balanced | 60 | 85 | no | on | any | warn |
strict | 30 | 60 | yes | on | known | hold |
Per-label minimums (labels, mapping any RiskLabel to warn or hold) can raise the action for specific threat types regardless of score, and a policy whose fields depart from the three presets reports level: "custom".
modelAnalysis, deepScan and linkSandbox are on by default and belong to no preset: applying a level leaves them as they are, and switching one off does not make a policy custom. SecuritySettings says what the deployment can do with them: modelAnalysisAvailable and deepScanAvailable.
SecuritySettings.enforcement reports what the deployment does with assessments: observe scores mail and records risk and spamScore while delivering everything and enforcing no guards; enforce applies warnings, holds, blocked-sender refusals and outbound send guards; off disables assessment and sender tracking.
curl -s -X PATCH "https://api.doorman.fyi/v1/inboxes/inb_01jc4q7w9k2m5n8p3r6t1v4x7z/security" \
-H "authorization: Bearer $DOORMAN_API_KEY" \
-H "content-type: application/json" \
-d '{
"level": "strict"
}'Held mail, release, discard and feedback
When an enforcing policy holds a message, Doorman stores it in an isolated held thread invisible to API keys and app tokens on message, thread and attachment routes, and emits a content-free message.held event carrying only who sent it, when, and the RiskAssessment.
GET /v1/inboxes/{inboxId}/heldlists held stubs (delegated tomail:readso agents can see that mail is waiting and ask their user;subjectisnullfor keys, app tokens and organization members withoutsecurity:manage, and included for callers that may review held mail).- A console session that may review held mail (
security:manageandmail:readin an organization) can inspect a held message in full viaGET /v1/messages/{messageId}, then deliver it withPOST /v1/messages/{messageId}/release(which threads it at release time and emitsmessage.receivedwithrisk.action: "released") or trash it permanently withPOST /v1/messages/{messageId}/discard. POST /v1/messages/{messageId}/feedbackrecords{ "verdict": "safe" | "unsafe" }on a delivered inbound message.safelifts the reply guard, removes the message from its thread'sriskLeveland withdraws the flag on its sender;unsafeflags the sender and disables automatic replies. The original score stays unchanged.
When a flagged (warned, released, or unsafe) message reaches an agent through @doorman/inbox-mcp or @doorman/inbox-agent, Doorman places riskWarning(risk) outside and ahead of the untrusted-content fence so the warning is read as trusted platform guidance rather than sender text.
Outbound guards and who may loosen protection
In enforce mode, POST /v1/inboxes/{inboxId}/send checks three outbound guards and answers 403 risk_blocked with guard naming which one stopped the send. The first two apply to every caller that is not a console session:
guard: "reply"replyGuardis on and the target thread contains any inbound message that the current policy warns about or holds (or that the owner markedunsafe), unless the owner marked that messagesafeor its sender istrustedand the message passed DMARC. A harmless follow-up in the same thread does not clear the guard.guard: "recipient"recipientsisknown(thestrictpreset) and ato,ccorbccaddress is neithertrusted,known, nor one of the account's own active inboxes. Nothing inside an inbound message (notFrom,Reply-ToorCc) widens this list: under Strict, an agent only writes to people the owner trusts or has already written to.guard: "content"- Checked for every caller, a console session included. An attachment did not pass the check of its bytes, or a link delivered harmful software or a program when it was opened in isolation;
reasonslists the codes. A program, a file dressed as another kind and a file the malware engine knows are refused for everyone. A locked or damaged file, and a file that carries a program or macros, are refused for keys and app tokens only: a person can send those from the console.
Where the deployment runs the malware engine and it does not answer in time, a send with an attachment answers 503 scan_unavailable with Retry-After and nothing is sent: an unchecked file is never sent as if it had been checked. Send again with the same Idempotency-Key. A link sandbox that does not answer does not stop a send.
The same bound applies to reading: whatever the policy, GET /v1/attachments/{messageId}/{filename}, its text route and the raw message answer 403 risk_blocked with guard: "content" to a key or an app token when an attachment is malicious.
Because an injected agent holds an API key or app token, loosening protection (lowering thresholds, turning off a guard, switching off modelAnalysis, deepScan or linkSandbox, moving unscannable towards deliver, trusting a sender, deleting a block rule, releasing held mail, or marking a message safe) requires a console session and answers 403 session_required to API keys unless the owner explicitly enables allowKeyManagement on the account policy. Tightening protection, blocking senders, marking mail unsafe and discarding held mail remain open to account keys. Every change is recorded without mail content in GET /v1/security/audit.
Sends that wait for the owner
The guards refuse a send. sendApproval does something else with it: the message is kept, and the owner sends it or discards it. It is a field of the security policy with three values: off, apps (a connected app's sends) and all (an app's and an API key's). An account that never chose starts on apps; accounts that existed before held sends were set to off. No preset changes it, and a console session is never held.
Where it applies, POST /v1/inboxes/{inboxId}/send with any to, cc or bcc address that is neither trusted, known, nor one of the account's own active inboxes answers 202 with a HeldSend instead of 201 with the sent message. Nothing was sent, counted against a limit or stored as mail. The same request with the same Idempotency-Key replays the same 202. Unlike the guards, this does not wait for enforce: it applies in observe too, and only a deployment whose mode is off, which keeps no record of senders, holds nothing.
- Who is known
- A sender the inbox has written to, or one that sent authenticated mail over time, without a flag against them. Having written to the inbox once does not make someone known, so a connected app's first reply to a new correspondent waits. Sending a held send makes its recipients known, unless their own mail was flagged: then the owner trusts them with a sender rule first.
- What the caller sees
- Who it is to,
unknownRecipients,requestedByandstatus.GET /v1/held-sends/{heldSendId}says where it stands later:held,sent,discardedorexpired. The subject and the text are null for every caller that may not decide. - Who decides
POST /v1/held-sends/{heldSendId}/approvesends it as it was asked for, with the limits, the plan and the thread checked at that moment, and answers the sent message. It needs a console session, or an account key where the account setallowKeyManagement.POST /v1/held-sends/{heldSendId}/discardends it unsent and is open to account keys. No app token can do either.- Limits
- An inbox has at most 50 sends waiting (
409 limit_reachedbeyond that), and one that nobody decides expires unsent after 7 days. - Events
send.heldwhen a message starts to wait andsend.discardedwhen it ends unsent, both without the subject or the body. A held send the owner sends emitsmessage.sent.
A held send is an answer, not an error: a program that reads id from the answer of a send must check which of the two it was given. The TypeScript client has isHeldSend(result) for that, and the MCP server puts a note ahead of the answer that tells a model the message was not sent and must not be sent again.
Policy preview and rule conditions
POST /v1/security/preview evaluates a built-in sample (ordinary, phishing, prompt_injection, impersonation), a stored inbound messageId, or custom text / html against the active policy or a draft policy overlay without storing, sending or charging anything, returning { risk, refused, agentView, enforcement }.
curl -s -X POST "https://api.doorman.fyi/v1/security/preview" \
-H "authorization: Bearer $DOORMAN_API_KEY" \
-H "content-type: application/json" \
-d '{
"sample": "prompt_injection",
"policy": {
"level": "strict"
}
}'Durable inbound rules also accept minRiskLevel (low, medium, high, critical) and senderStanding (trusted, known, new, blocked) in RuleWhen, so workflows can label or route flagged mail while automatic replies remain blocked on any message whose autoReplyable is false.
Security error codes
| Status | Error | Meaning |
|---|---|---|
| 403 | risk_blocked | The send or the download was refused; guard says why: reply when the thread holds a flagged message whose sender is not trusted, recipient when a recipient is not one the inbox knows, content when an attachment did not pass the check of its bytes (reasons lists what was found), guardrail when a healthcare guardrail found what may not be sent (entities lists the kinds). For reply and recipient a person can send from the console, mark the message safe or trust the sender. For content, a program or a file dressed as another kind is refused for every caller; a locked or damaged file, a script, or a document with macros, is refused for keys and app tokens only. A link that delivered harmful software when it was opened in isolation is refused for every caller. |
| 503 | scan_unavailable | The malware engine did not answer in time, so an attachment could not be checked and nothing was sent. Try again after Retry-After; an Idempotency-Key makes the retry safe. |
| 403 | session_required | Account keys, developer apps, relying parties, installations, consent, approving a sign-in and the assistant require a console session. So does loosening the security policy, trusting a sender, releasing held mail, allowing a sign-in, letting agents sign in to new services alone or telling a service who owns an agent, unless the account allows its account keys to. |
| 403 | forbidden | The key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data. |
| 409 | limit_reached | The abuse ceiling for inboxes, custom domains, keys, endpoints, services, relying parties, the services an address signs in to, the sends an inbox has waiting for its owner or the invitations an organization has open; delete, revoke or decide one first. |
| 400 | validation_error | A field is missing or invalid; the message names it. |
| 404 | not_found | No such resource for this caller, or no such route. |

