Skip to content

fix: protect mail previews and attachments - #86

Merged
markvaneijk merged 2 commits into
backstagephp:mainfrom
jeromecoloma:secure-mail-routes
Aug 24, 2026
Merged

fix: protect mail previews and attachments#86
markvaneijk merged 2 commits into
backstagephp:mainfrom
jeromecoloma:secure-mail-routes

Conversation

@jeromecoloma

Copy link
Copy Markdown
Contributor

Summary

  • Require Filament authentication for preview and attachment routes
  • Enforce the plugin's canManageMails() permission check
  • Scope attachment lookups to their parent mail
  • Return 404 responses for missing or mismatched records
  • Render stored email HTML in a sandboxed iframe
  • Add security headers to direct preview responses
  • Document authenticated route registration

Security impact

Previously, preview and attachment routes could expose stored email content without authentication. Attachment IDs were also resolved independently of the mail ID in the URL.

This change protects both routes and prevents attachments from being downloaded through unrelated mail records.

Testing

  • 14 tests passed with 35 assertions
  • composer validate --strict passed
  • composer audit reported no known vulnerabilities

@Baspa

Baspa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Wasn't this already fixed in #84 ? @markvaneijk

@markvaneijk

Copy link
Copy Markdown
Contributor

These are all good additions. Merging. Thanks @jeromecoloma

@markvaneijk
markvaneijk merged commit 536e969 into backstagephp:main Aug 24, 2026
1 check passed
@jeromecoloma

Copy link
Copy Markdown
Contributor Author

Thanks!

markvaneijk added a commit that referenced this pull request Aug 25, 2026
Port #86 into the monorepo copy of the package.

- Require Filament authentication and the plugin's canManageMails()
  check on the preview and attachment routes
- Scope attachment lookups to their parent mail so an attachment cannot
  be downloaded through an unrelated mail record
- Return 404 responses for missing or mismatched records
- Render stored email HTML in a sandboxed iframe and add security
  headers to direct preview responses
- Register the routes as authenticated (tenant) panel routes

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@markvaneijk

Copy link
Copy Markdown
Contributor

Released in v5.2.1

markvaneijk added a commit that referenced this pull request Aug 26, 2026
Port the remaining parts of #86 that 5.x did not pick
up in #299.

- Render stored email HTML in a sandboxed iframe via srcdoc instead of
  pointing the iframe at the preview route
- Serve the preview with a sandboxing Content-Security-Policy plus
  Referrer-Policy and X-Frame-Options
- Type the controller responses and read the mail model with
  Config::string()
- Cover the new headers and the sandboxed render in the security test

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants