fix: use HMAC for proxied HTML iframe content#12735
Merged
ChristophWurst merged 1 commit intomainfrom Apr 15, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the /proxy endpoint used for loading external content from HTML emails by binding proxied URLs to a specific message id via an HMAC, and ensuring the current user actually owns the referenced message.
Changes:
- Introduce
ProxyHmacGeneratorand integrate it into HTML sanitization so proxied URLs includeid,hmac, andsrc. - Update
TransformURLSchemeto generate proxied URLs with HMAC instead of relying on request tokens. - Update
ProxyController::proxy()to validate message ownership and HMAC before proxying, and expand/adjust unit tests accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/Html/ProxyHmacGenerator.php | New helper to generate per-message HMACs for proxied URLs. |
| lib/Service/Html.php | Injects HMAC generator and passes message id into URL rewriting filter. |
| lib/Service/HtmlPurify/TransformURLScheme.php | Rewrites external URLs to /proxy with id/hmac/src query params and updates CID attachment URL building. |
| lib/Controller/ProxyController.php | Validates id/hmac and message ownership before proxying; returns 400/401 on invalid requests. |
| lib/Model/IMAPMessage.php | Updates call site to new sanitizeHtmlMailBody(..., int $id, ...) signature. |
| tests/Unit/Html/ProxyHmacGeneratorTest.php | Adds unit tests for HMAC generation behavior. |
| tests/Unit/Controller/ProxyControllerTest.php | Updates controller construction/signature and adds tests for invalid/missing HMAC and ownership checks. |
| tests/Unit/Service/HtmlPurify/TransformURLSchemeTest.php | Updates expectations to include id/hmac/src in proxied URLs and new constructor signature. |
| tests/Unit/Service/HtmlTest.php | Updates Html service construction to include the new dependency. |
| tests/Unit/Model/IMAPMessageTest.php | Updates Html service construction to include the new dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kesselb
approved these changes
Apr 15, 2026
AI-Assisted: OpenCode (Claude Haiku 4.5) Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
dc8010f to
b346f0b
Compare
Member
Author
|
/backport to stable5.7 |
Member
Author
|
/backport to stable5.6 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This was referenced Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This scopes the proxy to a specific email and URL.
Most changes are about injecting service and data. The main changes are trivial.
AI-Assisted: OpenCode (Claude Haiku 4.5)