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, 83.4th percentile (scored ); unchanged over 30 days. About EPSS.
Affected products
- Golang Go
- Go Standard Library Html/template — versions 0, 1.20.0-0
Weakness classification (CWE)
Public exploits and proof-of-concept code
2 public repositories with exploit or proof-of-concept code for this CVE:
- skulkarni-mv/goIssue_dunfell (last pushed 2023-10-04): go CVE-2023-24538 patch issue resolver - Dunfell
- skulkarni-mv/goIssue_kirkstone (last pushed 2023-09-29): go CVE-2023-24538 patch issue resolver - Kirkstone
Also mentioned in 9 other repositories (4l3pH0/Universal-template-fuzzing, 8-cm/kube-dump, brokedba/K8sGpt_lab, …). These reference the CVE in a list, notes or a scanner and are not exploit code for it.
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
- security.netapp.com/advisory/ntap-20241115-0007/
This CVE has public exploit evidence. See the latest CVEs with public exploits.