You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(xmldsig): generate exclusive canonicalization, honour implicit one and declined recipients - #488
Signing completes a Reference whose chain ends in a node set with an explicit Exclusive C14N transform: XMLDSig 1.1 section 3.1.1 asks generators not to rely on the implicit conversion and names C14N 1.1 only where inclusive canonicalization is desired, while Exclusive C14N is verified by libxmlsec1, .NET and Java alike and keeps a signed subset independent of its ancestors' namespaces and xml:* attributes.
The template builder honours a signing policy that leaves a node set's conversion implicit: it writes no generated transform for such a Reference (XMLDSig 1.1 section 4.4.3.2), so a builder template matches what the policy signs.
A decryption whose resolver declines the EncryptedKey recipients neither preflights nor resolves any recipient, inline or reached through a RetrievalMethod.
RustCryptoRsaPublicKey::from_spki_der refuses an id-RSASSA-PSS key, which RFC 4055 section 1.2 reserves for signatures, as a key-transport key.
An internal subset written back out keeps an attribute default holding a quote a valid literal (XML 1.0 section 2.3), so a fragment parsed with the document's subset sees it.
Changes
GeneratedCanonicalization::ExplicitExclusiveC14n (formerly ExplicitC14n11) is the default of every profile; signing and SignatureBuilder write the transform from one shared mode. The libxmlsec1 C library and the xmlsec1 command keep the implicit conversion.
SignatureBuilder passes the policy's generated_canonicalization to the transforms it writes and validates.
CipherReferenceContext carries the operation's recipient decision into metadata parsing; a declined recipient's method and CipherReference are neither admitted nor resolved, while the content CipherReference keeps its checks.
A key-transport key is read from an rsaEncryption SPKI alone; signature verification keeps accepting both identifiers.
The libxmlsec1 oracle pin follows upstream master, with the C library behaviour it brought: xmlSecReplaceNodeAndReturn refuses a replacement by the node itself, a node of another kind or a relative of the node, so an XML encryption whose template lies inside the element it encrypts is refused and leaves the template unwritten; xmlSecTmplTransformAddRsaOaepParam writes an empty OAEPparams for empty parameters; key unwrap and RSA key transport decryption, and key derivation and agreement transforms, mark the buffers holding keys as secure; a Base64 node read that fails to decode leaves the buffer empty; the xmlsec1 command keeps a dotfile input name whole in an output template.
Testing
Tests, lints and formatting run in CI on macOS, Linux and Windows.
Signing inserts and materializes Exclusive C14N for eligible reference chains. Tests and documentation cover generated transforms and Implicit mode, which adds no generated transform.
DTD attribute default serialization
Layer / File(s)
Summary
Default literal serialization and fragment test src/parser_xmloxide/validation/dtd.rs, src/document/owned_tree/tests.rs
Default literals select a quote delimiter that is absent when possible. If both quote types occur, embedded double quotes are escaped. A fragment test covers ordinary and #FIXED defaults.
RSA transport-key parsing
Layer / File(s)
Summary
SPKI parsing rules and provider validation src/rsa_encoding.rs, src/provider.rs, tests/rsa_encoding.rs
The transport-key parser rejects id-RSASSA-PSS SPKIs while accepting rsaEncryption SPKIs. The general RSA public-key decoder continues to accept the tested PSS-labeled key.
Declined encrypted-key recipients
Layer / File(s)
Summary
Recipient state and encrypted-key processing src/xmlenc/cipher_reference.rs, src/xmlenc/decrypt.rs, src/xmlenc/parse.rs, tests/cipher_reference.rs
The decryption context records when recipients are declined. In that case, encrypted-key retrieval and preflight skip nested cipher-reference processing. Tests cover direct-key decryption when an unused recipient contains an unresolved or disallowed reference.
xmlsec transform and buffer handling
Layer / File(s)
Summary
Secure buffer marking and checks crates/xml-sec-xmlsec1/src/ffi/transforms.rs, crates/xml-sec-xmlsec1/src/ffi/transforms/ciphers.rs, crates/xml-sec-xmlsec1/src/ffi/transforms/transport.rs, crates/xml-sec-xmlsec1/src/ffi/transforms/*/tests.rs, crates/xml-sec-xmlsec1/tests/c/ciphers.c
Selected key-derivation, key-agreement, key-wrap, and decryption paths mark buffers secure. Rust and C tests inspect output-buffer security state.
Encryption refuses templates inside replaced content. Node replacement rejects identical, different-kind, and ancestor/descendant node pairs before changing the tree.
xmloxide parser and DTD patch
Layer / File(s)
Summary
Storage-aware DTD parsing and validation scripts/patches/xmloxide-0.5.0.patch, src/parser_xmloxide/documentation_tests.rs
The patch moves DTD parsing and validation to storage-aware, fallible operations. Entity and content-model traversal use iterative processing. Tests cover limits, long chains, and serialization.
Compatibility records and headers
Layer / File(s)
Summary
Backend capability records and header comments compatibility/libxmlsec1.json, compatibility/libxmlsec1-donor-commit.txt, crates/xml-sec-xmlsec1/include/xmlsec/exports.h
The compatibility snapshot separates AWS-LC and BoringSSL capability conditions and adds a backend API item. The donor commit identifier and two header comments also change.
structured-world/xml-sec#485: This stacked follow-up changes encrypted-key recipient handling in the same processing path.
Merge Risk: Minimal · up to b933c
This change switches generated signature canonicalization to Exclusive C14N, skips unused decryption recipients, and tightens several key-handling and tree-replacement checks. Targeted tests cover each behavior and no merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: signing now generates an explicit Exclusive C14N transform, replacing C14N 1.1 (ExplicitC14n11 renamed to ExplicitExclusiveC14n in src/policy.rs and src/xmldsig/sign.r…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: signing now generates an explicit Exclusive C14N transform, replacing C14N 1.1 (ExplicitC14n11 renamed to ExplicitExclusiveC14n in src/policy.rs and src/xmldsig/sign.rs). It also names the implicit-mode behavior (no generated transform when conversion stays implicit) and the declined-recipients decryption change, both of which appear in the changeset. The title is specific and accurate, though long at 95 characters and covers several changes beyond the main one.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between a84fbf2 and b933c15.
Files selected for processing: 10
compatibility/libxmlsec1-donor-commit.txt
compatibility/libxmlsec1.json
crates/xml-sec-xmlsec1/src/ffi/buffer.rs
crates/xml-sec-xmlsec1/src/ffi/buffer/tests.rs
crates/xml-sec-xmlsec1/src/ffi/errors.rs
crates/xml-sec-xmlsec1/src/ffi/errors/tests.rs
crates/xml-sec-xmlsec1/tests/c/keysdata.c
tests/capability_ledger.rs
tools/xmlsec1/src/commands.rs
tools/xmlsec1/tests/process_contract.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
polaz
changed the title
fix(xmldsig): honour implicit canonicalization and declined recipients
feat(xmldsig): generate exclusive canonicalization, honour implicit one and declined recipients
Nov 18, 2026
…ne and declined recipients
- Signing completes a Reference whose chain ends in a node set with an
explicit Exclusive C14N transform: XMLDSig 1.1 section 3.1.1 asks
generators not to rely on the implicit conversion and names C14N 1.1
only where inclusive canonicalization is desired, while Exclusive C14N
is verified by libxmlsec1, .NET and Java alike and keeps a signed subset
independent of its ancestors' namespaces and xml:* attributes. The
template builder writes the same transform from one shared mode, and
honours a policy that leaves the conversion implicit.
- A decryption whose resolver declines the EncryptedKey recipients neither
preflights nor resolves any recipient, inline or reached through a
RetrievalMethod.
- RustCryptoRsaPublicKey::from_spki_der refuses an id-RSASSA-PSS key,
which RFC 4055 section 1.2 reserves for signatures, as a key-transport
key.
Part of #474
An internal subset written back out put every attribute default between
double quotes, so a default declared as 'say "hi"' became an invalid
literal and a fragment parsed with the document's subset failed. The
default is written between quotes it does not contain (XML 1.0 section
2.3), with a regression test through a fragment parsed in context.
Part of #474
The maintained xmloxide source is checked against the upstream crate
plus scripts/patches/xmloxide-0.5.0.patch, so the attribute default
literal fix in validation/dtd.rs belongs in that delta. The delta is
regenerated with the import script, which also moves the line numbers
the embedded documentation examples cite.
Part of #474
The oracle pin moves to upstream 6a6dd7ef, and the C library takes the
behaviour upstream changed since c62324b3:
- xmlSecReplaceNodeAndReturn refuses a replacement by the node itself,
by a node of another kind, or by an ancestor or descendant of the
node, before anything moves. An XML encryption whose Element template
lies inside the element it encrypts is therefore refused, as a
Content template inside its content already was, and leaves the
template unwritten; the admission no longer measures that case apart.
- xmlSecTmplTransformAddRsaOaepParam takes no buffer and no size as
empty parameters and writes an empty OAEPparams.
- Key unwrap and RSA key transport decryption mark their output buffer
as holding a secret, and a key derivation or agreement transform is
created with both buffers marked, as libxmlsec1 marks them. Every
buffer was already wiped; the flag is what xmlSecBufferIsSecure
reports.
Upstream's node set namespace walk rewrite and its typed list item
methods need no change here: the walk differs only on an explicit
xmlns:xml declaration, which the tree never holds, and the list klasses
are typed. The ledger, the capability counts and exports.h follow the
new revision.
Tests: regression tests for each behaviour; the differential C programs
compare the secure flags, a replacement by a relative and empty OAEP
parameters with the oracle.
Part of #474
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
scripts/patches/xmloxide-0.5.0.patch-8977-8977: 1
8977-8977: Minor · Performance & Scalability · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Admit work before scanning the default literal.
If the remaining serialization allowance covers only the declaration prefix, a large quote-free default is still scanned completely by contains before the next output write reports refusal. The new quote-selection scans have no work charge. Output formatting does not admit those earlier scans. (raw.githubusercontent.com)
Charge the scan work before each contains and before the split traversal, as write_entity_value does. Add a low-allowance test with a large retained default. This preserves the generated literal when sufficient work is available. (raw.githubusercontent.com)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The oracle pin moves to upstream ba711db9, and the C library and the
xmlsec1 command take the behaviour upstream changed since 6a6dd7ef:
- The message replacing one too long to format reads "Cannot format
error message".
- xmlSecBufferBase64NodeContentRead leaves the buffer empty when the
node content fails to decode, instead of resized over partly decoded
bytes.
- An output template's {inputfile} keeps a dotfile name such as
".hidden" whole: a leading dot is not an extension separator.
Upstream's refusal of an ECKeyValue whose NamedCurve is empty after the
urn:oid: prefix is already the core parser's; its BN node value change
touches functions this library does not implement. The ledger and its
category counts follow the new MSCrypto DES setter.
Tests: regression tests for each behaviour; the differential keysdata
program compares a failed Base64 node read with the oracle.
Part of #474
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Referencewhose chain ends in a node set with an explicit Exclusive C14N transform: XMLDSig 1.1 section 3.1.1 asks generators not to rely on the implicit conversion and names C14N 1.1 only where inclusive canonicalization is desired, while Exclusive C14N is verified by libxmlsec1, .NET and Java alike and keeps a signed subset independent of its ancestors' namespaces andxml:*attributes.EncryptedKeyrecipients neither preflights nor resolves any recipient, inline or reached through aRetrievalMethod.RustCryptoRsaPublicKey::from_spki_derrefuses anid-RSASSA-PSSkey, which RFC 4055 section 1.2 reserves for signatures, as a key-transport key.Changes
GeneratedCanonicalization::ExplicitExclusiveC14n(formerlyExplicitC14n11) is the default of every profile; signing andSignatureBuilderwrite the transform from one shared mode. The libxmlsec1 C library and thexmlsec1command keep the implicit conversion.SignatureBuilderpasses the policy'sgenerated_canonicalizationto the transforms it writes and validates.CipherReferenceContextcarries the operation's recipient decision into metadata parsing; a declined recipient's method andCipherReferenceare neither admitted nor resolved, while the contentCipherReferencekeeps its checks.rsaEncryptionSPKI alone; signature verification keeps accepting both identifiers.xmlSecReplaceNodeAndReturnrefuses a replacement by the node itself, a node of another kind or a relative of the node, so an XML encryption whose template lies inside the element it encrypts is refused and leaves the template unwritten;xmlSecTmplTransformAddRsaOaepParamwrites an emptyOAEPparamsfor empty parameters; key unwrap and RSA key transport decryption, and key derivation and agreement transforms, mark the buffers holding keys as secure; a Base64 node read that fails to decode leaves the buffer empty; thexmlsec1command keeps a dotfile input name whole in an output template.Testing
Tests, lints and formatting run in CI on macOS, Linux and Windows.
Part of #474
Summary by CodeRabbit