The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(email): make the authserv-id pin a required, pre-normalised argument
kshitijk4poorc495ab684b0a
diff --git a/plugins/platforms/email/adapter.py b/plugins/platforms/email/adapter.pyindex 4df299476d4..d722ecaa06f 100644--- a/plugins/platforms/email/adapter.py+++ b/plugins/platforms/email/adapter.py@@ -362,11 +362,11 @@ def _domains_aligned(a: str, b: str) -> bool:return bool(a and b) and (a == b or a.endswith("." + b) or b.endswith("." + a))-def _verify_sender_authentication(msg: email_lib.message.Message, from_addr: str, *, authserv_id: str = "") -> Tuple[bool, str]:+def _verify_sender_authentication(msg: email_lib.message.Message, from_addr: str, *, authserv_id: str) -> Tuple[bool, str]:"""Verify the ``From:`` domain is authenticated; returns ``(authenticated, reason)``.``From:`` is attacker-controlled (GHSA-rxqh-5572-8m77); the only trustworthy signal is the``Authentication-Results`` header stamped by the *receiving* server. It prepends, so only the- FIRST instance is authoritative, and it must match the required *authserv_id* exactly. A matching id is a+ FIRST instance is authoritative, and it must match the required, already-normalised *authserv_id* exactly. A matching id is apin, not proof of provenance: the receiving MTA must strip inbound results claiming its id (RFC 8601).True on DMARC pass, aligned SPF pass, or aligned DKIM (``header.d``) pass. No header or no pin → fail-closed(opt out via ``EmailAdapter._require_authenticated_sender``)."""@@ -380,9 +380,9 @@ def _verify_sender_authentication(msg: email_lib.message.Message, from_addr: str# receiver variants remain valid without allowing a lower field or a related domain to satisfy the pin.if (clauses := _ar_clauses(trusted)) is None:return False, "unbalanced quote or comment in Authentication-Results"- if not authserv_id.strip(): # without a pin the topmost header may be one the sender wrote+ if not authserv_id: # without a pin the topmost header may be one the sender wrotereturn False, _MISSING_AUTHSERV_REASON- if clauses[0].strip().lower() != authserv_id.strip().lower():+ if clauses[0].strip().lower() != authserv_id:return False, _UNTRUSTED_AUTHSERV_REASON# Each verdict comes from the head of its own clause (split outside quotes/comments) and its domains only from that# clause: a quoted local part or comment can otherwise smuggle ``spf=pass``/``header.d=`` (GHSA-rxqh-5572-8m77).