Backticks not treated as string delimiters in html/template
Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template. As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. "var a = {{.}}"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml. With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21. Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmpllitinterp=1, with the caveat that backticks will now be escaped. This should be used with caution.
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2023-24538
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 7 Nov 2026, 04:15 UTC · Revision 1
Source evidence
Backticks not treated as string delimiters in html/template
core-osv · Original sourcePublished 6 Apr 2023, 15:50 UTC
Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template. As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. "var a = {{.}}"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml. With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21. Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmpllitinterp=1, with the caveat that backticks will now be escaped. This should be used with caution.
osv:CVE-2023-24538
Complete source record
{
"id": "9ca1484d9d38f801e31f866ca9919fa54ecc30683c69162efa1f2b18d9b6eea1",
"url": "https://osv.dev/vulnerability/CVE-2023-24538",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "Backticks not treated as string delimiters in html/template",
"summary": "Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template. As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. \"var a = {{.}}\"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml. With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21. Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmpllitinterp=1, with the caveat that backticks will now be escaped. This should be used with caution.",
"evidence": "osv:CVE-2023-24538",
"products": [],
"severity": "critical",
"structured": {
"id": "CVE-2023-24538",
"aliases": [
"BIT-golang-2023-24538",
"CVE-2023-24538",
"GO-2023-1703"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/golang/go",
"type": "GIT",
"events": [
{
"introduced": "0"
},
{
"fixed": "ca305e101d89969b5cc6a812b1f12038b769aaa2"
},
{
"fixed": "7c47a6b15782b13ecb76fd3c6c18e5f1edc34733"
}
],
"database_specific": {
"extracted_events": [
{
"cpe": "cpe:2.3:a:golang:go:*:*:*:*:*:*:*:*",
"range": [
{
"introduced": "0"
},
{
"fixed": "1.19.8"
}
],
"source": "CPE_RANGE"
},
{
"cpe": "cpe:2.3:a:golang:go:*:*:*:*:*:*:*:*",
"range": [
{
"introduced": "1.20.0"
},
{
"fixed": "1.20.3"
}
],
"source": "CPE_RANGE"
}
]
}
}
],
"versions": [
"go1.19.7",
"go1.20.2",
"go1.20.1",
"go1.19.6",
"go1.20",
"go1.20rc3",
"go1.19.5",
"go1.20rc2",
"go1.20rc1",
"go1.19.4",
"go1.19.3",
"go1.19.2",
"go1.19.1",
"go1.19",
"go1.19rc2",
"go1.19rc1",
"go1.19beta1",
"go1.18beta2",
"go1.18beta1",
"go1.17beta1",
"go1.16beta1",
"go1.15beta1",
"go1.14beta1",
"go1.13beta1",
"go1.12beta2",
"go1.12beta1",
"go1.11beta3",
"go1.11beta2",
"go1.11beta1",
"go1.10rc2",
"go1.10rc1",
"go1.10beta2",
"go1.10beta1",
"go1.9beta2",
"go1.9beta1",
"go1.8beta2",
"go1.8beta1",
"go1.7rc4",
"go1.7rc3",
"go1.7rc2",
"go1.7rc1",
"go1.7beta2",
"go1.7beta1",
"go1.6beta2",
"go1.6beta1",
"go1.5beta3",
"go1.5beta2",
"go1.5beta1",
"go1.4beta1",
"go1.3beta2",
"go1.3beta1",
"weekly.2012-03-27",
"weekly",
"weekly.2012-03-22",
"weekly.2012-03-13",
"weekly.2012-03-04",
"weekly.2012-02-22",
"weekly.2012-02-14",
"weekly.2012-02-07",
"weekly.2012-01-27",
"weekly.2012-01-20",
"weekly.2012-01-15",
"weekly.2011-12-22",
"weekly.2011-12-14",
"weekly.2011-12-06",
"weekly.2011-12-02",
"weekly.2011-12-01",
"weekly.2011-11-18",
"weekly.2011-11-09",
"weekly.2011-11-08",
"weekly.2011-11-02",
"weekly.2011-11-01",
"weekly.2011-10-26",
"weekly.2011-10-25",
"weekly.2011-10-18",
"weekly.2011-10-06",
"weekly.2011-09-21",
"weekly.2011-09-16",
"weekly.2011-08-17",
"weekly.2011-09-07",
"weekly.2011-09-01",
"weekly.2011-08-10",
"weekly.2011-07-07",
"weekly.2011-07-29",
"weekly.2011-07-19",
"weekly.2011-06-09",
"weekly.2011-06-23",
"weekly.2011-06-16",
"weekly.2011-06-02",
"weekly.2011-05-22",
"weekly.2011-04-27",
"weekly.2011-04-13",
"weekly.2011-04-04",
"weekly.2011-03-28",
"weekly.2011-03-15",
"weekly.2011-03-07.1",
"release.r56",
"weekly.2011-03-07",
"weekly.2011-02-24",
"weekly.2011-02-15",
"weekly.2011-02-01.1",
"weekly.2011-02-01",
"weekly.2011-01-20",
"weekly.2011-01-19",
"weekly.2011-01-12",
"weekly.2011-01-06",
"weekly.2010-12-22",
"weekly.2010-12-15.1",
"weekly.2010-12-15",
"weekly.2010-12-08",
"weekly.2010-12-02",
"weekly.2010-11-23",
"weekly.2010-11-10",
"weekly.2010-11-02",
"weekly.2010-10-27",
"weekly.2010-10-20",
"weekly.2010-10-13.1",
"weekly.2010-10-13",
"weekly.2010-09-29",
"weekly.2010-09-22",
"weekly.2010-09-15",
"weekly.2010-09-06",
"weekly.2010-08-25",
"weekly.2010-08-11",
"weekly.2010-08-04",
"weekly.2010-07-29",
"weekly.2010-07-14",
"weekly.2010-07-01",
"weekly.2010-06-21",
"weekly.2010-06-09",
"weekly.2010-05-27",
"weekly.2010-05-04",
"weekly.2010-04-27",
"weekly.2010-04-13",
"weekly.2010-03-30",
"weekly.2010-03-22",
"weekly.2010-03-15",
"weekly.2010-03-04",
"weekly.2010-02-23",
"weekly.2010-02-17",
"weekly.2010-02-04",
"weekly.2010-01-27",
"weekly.2010-01-13",
"weekly.2010-01-05",
"weekly.2009-12-22",
"weekly.2009-12-09",
"weekly.2009-12-07",
"weekly.2009-11-17",
"weekly.2009-11-12",
"weekly.2009-11-10.1",
"weekly.2009-11-10",
"weekly.2009-11-06"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-24538.json"
}
}
],
"modified": "2026-10-28T02:30:49.486963528Z",
"provider": "osv",
"references": [
"https://go.dev/cl/482079",
"https://go.dev/issue/59234",
"https://groups.google.com/g/golang-announce/c/Xdv6JL9ENs8",
"https://pkg.go.dev",
"https://pkg.go.dev/vuln/GO-2023-1703",
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/24xxx/CVE-2023-24538.json",
"https://nvd.nist.gov/vuln/detail/CVE-2023-24538",
"https://security.gentoo.org/glsa/202311-09",
"https://security.netapp.com/advisory/ntap-20241115-0007/"
],
"provider_metadata": {
"cna_assigner": "Go",
"unresolved_ranges": [
{
"extracted_events": [
{
"range": [
{
"fixed": "1.19.8"
},
{
"introduced": "1.20.0-0"
},
{
"fixed": "1.20.3"
}
],
"source": "AFFECTED_FIELD",
"strategy": "StandardRange"
}
]
}
],
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/24xxx/CVE-2023-24538.json"
}
},
"related_cves": [
{
"value": "CVE-2023-24538",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 518057,
"published_at": "2023-04-06T15:50:48.185+00:00"
}