VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

How Superintelligence Works | Agent XML Signatures — Canonicalization, Wrapping Attacks and Verified References

Did you know? An XML document can pass a cryptographic signature check while the application reads a different unsigned element as its instruction. This is the central danger of XML signature wrapping: proving that some bytes were signed is not enough unless the verifier also proves exactly which business object was covered and passes that verified object into the next step. An AI agent handling signed approvals, procurement files or legacy service messages needs to bind cryptographic validity to the intended element, its location, the authorised signer and the current transaction.

The safe method is to select a supported XML Signature profile, parse with hostile-document protections, resolve each reference without ambiguity, apply only permitted canonicalisation and transforms, validate its digest and signature against a trusted key, then give the application the exact verified subtree rather than searching the document again. Reject duplicate IDs, untrusted external references, unexpected unsigned fields, stale nonces and business actions outside the signature’s scope. Never report that an agent has an authorised approval merely because a library returned a generic ‘signature valid’ boolean.

These are engineering safeguards for current services and supervised AI agents. Artificial superintelligence remains hypothetical. This guide distinguishes what XML digital signatures mathematically protect from what workflow approval requires, and includes illustrative, clearly labelled examples—not claims of a live signature-verification experiment.

Contents

What a digital signature certifies, and what it does not

An XML Signature attaches cryptographic evidence to selected data. Its core structure contains SignedInfo, which describes references, digest methods and signature methods, and SignatureValue, which signs canonicalised SignedInfo. Each reference points to some content and describes how to transform or canonicalise it before hashing. The verifier must check both the reference digests and the signature over SignedInfo. A successful cryptographic check establishes a relation among those bytes, a verification key and the configured algorithms, not the whole business meaning of a document.

The W3C Recommendation XML Signature Syntax and Processing Version 1.1 specifies the syntax and core verification rules. Its scope is deliberately narrower than a complete trust-policy or application-authorisation protocol. A signature can be technically valid even if the signer was not allowed to approve the particular purchase, the signed field was already revoked, or the application read an unsigned sibling as the amount to charge.

Consider an invoice processing agent. The signed object says invoice 42 has an approved total of 120 currency units. A nearby unsigned field says 1,200. If the signature validator checks the 120-unit object but a document parser passes the 1,200-unit field into payment logic, the mathematical signature result and the operational action refer to different data. Cryptographic integrity has not failed; integration between the verifier and the application has failed.

The crucial questions are therefore: which exact element did the signer intend to authenticate? Which node was actually selected by each reference? What signer identity and key policy are trusted? Was the signed object current for this action? And did the agent act only on the verified node? These questions are not interchangeable with ‘does the document contain a Signature element?’ or ‘did a cryptographic API return true?’

This topic differs from PDF signatures, where revision boundaries and byte ranges are often central. For the related format, consult Agent PDF Digital Signatures. XML signatures bring their own reference-selection, namespace, transform and wrapping issues.

Read SignedInfo as a constrained data-binding contract

Start from the SignedInfo element, because that is what the signer cryptographically authenticates. It names a canonicalisation method for itself, a signature method and one or more references. Each reference typically contains a URI or other resource-selection mechanism, optional transforms, a digest method and a digest value. The verifier reconstructs the covered byte representation and compares the digest with the declared value. A separate signature check then validates SignedInfo against the trusted key.

An application should define what it expects before accepting a signature. For example, the business contract might require one reference covering the Approval element whose ID matches the task being executed, with an approved digest algorithm and no external network reference. A signature of a different element is not equivalent, even when the cryptographic operation succeeds. The reference list should be reviewed as an inventory of what is protected and what remains outside it.

Enveloped signatures sit within the content they cover, enveloping signatures contain the content inside a Signature structure, and detached signatures refer to external content. These arrangements differ in reference handling and attack surface. A parser that was written only for one pattern should not quietly accept another because it recognises a familiar tag name. Profile negotiation is an explicit security decision, not a convenience fallback.

XML namespaces also matter. Two elements may display the same local name while belonging to different namespace URIs, making them different qualified names. Matching only the visible word Approval can select the wrong element. Prefixes are not authoritative identities; namespace URI plus local name and the expected structural position matter. If schema and application models differ, the document can become internally ambiguous despite being well-formed XML.

The W3C XML Signature Best Practices explicitly recommends that applications learn what was signed, verify intended element names and positions, and avoid dangerous transform or retrieval behavior. Treat that guidance as an integration requirement rather than optional commentary appended after a cryptographic library is installed.

Canonicalization makes byte comparison meaningful

XML permits several surface spellings that may represent equivalent parsed structures. Attribute ordering can differ, namespace prefixes can change presentation, and line-ending conventions can vary. A cryptographic digest, however, is calculated over bytes rather than human interpretation. Canonicalisation converts the relevant XML representation into a deterministic byte sequence under an explicitly chosen algorithm, so signers and verifiers can compute matching digests for equivalent permitted forms.

That normalisation is not a blanket licence to rewrite anything. Different canonicalisation algorithms handle namespaces, comments and inherited context in specific ways. If a verifier applies the wrong method, a legitimate signature can fail. If an application relies on a broader equivalence than the signature actually covers, it can wrongly assume changes were authenticated. Record the exact canonicalisation URI rather than saying the system ‘normalises XML’ as though there were one universal operation.

Suppose an application receives an element with two attributes written in the order b then a, while the signer processed a then b. The canonicalised sequence may put attributes in a consistent order under the selected algorithm, allowing verification. But changing the actual value of the payment amount must still change the covered bytes and invalidate its digest, unless that amount was outside the signed selection. This is the boundary between harmless representational variation and consequential content alteration.

Unicode and parser configuration introduce further subtleties. The W3C specification explains that canonical XML algorithms do not necessarily perform character normalisation and require care with external entities and schema-induced defaults. If a sender and receiver transform data differently before signature validation, the same-looking document can produce different digests. An agent should not repair a failed signature by casually trying arbitrary Unicode substitutions or dropping suspicious nodes.

Instead, log the supported canonicalisation method, carefully bound parsing context and digest outcome, without exposing private content unnecessarily. If an otherwise trusted message fails validation after a harmless-seeming reserialization, investigate which transformation changed the covered data. Correct the producing pipeline or agreed profile; do not accept a mismatched signature merely because the business action seems plausible.

How a wrapping attack tricks the business reader

Imagine a document with one signed Approval element stored inside a Signature Object and another prominent Approval element outside it. Both have the same local name. The signed one contains a modest authorised amount; the outside one contains an attacker-selected amount. A library validates the reference to the inner element. The application then uses a simple descendant search for the first Approval element and selects the outer element. It acts on unsigned information while logging ‘signature valid’.

The W3C best-practices document presents a wrapping-attack example in which a reference to one ID points at a different Approval element from the one application code reads. Its recommendation is to check more than the name of the element: its position and business identity must also match the expected object. Signature verification and application extraction must share the exact same resolved node, not perform independent loose searches.

Duplicate ID handling is particularly dangerous. If two nodes claim the same identifier and different parts of the system choose different ones, the reference resolver and business parser can disagree. An accepted profile must define which attributes have ID semantics, enforce uniqueness in the relevant document, and reject ambiguous documents. The application should not guess which duplicate is intended or use an arbitrary first-match rule.

External reference retrieval can be risky too. A signature profile may reference remote resources or permit transforms with substantial computational cost. Validating a document supplied by an untrusted sender should not grant permission to fetch arbitrary internal URLs or run unrestricted XSLT or XPath operations. The best-practices guidance recommends limiting dangerous transforms, controlling external references and checking key trust before expensive or hazardous processing where appropriate.

The defensive outcome is an object-bound verifier interface. Instead of returning only true, a verifier returns a typed, immutable representation of the exact authorised Approval node, accompanied by the validated reference identifier, signer information and checked business constraints. If it cannot prove that binding, it returns an explicit failure or abstention. An agent must never manufacture an approval from an ambiguous signature.

Trust in the signer is a separate decision from valid mathematics

A public-key signature can be checked with a public key, but the system must know whether that key belongs to a permitted actor for the task. A key embedded in the submitted XML is not trustworthy merely because the signature can be verified with it. An attacker can produce a perfectly valid signature under their own key over their own malicious instructions. Key authenticity, certificate path validation and authority scope need an independently configured source of trust.

For a business approval system, permitted roles might distinguish reviewers, purchasers and accounting staff. The XML Signature component establishes who could have signed under an accepted key, subject to its trust model. The business authorisation component decides whether that actor could approve this particular change, for this resource, at that revision and amount. An approval for one workflow is not transferable to every other workflow.

Trust also changes over time. A signing certificate may expire, a user’s role may be revoked, or the workflow may have been superseded. A long-lived signed document may require different archival validation evidence from a fresh transactional instruction. Do not infer present authorisation merely from a cryptographically valid historical signature; distinguish signature creation time, trusted timestamp evidence, revocation policy and the business deadline.

Implementers should review the W3C guidance on KeyInfo processing and retrieval methods. An untrusted key-resolution pointer can create unwanted network requests or infinite resolution chains if followed without restrictions. Keep allowed algorithms and trusted identities in configuration controlled by an authorised owner rather than letting the document declare that any self-supplied key is acceptable.

The final approval decision should therefore have at least two layers: cryptographic binding of a trusted signature to a precise object and business verification that the identified signer and object satisfy current policy. A system that conflates these layers may be technically correct about cryptography and seriously wrong about authorisation.

Worked case: 1,000 signatures and three different failure boundaries

Consider a fictional test batch of 1,000 signed order messages. The system first checks technical signature validation under its permitted profile. It finds 970 with passing digests and accepted signature algorithms, and 30 that fail these checks. The technical pass rate is 970/1,000 = 97%, while the technical rejection rate is 30/1,000 = 3%. Those are not yet business authorisation rates.

Next, the application requires the verified reference to bind uniquely to the business Approval element intended for action. Of the 970 technically passing messages, 20 fail the application binding rule because the reference selection is unexpected or ambiguous; 950 satisfy it. The binding pass fraction among cryptographically passing messages is 950/970 ≈ 97.94%. Across all incoming messages it is 950/1,000 = 95%. Both figures are correct, but they have different denominators.

Finally, of those 950 exactly bound messages, 45 have stale or unauthorised actions under the current task ledger, leaving 905 eligible actions. The business-eligible fraction among bound messages is 905/950 ≈ 95.26%; the end-to-end eligible fraction among incoming messages is 905/1,000 = 90.5%. The total non-eligible count is 30 + 20 + 45 = 95, and 905 + 95 = 1,000. This arithmetic shows why a successful cryptographic stage does not prove a successful transaction.

The 30 signature failures should be investigated differently from the 20 binding failures. A failed digest may indicate corruption, wrong canonicalisation profile or tampering. An unexpected signed element can indicate a format mismatch or a wrapping attempt, even while digest validation passes. A stale task may indicate legitimate historical data rather than a hostile document. One generic ‘invalid signature’ label would obscure the cause and lead to the wrong repair.

Suppose an operator instead announced 97% of orders are safe because the first cryptographic stage passed. That claim would ignore 65 subsequent exclusions, overstating eligible actions by 6.5 percentage points in the illustrative batch. But even the 90.5% eligible rate is not proof that all 905 were executed; execution should be audited separately. All counts here are invented, not measured from an operational signature service.

Prevent replay of perfectly signed old instructions

A valid signature can be copied and submitted again. Replaying a previously approved action is not necessarily a cryptographic forgery; the same signed bytes can still verify. If the signed object requests an action with side effects, the application must decide whether the signed request has already been consumed, superseded or expired. A repeat approval must not create duplicate payments, messages or changes.

Bind a stable task ID, revision or business nonce to the signed content under a well-defined profile. A server-side ledger can record accepted uses and reject duplicates. When a timestamp is part of the policy, it must itself be covered by the signature; an attacker must not be able to modify an unsigned validity period. The W3C best-practices document describes signing time and nonce techniques for replay resistance.

Do not confuse a signature-generation timestamp with an immutable assertion of current user permission. A valid signed approval from last month may be evidence of a historical decision, but the task might have been cancelled in the meantime. The agent should fetch authoritative current state before acting. When two services process the same message concurrently, the ledger update and consequential action should have a clear atomicity and retry model.

A single-use key alone is not a universal solution. If a transport is interrupted after a business action committed, the sender may legitimately retry and need a stable result rather than triggering a second action. The workflow can return ‘already completed’ for an identical request while rejecting conflicting new content. That is an idempotency design decision beyond the low-level XML signature algorithm.

The Idempotency and Recovery companion guide explains how to separate uncertain network responses from authoritative action records. XML signatures add evidence about signed intent, not a replacement for action-state reconciliation.

Safe XML parsing and restricted transforms before trusting fields

Before any signature algorithm runs, a document has to be parsed. An attacker-controlled XML parser may encounter large nested structures, entity expansion requests or resource references, depending on supported features. Use an XML library configured to limit resource consumption, disallow unneeded external entities and resolve no arbitrary network references by default. The allowed payload size and depth should be proportionate to legitimate documents.

Signature transforms can be more powerful than they appear. XPath can select subsets of a document; XSLT can transform documents; external URI dereferencing can cross network boundaries. The W3C best-practices guidance recommends minimising attack surface with restricted transform algorithms and reference counts, establishing key trust early and controlling external retrieval. This is especially important for an agent that may have access to internal services.

A verifier should return the exact bytes or immutable parsed object that passed validation. Do not validate one DOM tree and then perform schema normalisation, namespace rewriting or document merging that can alter the meaning before the application acts. If transformations are necessary, decide whether they are inside the signed canonicalisation contract or occur after verification, and document how verified identity survives them.

Typed schema validation can still be useful, but it is not a cryptographic substitute. A schema may reject impossible fields, while a signature binds data to a signer; either can pass while the other fails. Validate the appropriate constraints in a controlled order, as the W3C notes that some validation transforms can alter in-memory representations and break signature checks.

An agent should use parser and verifier error categories for diagnosis: malformed XML, unsupported namespace or signature algorithm, unresolved reference, duplicate ID, digest mismatch, untrusted signer, expired action and missing business permission. Clear categories permit safe repair or escalation without teaching the agent to treat a cryptographic failure as merely an inconvenient formatting bug.

A verifier-to-agent contract that does not lose the signed object

Design the interface so the agent cannot obtain a generic signature-valid flag detached from the verified content. A suitable result may contain the verified document or node identifier, its namespace-qualified type, the approved key identity, the signed task ID, covered field names, the applied profile and the current business validation status. It should not return arbitrary document text as if it had been authenticated.

Some systems need multiple signatures or multiple references, perhaps by different actors. Do not assume that the presence of two successful signatures means they each cover the whole transaction. One may cover the document header and another a related attachment. The application should map which signer authorised which part and whether its policy requires both. Multiple signatures can coexist with unsigned fields that the agent still must not treat as approved.

Separating verified data from explanatory commentary is useful. The user-facing answer can say, ‘The signer authenticated this purchase order at revision seven; the current server state marks it cancelled.’ The action layer receives only a typed and authorised command derived from the verified object and current ledger. Untrusted natural language inside a signed attachment is still data; the signature establishes provenance, not permission for an assistant to obey new instructions from it.

Approval scope must be explicit. If a signature protects an item amount but not the currency or recipient, it cannot safely be used as blanket permission to transfer money. If an agent notices missing protected fields, it should abstain and request a correctly signed record from the workflow owner. Do not fill unsigned gaps by guessing from a neighbouring element.

A typed result makes independent testing possible: an invalid wrapped approval should never produce an eligible command; a valid signature over the wrong task should still be rejected; and an expired but historically genuine signature should remain a valid historical artifact without becoming a new authorisation. These are separate assertions that a well-designed system can check.

Common failure cases and the repair for each

Failure one is selecting elements by their visible local name while ignoring namespaces or expected path. Repair by binding the reference to an exact schema-approved node identity. Failure two is accepting duplicate XML IDs because the cryptographic library and application choose different duplicates. Repair by rejecting ambiguous identifiers before business extraction.

Failure three is trusting a public key supplied by the document without an external key authority. Repair by checking an authorised trust store, allowed signer identities and appropriate certificate policy. Failure four is accepting a signature over only convenient fields while the application later uses unsigned currency, recipient or amount fields. Repair by requiring the intended business-critical elements to be signed together.

Failure five is allowing a signature reference to fetch untrusted remote data or invoke unlimited transformations. Repair by restricting permitted algorithms, URI resolution and resource budgets. Failure six is assuming that a signature proves the request is recent. Repair by signed freshness fields, server-side nonce handling and current workflow-state checks.

Failure seven is processing a second DOM tree rather than the exact verified element. Repair by returning the verified subtree as the only business input. Failure eight is interpreting a successful core cryptographic result as permission to execute an irreversible action. Repair by layering current signer authority, task permissions, review and transaction idempotency.

When any failure occurs, preserve enough information to diagnose the stage without logging private document contents or secrets. A digest mismatch does not establish attacker intent, and a valid signature does not establish benign intent. Avoid dramatic labels unsupported by actual evidence.

The general pattern is consistent: cryptographic verification must be attached to the correct object, and the correct object must be attached to a current authorised task. Each transition is separately checkable and separately fallible.

Changed-context exercise: a signed student transfer form

Transfer the reasoning to a hypothetical school administration system. A signed XML form contains student ID S-17, programme choice P-2 and an approval at revision four. The same XML envelope also carries an unsigned display note naming programme P-3. The signature library confirms the digest over the revision-four form. A naïve application searches for the last programme code anywhere in the XML and chooses P-3.

Which action is authorised by the signature? Only the precise data bound to the valid signed form, subject to trusted signer and current permissions. The unsigned note is not evidence of approval for P-3. If a legitimate process requires changes after signing, it must issue a new authorised form or define an explicitly signed amendment mechanism. The existence of a human-readable hint cannot extend the signed scope.

Now add a timing change. The server shows revision five superseded revision four yesterday. The revision-four signature can still be genuine historical evidence, but the requested action is stale. The system should report that revision five requires separate review rather than silently applying revision four or claiming the signature has expired cryptographically when the actual problem is workflow versioning.

Assume 240 forms arrive in a teaching exercise; 228 pass cryptographic checks, 220 bind to the intended signed form, and 210 remain authorised after revision checks. Technical acceptance is 228/240 = 95%; exact binding among technical passes is 220/228 ≈ 96.49%; current business eligibility across the full input is 210/240 = 87.5%. The ten forms that passed binding but failed current authorisation are not evidence of signature forgery.

The lesson transfers across procurement, school records, regulated XML exchanges and agent workflows. Ask which bytes were signed, which business object those bytes represent, what authority the signer had and whether the action is still valid. This method is more reliable than attaching one green tick to an entire document.

Meaningful limitations and unavoidable design choices

XML Signature has multiple deployment profiles and long-lived interoperability requirements. An application built around one permitted subset cannot assume every possible transform, algorithm and certificate model is safe to accept. Reject unsupported configurations explicitly and document how conformant senders can interoperate. The W3C XML Signature 1.1 Recommendation is normative for that version; the separate 2.0 document is a Working Group Note, not a universal declaration that every installation must migrate.

Canonicalisation does not repair semantic ambiguity. Two different-looking XML trees might contain the same business content, yet the application still needs a uniquely identified authorised object. Nor does a valid signature establish what was on a human screen, whether a user understood the terms or whether the signer was acting without coercion. Those are separate workflow questions.

Key revocation, historical proof, nonce retention and logging may have jurisdiction- or industry-specific requirements. A generic software tutorial cannot authorise a real financial, medical or educational transaction. Consult the appropriate technical and institutional owners for the actual trust policy and record-retention obligations.

Resource restrictions can reject some otherwise legitimate complex signed documents. That is a consciously chosen compatibility trade-off. A safe application should explain unsupported profiles to its operator and route them to review rather than silently weaken security until the file passes.

The numerical scenarios here are fictional. No XML signature was generated, attacked or verified during authoring. The facts being taught concern standards-defined structure and risk boundaries, not a claimed penetration-test result.

Frequently asked questions

What does XML signature validation prove? Under a trusted key and supported profile, it verifies selected referenced content and the signed metadata describing those references. It does not automatically prove that every element in a larger XML document is protected or that the signer may perform the requested action.

What is an XML signature wrapping attack? It is a mismatch where validly signed content is present but the application consumes another, unsigned or differently placed element as if it were the signed object. Strong reference-to-application binding is the defence.

Does canonicalisation encrypt XML? No. It prepares a deterministic representation for signing and digest verification. XML signatures provide integrity and origin-related evidence under the key policy, not confidentiality.

Can duplicate IDs be harmless? A general XML document might accidentally contain duplicate-looking labels, but ambiguous reference identifiers in a signed workflow are unsafe. Reject duplicate or unexpected IDs under the signature profile before authorising action.

Is KeyInfo proof of signer identity? Not by itself. A document may carry key information that must be authenticated through independent policy or trusted certificates before business authority is granted.

Why not fetch external references to see whether they validate? Unrestricted retrieval exposes internal services, side effects, privacy and resource risks. Permit only necessary well-constrained references under an approved profile.

Can a historically valid signature approve a new action? Only if current business rules explicitly allow that action. A genuine old signature can be rejected for task expiry, revision mismatch or duplicate consumption.

What is the simplest safe agent rule? Use the exact verified signed object, confirm the expected signer and covered fields, check current task authority and do not execute when any part is ambiguous.

Source standards and reader pathways

If you implement XML verification, start with the W3C XML Signature 1.1 Recommendation for reference and core validation semantics, and the W3C XML Signature Best Practices for wrapping, transform, key-handling and replay risks. Choose a maintained XML security library that supports the exact approved profile; do not invent a signing algorithm from scratch.

If you review an agent service, request a test showing that validly signed but irrelevant XML cannot authorise a business action. Ask for duplicate-ID rejection, trusted-key configuration, permitted transform lists, exact covered-field records, nonce replay checks and a server-side transaction receipt. The test should verify the same object reaches the application that the signature library authenticated.

If you are learning secure systems, work through the 1,000-message funnel. Label the denominator at each stage, then ask why a 97% cryptographic acceptance rate can coexist with 90.5% business eligibility. Explain why signatures, parsing and authority checks are different forms of evidence. This is a transferable skill for any system where a correct component can be connected to an incorrect overall conclusion.

For related concepts continue through Agent File Ingestion, PDF Digital Signatures and the broader How Super Intelligence Works hub. The shared goal is proof of the actual authorised outcome rather than confidence in a single intermediate API result.

Discover more from eduKate Singapore

Subscribe now to keep reading and get access to the full archive.

Continue reading