Skip to content

Fix XSS in rendered report: HTML-escape user-controlled reportLanguage#3337

Merged
baev merged 1 commit into
allure-framework:mainfrom
grootstebozewolf:fix/escape-report-language-in-html
May 11, 2026
Merged

Fix XSS in rendered report: HTML-escape user-controlled reportLanguage#3337
baev merged 1 commit into
allure-framework:mainfrom
grootstebozewolf:fix/escape-report-language-in-html

Conversation

@grootstebozewolf
Copy link
Copy Markdown
Contributor

@grootstebozewolf grootstebozewolf commented May 10, 2026

Context

Sister to #3334. reportLanguage is set via ConfigurationBuilder#withReportLanguage and interpolated into the lang attribute on the root <html> tag in index.html.ftl. With no auto-escaping configured on the FreeMarker context, a value like

en"><script>alert('xss')</script>

breaks out of the attribute and injects live markup. Apply per-variable HTML escaping at the bug site:

-<html dir="ltr" lang="${reportLanguage!"en"}">
+<html dir="ltr" lang="${(reportLanguage!"en")?html}">

Existing shouldSetLanguage and shouldSetDefaultLanguageIfNotProvided tests continue to pass — escaping a value with no HTML metacharacters is a no-op.

Checklist

@baev baev added the type:security Security vulnerability or fix label May 11, 2026
@baev
Copy link
Copy Markdown
Member

baev commented May 11, 2026

@grootstebozewolf please rebase

Sister to the reportName escaping fix. reportLanguage is set via
ConfigurationBuilder#withReportLanguage and interpolated into the
lang attribute on the root <html> tag in index.html.ftl. Without
escaping, a value like

    en"><script>alert('xss')</script>

breaks out of the attribute and injects live markup. Apply
per-variable HTML escaping at the bug site:

    <html dir="ltr" lang="${(reportLanguage!"en")?html}">

Adds ReportWebGeneratorTest#shouldEscapeHtmlInReportLanguage, which
fails on main and passes with this change. Existing
shouldSetLanguage / shouldSetDefaultLanguageIfNotProvided tests
continue to pass — escaping a value with no HTML metacharacters is
a no-op.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@grootstebozewolf grootstebozewolf force-pushed the fix/escape-report-language-in-html branch from f870ecc to 3788196 Compare May 11, 2026 14:48
@baev baev merged commit 0e6e1bc into allure-framework:main May 11, 2026
14 checks passed
@grootstebozewolf grootstebozewolf deleted the fix/escape-report-language-in-html branch May 11, 2026 17:08
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