CVE-2024-24785: Errors in JSON Marshaling Break Template Escaping in html/template

stdlib Updated 02 Oct 2025

Summary

05/03/2024
Yes i
Unrated
Not published

CVE-2024-24785: Errors returned from JSON marshaling may break template escaping in html/template. Affects stdlib across 2 version ranges.

< 1.21.8 >= 1.22.0-0, < 1.22.1

Fixed in 1.21.8 or 1.22.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2024-24785 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The stdlib package in the Go ecosystem is a collection of standard libraries that provide fundamental functionality for Go programs. One of these packages is html/template, which is used for generating HTML output. The html/template package includes auto-escaping behavior to prevent injection attacks and ensure the security of generated HTML templates.

Vulnerability Detail

The vulnerability arises when errors returned from MarshalJSON methods contain user-controlled data. This can lead to a break in the contextual auto-escaping behavior of the html/template package. As a result, unexpected content can be injected into templates, potentially leading to cross-site scripting (XSS) attacks or other security vulnerabilities.

How To Fix

Latest published version: go1.25.5 as of 22 Oct 2026

go get stdlib@vgo1.25.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.21.8 1.21.8
    go get stdlib@v1.21.8
  • >= 1.22.0-0, < 1.22.1 1.22.1
    go get stdlib@v1.22.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

There is no known workaround for this vulnerability. It is essential to update to the fixed version as soon as possible.

Conclusion

The vulnerability in the stdlib package's html/template package can lead to unexpected content injection in templates, potentially resulting in XSS attacks or other security issues. It is highly recommended to update to the fixed version (1.22.1 or later) to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

The vulnerability allows for unexpected content injection into templates, which can lead to cross-site scripting (XSS) attacks or other security vulnerabilities.

Versions 0 and 1.22.0-0 of the stdlib package are affected. The vulnerability is fixed in version 1.22.1.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. No signup is required, and you can simply provide your Gopkg.lock file to analyze your application's vulnerability status.

No, there is no known workaround for this vulnerability. It is crucial to update to the fixed version of the stdlib package.

You can find more information about this vulnerability in the Go vulnerability database at https://vuln.go.dev/ID/GO-2024-2610.json.

Related vulnerabilities

Recent vulnerabilities recorded for stdlib.

How To Fix

Latest published version: go1.25.5 as of 22 Oct 2026

go get stdlib@vgo1.25.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.21.8 1.21.8
    go get stdlib@v1.21.8
  • >= 1.22.0-0, < 1.22.1 1.22.1
    go get stdlib@v1.22.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback