Skip to content

jte's HTML templates containing Javascript template strings are subject to XSS

Moderate severity GitHub Reviewed Published Jan 13, 2025 in casid/jte • Updated Jan 13, 2025

Package

maven gg.jte:jte (Maven)

Affected versions

<= 3.1.15

Patched versions

3.1.16
maven gg.jte:jte-runtime (Maven)
<= 3.1.15
3.1.16

Description

Summary

Jte HTML templates with script tags or script attributes that include a Javascript template string (backticks) are subject to XSS.

Details

The javaScriptBlock and javaScriptAttribute methods in the Escape class (source) do not escape backticks, which are used for Javascript template strings. Dollar signs in template strings should also be escaped as well to prevent undesired interpolation.

PoC

  1. Use the Jte Gradle Plugin with the following code in src/jte/xss.jte:
    @param String someMessage
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title>XSS Test</title>
        <script>window.someVariable = `${someMessage}`;</script>
    </head>
    <body>
    <h1>XSS Test</h1>
    </body>
    </html>
  2. Use the following Java code to demonstrate the XSS vulnerability:
    final StringOutput output = new StringOutput();
    JtexssGenerated.render(new OwaspHtmlTemplateOutput(output), null, "` + alert(`xss`) + `");
    renderHtml(output);

Impact

HTML templates rendered by Jte's OwaspHtmlTemplateOutput in versions less than or equal to 3.1.15 with script tags or script attributes that contain Javascript template strings (backticks) are vulnerable.

References

@casid casid published to casid/jte Jan 13, 2025
Published to the GitHub Advisory Database Jan 13, 2025
Reviewed Jan 13, 2025
Published by the National Vulnerability Database Jan 13, 2025
Last updated Jan 13, 2025

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

CVE ID

CVE-2025-23026

GHSA ID

GHSA-vh22-6c6h-rm8q

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.