CVE-2023-39318: Improper handling of HTML-like comments in script contexts in html/template

Published Sep 6, 2023
·
Updated

Golang Go is vulnerable to cross-site scripting, caused by improper validation of user-supplied input by the html/template package. A remote attacker could exploit this vulnerability using a specially crafted URL to execute script in a victim's Web browser within the security context of the hosting Web site, once the URL is clicked. An attacker could use this vulnerability to steal the victim's cookie-based authentication credentials.

Other sources

Improper handling of HTML-like comments in script contexts in html/template

Microsoft

The html/template package did not properly handle HMTL-like "<!--" and "-->"comment tokens, nor hashbang "#!" comment tokens, in <script> contexts. This may cause the template parser to improperly interpret the contents of <script> contexts, causing actions to be improperly escaped. This could be leveraged to perform an XSS attack.

Red Hat

The html/template package does not properly handle HTML-like "" comment tokens, nor hashbang "#!" comment tokens, in <script> contexts. This may cause the template parser to improperly interpret the contents of <script> contexts, causing actions to be improperly escaped. This may be leveraged to perform an XSS attack.

Launchpad

Affected Software

13 affected componentsFixes available
debian/golang-1.15<=1.15.15-1~deb11u4
debian/golang-1.19<=1.19.8-2
Golang Go<1.20.8
Golang Go>=1.21.0<1.21.1
IBM Concert Software<=1.0.0 - 1.0.1
redhat/golang<1.20.8
1.20.8
redhat/golang<1.21.1
1.21.1
Microsoft cbl2 golang 1.20.10-1
Microsoft azl3 golang 1.20.10-1
Microsoft cbl2 golang 1.18.8-7
Microsoft cbl2 msft-golang 1.20.10-1
Microsoft cbl2 golang 1.21.6-1
Microsoft cbl2 golang 1.17.13-2

Remediation

Event History

Sep 6, 2023
Data Sourced
via Red Hat·08:23 PM
DescriptionSeverityAffected Software
Sep 8, 2023
CVE Published
via MITRE·04:13 PM
Data Sourced
via MITRE·04:13 PM
DescriptionWeakness
Jan 12, 2024
Data Sourced
via Launchpad·12:24 AM
Description
Oct 21, 2024
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software
Nov 15, 2024
Data Sourced
via Ubuntu·02:55 AM
RemedyDescriptionSeverityAffected Software
Sep 4, 2025
Data Sourced
via Microsoft·06:18 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·06:18 AM
Affected Software
Updated
via Microsoft·06:18 AM
Affected Software
Updated
via Microsoft·06:18 AM
DescriptionSeverity

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the vulnerability ID?

The vulnerability ID is CVE-2023-39318.

2

What is the severity of CVE-2023-39318?

The severity of CVE-2023-39318 is medium.

3

What is the affected software for CVE-2023-39318?

The affected software for CVE-2023-39318 is Golang Go versions between 1.20.8 and 1.21.1.

4

How does CVE-2023-39318 affect the html/template package?

CVE-2023-39318 affects the html/template package by not properly handling HTML-like comment tokens and hashbang #! comment tokens in <script> contexts, leading to improper interpretation of contents and potential escaping issues.

5

Are there any references related to CVE-2023-39318?

Yes, here are some references related to CVE-2023-39318: [Link 1](https://go.dev/cl/526156), [Link 2](https://go.dev/issue/62196), [Link 3](https://groups.google.com/g/golang-dev/c/2C5vbR-UNkI/m/L1hdrPhfBAAJ).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203