Skip to content

ews: enforce Send-As permission on client-supplied From/Sender - #316

Open
nourdineb-ops wants to merge 1 commit into
grommunio:masterfrom
nourdineb-ops:sendas-permission-check
Open

ews: enforce Send-As permission on client-supplied From/Sender#316
nourdineb-ops wants to merge 1 commit into
grommunio:masterfrom
nourdineb-ops:sendas-permission-check

Conversation

@nourdineb-ops

Copy link
Copy Markdown
Contributor

Sorry, missed something in #286 that I should have caught then. Found and fixed a permission gap in EWS's CreateItem while looking into something unrelated (a "Send As" convenience script on our own deployment). toContent() writes whatever identity a client supplies via a message's From/Sender field straight into PR_SENT_REPRESENTING_*/PR_SENDER_*, for both SaveOnly and SendOnly/SendAndSaveCopy - with no authorization check.

Root cause: #286 ("respect client-supplied From on save") intentionally started trusting a client-supplied From to fix a real bug - a draft saved from a secondary alias reverting to the primary identity - and explicitly modeled this on grommunio-web's PR_SENT_REPRESENTING_* ??= PR_SENDER_* pattern (class.operations.php). It only carried over the fallback-default half of that pattern, not the permission check that makes it safe there.

Fix adds EWSContext::checkSendAs(), mirroring zs_submitmessage()'s check (frightsGromoxSendAs or full store ownership on the claimed identity's mailbox), called from CreateItem right after toContent() populates PR_SENT_REPRESENTING_EMAIL_ADDRESS - applies uniformly to drafts and actual sends, and to the reply/forward wrapper types alongside plain messages.

Tested against a live deployment: granted a real frightsGromoxSendAs grant between two test mailboxes, confirmed a CreateItem with the granted identity still succeeds and correctly resolves to it, confirmed the same request with an ungranted identity now gets ErrorAccessDenied, and confirmed a plain message with no From override is unaffected.

toContent() has always written whatever identity a client supplied via
a message's From/Sender field straight into PR_SENT_REPRESENTING_* and
PR_SENDER_*, for both CreateItem's SaveOnly (draft) and SendOnly/
SendAndSaveCopy (actual send) paths - with no authorization check of
its own. Real Exchange, and gromox's own zcore (zs_submitmessage())
and emsmdb paths, instead require frightsGromoxSendAs or full store
ownership on the claimed identity's mailbox before honoring it - EWS
was the only one of gromox's three client-facing paths missing this.

Traced empirically on a live deployment: grommunio-web correctly
denies/grants based on this permission (addUserStore() -> a genuine
MAPI store-open, checked server-side), while an EWS CreateItem with an
arbitrary From currently goes through unchecked - confirmed via raw
delivered headers showing a clean, unauthorized identity with no
rejection anywhere in the pipeline.

Root cause: a prior commit ("ews: implement ReplyToItem/.../and
respect client-supplied From on save") intentionally started trusting
a client-supplied From to fix a real bug (drafts from a secondary
alias reverting to the primary identity) and explicitly modeled this
on grommunio-web's PR_SENT_REPRESENTING_* ??= PR_SENDER_* pattern -
but only copied the fallback-default half of that pattern, not the
permission check that makes it safe in the webapp
(class.operations.php's addUserStore()/openMessageStore()).

Adds EWSContext::checkSendAs(), mirroring zs_submitmessage()'s check,
called from CreateItem right after toContent() populates
PR_SENT_REPRESENTING_EMAIL_ADDRESS - applies uniformly to drafts and
actual sends, and to the reply/forward wrapper types alongside plain
messages, since they all flow through the same toContent() call.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@nourdineb-ops

Copy link
Copy Markdown
Contributor Author

Just checking in - any questions on this one, or anything else you'd like me to test/expand on before it gets a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant