Skip to content

Fix XSS in rendered report: HTML-escape user-controlled reportName#3334

Merged
baev merged 3 commits into
allure-framework:mainfrom
grootstebozewolf:fix/escape-report-name-in-html
May 11, 2026
Merged

Fix XSS in rendered report: HTML-escape user-controlled reportName#3334
baev merged 3 commits into
allure-framework:mainfrom
grootstebozewolf:fix/escape-report-name-in-html

Conversation

@grootstebozewolf
Copy link
Copy Markdown
Contributor

@grootstebozewolf grootstebozewolf commented May 10, 2026

Context

FreemarkerContext constructs the FreeMarker Configuration without an output format, so HTML auto-escaping is off. The reportName value (set via ConfigurationBuilder#withReportName, ultimately controlled by the user's CLI invocation or upstream config) is interpolated into the <title> tag in index.html.ftl with no escaping, so a value containing live HTML or JS is rendered raw.

This PR applies per-variable HTML escaping at the bug site:

-<title>${reportName!"Allure Report"}</title>
+<title>${(reportName!"Allure Report")?html}</title>

A broader change to the Configuration's output format would tighten escaping across every template variable, but it would need a template-wide audit first (especially for ${...} interpolations inside <script> tags). That's intentionally out of scope here and worth its own discussion.

Checklist

FreemarkerContext constructs the FreeMarker Configuration without an
output format, so HTML auto-escaping is off. The reportName value
(set via ConfigurationBuilder#withReportName, ultimately controlled
by the user's CLI invocation or upstream config) is interpolated into
the <title> tag in index.html.ftl with no escaping, so a value
containing live HTML or JS is rendered raw.

Apply per-variable HTML escaping at the bug site:

    <title>${(reportName!"Allure Report")?html}</title>

A broader change to the Configuration's output format would tighten
escaping across every template variable, but it would need a
template-wide audit first (especially for ${...} interpolations
inside <script> tags). Out of scope here; tracked separately.

Adds ReportWebGeneratorTest#shouldEscapeHtmlInReportName, which fails
on main and passes with this change.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@baev baev added the type:security Security vulnerability or fix label May 11, 2026
@baev baev merged commit 98d91c0 into allure-framework:main May 11, 2026
13 checks passed
@grootstebozewolf grootstebozewolf deleted the fix/escape-report-name-in-html branch May 11, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:generator type:security Security vulnerability or fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants