RCE in Golang Go
CVE-2023-24538
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.
Vulnerability class: RCE (Remote Code Execution)
Published · last modified .
CVSS v3 metric
CVSS v3 base score 9.8 (Critical). Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
EPSS exploit prediction
EPSS: 0.023 (82.5th percentile), scored .
Low probability of exploitation in the next 30 days, but still tracked. 82nd percentile — 82.5% of CVEs in the catalogue have a lower EPSS than this one. How to read EPSS.
EPSS over last 30 days · oldest: 0.023 · newest: 0.023 · change: 0.000
Affected products
- Golang Go
- Go Standard Library Html/template — versions 0, 1.20.0-0
Weakness classification (CWE)
Public proof-of-concept exploits
References
- go.dev/issue/59234 (Patch, Issue Tracking)
- go.dev/cl/482079 (Patch)
- groups.google.com/g/golang-announce/c/Xdv6JL9ENs8 (Mailing List)
- pkg.go.dev/vuln/GO-2023-1703 (Vendor Advisory)
- security.gentoo.org/glsa/202311-09
- af854a3a-2127-422b-91ae-364da2661108
Frequently asked questions
- What is CVE-2023-24538?
- CVE-2023-24538 is a critical-severity vulnerability in Golang Go, classified under Code Injection. CVSS score: 9.8/10. Published 2023-04-06.
- How severe is CVE-2023-24538?
- Critical severity. CVSS v3 base score is 9.8 out of 10.
- Is CVE-2023-24538 known to be exploited?
- 12 public proof-of-concept repositories are indexed. Not currently listed in the CISA KEV catalog.