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
  1. Defense in depth for agent mail
  2. How inbound mail is rated
  3. Attachments and links
  4. Reason catalogue
  5. Sender standing and sender rules
  6. Security policy, presets and enforcement modes
  7. Held mail, release, discard and feedback
  8. Outbound guards and who may loosen protection
  9. Sends that wait for the owner
  10. Policy preview and rule conditions
  11. 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.

A risk assessment

{
  "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 it high (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.

The check of an attachment

{
  "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.

CodeFamilyLabelMeaning
dmarc_failidentityimpersonationThe message failed the check the sender's own domain publishes for its mail.
spf_failidentityscore onlyThe server that sent the message is not one the sender's domain allows.
dkim_failidentityscore onlyThe message's signature did not match its content.
auth_missingidentityscore onlyNothing proves the message comes from the domain it names.
reply_to_mismatchidentityphishingA reply would go to a different domain than the one the message says it is from.
envelope_mismatchidentityscore onlyThe address the message was sent from is not the one it shows.
display_name_addressidentityimpersonationThe sender's name is written to look like a different email address.
display_name_impersonationidentityimpersonationThe sender uses the name of someone this address knows, from a different address.
lookalike_domainidentityimpersonationThe sender's domain imitates one this address trusts.
trusted_sender_unauthenticatedidentityimpersonationThe message claims to be from a trusted sender, but nothing proves it.
self_spoofidentityimpersonationThe message claims to come from this address or its own domain, without proof.
sender_authentication_droppedidentityimpersonationEarlier mail from this sender proved where it came from, and this message does not.
first_time_senderidentityscore onlyThis address has never heard from this sender before.
hidden_textstructureprompt_injectionThe message carries text a person reading it would not see.
text_html_mismatchstructureprompt_injectionThe plain version and the formatted version of the message say different things.
invisible_charactersstructureprompt_injectionThe message uses invisible or direction-changing characters.
mixed_scriptstructurephishingWords in the message mix alphabets to look like other words.
fence_forgerystructureprompt_injectionThe message imitates the markers that separate mail from an agent's own instructions.
role_tagsstructureprompt_injectionThe message imitates instructions from a system or an assistant.
encoded_payloadstructurescore onlyThe message carries a block of encoded text.
instruction_overrideinjectionprompt_injectionThe message tells its reader to ignore or replace the instructions it was given.
role_reassignmentinjectionprompt_injectionThe message tries to give its reader a new role.
system_prompt_probeinjectionprompt_injectionThe message asks its reader to reveal its instructions or its setup.
tool_requestinjectionprompt_injectionThe message asks its reader to act by itself: to forward, send, delete or run something.
exfiltration_requestinjectionprompt_injectionThe message asks for other mail, passwords or private data to be sent out.
secrecy_requestinjectionprompt_injectionThe message asks its reader to hide what it does from the person it works for.
addresses_aiinjectionscore onlyThe message speaks to an AI assistant, not to a person.
credential_requestdeceptionphishingThe message asks for a password, a code or sign-in details.
payment_requestdeceptionscamThe message asks for a payment, a transfer or a change of payment details.
urgency_pressuredeceptionscore onlyThe message presses for action right away.
link_mismatchdeceptionphishingA link shows one destination and leads to another.
suspicious_linkdeceptionphishingA link hides where it leads, behind a shortener, a bare number or a look-alike name.
risky_attachmentdeceptionmalwareAn attachment is of a kind often used to carry harmful software.
attachment_disguisedeceptionmalwareAn attachment's name hides what it really is.
executable_contentdeceptionmalwareAn attachment is a program, or carries one.
type_mismatchdeceptionmalwareAn attachment is not the kind of file its name or its type says it is.
macro_documentdeceptionmalwareAn attached document carries macros, which run when it is opened.
active_documentdeceptionmalwareAn attached document carries script or a form that acts when it is opened.
archive_bombdeceptionmalwareAn attached archive is built to unpack into far more data than it holds.
encrypted_archivedeceptionscore onlyAn attachment is locked with a password, so what is inside could not be checked.
corrupt_attachmentdeceptionscore onlyAn attachment is empty, cut short or damaged.
hidden_linkdeceptionphishingThe message carries a link a person reading it would not see.
malware_detecteddeceptionmalwareAn attachment matches known harmful software.
link_maliciousdeceptionmalwareA link was opened in isolation and delivered known harmful software.
link_downloaddeceptionmalwareA link was opened in isolation and started a download by itself.
link_credential_pagedeceptionphishingA 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_chaindeceptionphishingA link was opened in isolation and passed through other sites to end somewhere it did not name.
spam_flaggedbulkspamA mail system on the way marked the message as junk.
bulk_unsolicitedbulkspamThe message is bulk mail from a sender this address has no history with.
model_injectionanalysisprompt_injectionReading the content, Doorman judged it an attempt to instruct an AI agent.
model_phishinganalysisphishingReading the content, Doorman judged it an attempt to steal sign-in details or data.
model_scamanalysisscamReading the content, Doorman judged it an attempt to obtain money or goods by deceit.
model_impersonationanalysisimpersonationReading the content, Doorman judged that the sender pretends to be someone else.
model_spamanalysisspamReading the content, Doorman judged it junk mail.
scan_incompleteanalysisscore onlyThe check of this message's attachments or links could not be finished, so it was delivered without it.
assessment_failedanalysisscore onlyDoorman could not finish checking this message, so it is treated with caution.
protected_informationanalysisscore onlyThe 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 unsafe feedback revokes known.
new
Every other sender.
blocked
Set by an owner rule for an address or domain. In enforce mode, 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.

PresetWarn atHold atHold unauthenticated new sendersReply guardRecipientsUnscannable
relaxed60nevernooffanydeliver
balanced6085noonanywarn
strict3060yesonknownhold

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.

Tighten an inbox to Strict

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}/held lists held stubs (delegated to mail:read so agents can see that mail is waiting and ask their user; subject is null for keys, app tokens and organization members without security:manage, and included for callers that may review held mail).
  • A console session that may review held mail (security:manage and mail:read in an organization) can inspect a held message in full via GET /v1/messages/{messageId}, then deliver it with POST /v1/messages/{messageId}/release (which threads it at release time and emits message.received with risk.action: "released") or trash it permanently with POST /v1/messages/{messageId}/discard.
  • POST /v1/messages/{messageId}/feedback records { "verdict": "safe" | "unsafe" } on a delivered inbound message. safe lifts the reply guard, removes the message from its thread's riskLevel and withdraws the flag on its sender; unsafe flags 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"
replyGuard is on and the target thread contains any inbound message that the current policy warns about or holds (or that the owner marked unsafe), unless the owner marked that message safe or its sender is trusted and the message passed DMARC. A harmless follow-up in the same thread does not clear the guard.
guard: "recipient"
recipients is known (the strict preset) and a to, cc or bcc address is neither trusted, known, nor one of the account's own active inboxes. Nothing inside an inbound message (not From, Reply-To or Cc) 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; reasons lists 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, requestedBy and status. GET /v1/held-sends/{heldSendId} says where it stands later: held, sent, discarded or expired. The subject and the text are null for every caller that may not decide.
Who decides
POST /v1/held-sends/{heldSendId}/approve sends 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 set allowKeyManagement. POST /v1/held-sends/{heldSendId}/discard ends 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_reached beyond that), and one that nobody decides expires unsent after 7 days.
Events
send.held when a message starts to wait and send.discarded when it ends unsent, both without the subject or the body. A held send the owner sends emits message.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 }.

Preview a draft policy against a prompt injection sample

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

StatusErrorMeaning
403risk_blockedThe 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.
503scan_unavailableThe 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.
403session_requiredAccount 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.
403forbiddenThe key is scoped to one inbox and cannot manage inboxes, keys or webhooks, or cannot read account-wide data.
409limit_reachedThe 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.
400validation_errorA field is missing or invalid; the message names it.
404not_foundNo such resource for this caller, or no such route.

Up Down to move, Enter to open, Esc to close