CVE-2024-24785 Errors returned from JSON marshaling may break template escaping in html/template

Medium 5.4 Published Updated

Attackers can inject unexpected content into templates by exploiting errors from JSON marshaling, bypassing auto-escaping in Go's html/template package.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-24785?

CVE-2024-24785 is a medium-severity cross-site scripting vulnerability in Go standard library html/template, published on 5 Mar 2024. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

If errors returned from MarshalJSON methods contain user controlled data, they may be used to break the contextual auto-escaping behavior of the html/template package, allowing for subsequent actions to inject unexpected content into templates.

Which versions are affected by CVE-2024-24785?

2 open source packages ship an affected version, including golang and stdlib.

PackageAffectedFixed in
golang BitnamiAll versions1.21.8, 1.22.1
stdlib GoAll versions1.21.8, 1.22.1

How do I fix CVE-2024-24785?

Upgrade golang to a fixed version for your release line: 1.21.8 or 1.22.1.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2024-24785 being exploited?

There is no known exploitation of CVE-2024-24785 in the wild and no public exploit code.

Sources

Also known as AZL-37457, AZL-37460, AZL-79024, AZL-98967, BELL-CVE-2024-24785, BIT-golang-2024-24785 and 8 more.

Is CVE-2024-24785 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free