The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2024-24785

CVE-2024-24785: Go html/template XSS Vulnerability

CVE-2024-24785 is an XSS vulnerability in Go's html/template package that breaks contextual auto-escaping through MarshalJSON errors. This post covers the technical details, affected versions, impact, and mitigation.

Updated: January 22, 2026

CVE-2024-24785 Overview

CVE-2024-24785 is a template injection vulnerability affecting the Go programming language's html/template package. 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. This allows subsequent actions to inject unexpected content into templates, potentially enabling Cross-Site Scripting (XSS) attacks.

Critical Impact

Attackers can bypass the contextual auto-escaping security mechanism in Go's html/template package by crafting malicious error messages from MarshalJSON methods, potentially leading to XSS attacks and content injection in web applications.

Affected Products

  • Go programming language html/template package
  • Applications using Go's html/template with custom MarshalJSON implementations
  • NetApp products (per NetApp Security Advisory NTAP-20240329-0008)

Discovery Timeline

  • 2024-03-05 - CVE-2024-24785 published to NVD
  • 2024-03-08 - Public disclosure via Openwall OSS-Security Discussion
  • 2025-03-14 - Last updated in NVD database

Technical Details for CVE-2024-24785

Vulnerability Analysis

This vulnerability exists in Go's html/template package, which provides contextual auto-escaping to prevent XSS attacks when rendering HTML templates. The package is designed to automatically escape content based on the context where it appears (HTML, JavaScript, CSS, URL, etc.).

The flaw occurs when custom types implement the json.Marshaler interface via a MarshalJSON method. If this method returns an error containing user-controlled data, the error message can be crafted to break out of the auto-escaping context. This happens because error messages from JSON marshaling are processed in a way that doesn't properly sanitize embedded content before inclusion in template output.

An attacker who can influence the data passed to a MarshalJSON implementation can craft payloads that, when triggering an error, will bypass the template's safety mechanisms and inject arbitrary content.

Root Cause

The root cause lies in how the html/template package handles error messages returned from MarshalJSON methods during template execution. When JSON marshaling fails, the error message is incorporated into the template processing flow without adequate escaping. If the error message contains user-controlled data, this creates a path for injection attacks that circumvents the package's contextual auto-escaping design.

The vulnerability specifically affects the boundary between JSON serialization errors and HTML template rendering, where trust assumptions about error content are violated.

Attack Vector

The attack is network-accessible and requires the following conditions:

  1. The target application uses Go's html/template package
  2. The application processes user-controlled data through a custom type with a MarshalJSON method
  3. The MarshalJSON method can produce error messages that include user-provided input
  4. These errors are processed during template execution

An attacker provides specially crafted input that causes the MarshalJSON method to fail with an error message containing malicious content. This content then bypasses the auto-escaping mechanism, allowing injection of arbitrary HTML or JavaScript into the rendered template output.

For technical implementation details, see the Go.dev Issue Tracker Entry and the Go.dev Code Change Notice which contains the fix.

Detection Methods for CVE-2024-24785

Indicators of Compromise

  • Unusual error messages in application logs containing HTML or JavaScript code fragments
  • Template rendering errors that include unexpected special characters (<, >, ", ')
  • Web application responses containing unescaped user input in HTML context
  • Reports of XSS attacks originating from template-rendered pages

Detection Strategies

  • Audit Go applications for custom MarshalJSON implementations that may include user input in error messages
  • Review template rendering code paths for potential error handling that exposes marshaling failures
  • Implement Content Security Policy (CSP) headers to detect and mitigate successful XSS exploitation
  • Use static analysis tools to identify vulnerable patterns in Go codebases

Monitoring Recommendations

  • Monitor web application firewall (WAF) logs for XSS attack patterns in request parameters
  • Enable detailed logging for template rendering errors in Go applications
  • Track security advisories from Go and downstream vendors for patch availability
  • Monitor the Go.dev Vulnerability Report GO-2024-2610 for updates

How to Mitigate CVE-2024-24785

Immediate Actions Required

  • Update Go to the latest patched version that addresses CVE-2024-24785
  • Review all custom MarshalJSON implementations to ensure error messages do not include user-controlled data
  • Implement input validation before data reaches MarshalJSON methods
  • Deploy Content Security Policy headers as a defense-in-depth measure

Patch Information

The Go team has released a fix for this vulnerability. The patch is available via the Go.dev Code Change Notice. Organizations should update their Go installations and rebuild affected applications. NetApp customers should refer to the NetApp Security Advisory NTAP-20240329-0008 for product-specific guidance.

For detailed vulnerability information, consult the Golang Announcement on Security.

Workarounds

  • Sanitize or remove user-controlled data from custom MarshalJSON error messages
  • Implement wrapper functions that catch and sanitize marshaling errors before template processing
  • Use the text/template package for non-HTML content where contextual escaping is not required
  • Add explicit output encoding as an additional layer of protection around template rendering
bash
# Check Go version and update
go version
# Update to latest Go version
go install golang.org/dl/go1.22@latest
# Rebuild affected applications after updating Go
go build -a ./...

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechN/A

  • SeverityMEDIUM

  • CVSS Score5.4

  • EPSS Probability0.27%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • Technical References
  • Openwall OSS-Security Discussion

  • Go.dev Code Change Notice

  • Go.dev Issue Tracker Entry

  • Golang Announcement on Security

  • Go.dev Vulnerability Report GO-2024-2610

  • NetApp Security Advisory NTAP-20240329-0008
  • Latest CVEs
  • CVE-2025-70797: LimeSurvey XSS Vulnerability

  • CVE-2025-30650: Juniper Junos OS Auth Bypass Vulnerability

  • CVE-2026-35471: Goshs Path Traversal Vulnerability

  • CVE-2026-35393: Goshs Path Traversal Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English