Skip to content

feat(xmldsig): complete transform coverage - #103

Open
polaz wants to merge 165 commits into
mainfrom
test/#100-phaos-negative-vectors
Open

feat(xmldsig): complete transform coverage#103
polaz wants to merge 165 commits into
mainfrom
test/#100-phaos-negative-vectors

Conversation

@polaz

@polaz polaz commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • classify the imported Phaos negative XMLDSig artifacts at their actual digest, structure, weak-key, and certificate-validity boundaries
  • implement the XMLDSig Base64 transform for binary and exact node-set text input across parsing, building, signing, verification, and policy enforcement
  • implement safe-Rust XPath 1.0 and XPath Filter 2.0 with exact tree, attribute, and namespace nodes, XMLDSig-mandated per-node unit contexts, bounded expression complexity and whole-signature parse cardinality across SignedInfo and authenticated Manifests, namespace storage, cumulative node-evaluation work aware of repeated child-axis branches, path composition, and parent-axis traversal, metered custom-function ancestor scans, comparison-, numeric-coercion-, custom-function-, and repeated-string-operation-aware cumulative string-processing work, preflighted SXD mirror copying, standard functions, and single-pass subtree set projection
  • implement standards-default <XPath> semantics for here() plus explicit libxmlsec1 <Transform> compatibility in signing and verification
  • fail closed on ambiguous XPath id() values, XML 1.0-invalid XPath text or namespace bindings, reserved namespace bindings, namespaced ID mismatches, and parsed here() locations reused with another document while preserving the implicit XPath xml context and C14N 1.1 xml:id non-inheritance
  • retain parsed here() provenance with lazy parse- and pointer-keyed execution-chain document identity caches, hashing each live XML document at most once per phase and skipping execution hashing entirely when no parsed provenance requires it
  • bound exact node-set materialization through every public and internal constructor, share cumulative owned-string materialization limits across URI dereference, XPath projections, and binary adapters for the complete signature, preflight every string copied into temporary SXD mirrors, and enforce signature-wide work limits while excluding subtrees without materializing attacker-controlled removal sets
  • bound cumulative raw and per-transform decoded XMLDSig Base64 data before allocations, retain amortized growth for fragmented node sets, and follow RFC 2045 by ignoring non-alphabet transform bytes
  • enforce cumulative explicit and implicit terminal canonical output while bytes are serialized across each signature, batching unchanged C14N text runs through the bounded writer to prevent per-byte checks while still preventing oversized transient buffers and capping recursive binary-to-node-set adapter retention
  • adapt UTF-8 and BOM-marked UTF-16 XML octet streams to comment-preserving node sets for subsequent XPath, Filter 2.0, canonicalization, and enveloped-signature transforms
  • preserve the exact owning <Signature> across filtered canonicalization and reparsing by tracking its emitted byte position instead of mutable sibling indices, while clearing stale identity when binary transforms replace the source document
  • make template builders reject transform chains and XPath parameters that parsing or execution cannot accept, including inherited namespace bindings on every serialized XPath element
  • process Manifest references only after their complete XML structure is authenticated by a SignedInfo reference with a structure-preserving canonicalization chain and SignatureValue succeeds; reject filtered or binary chains as Manifest authentication, skip parsing on any core validation failure, and report Manifest validity separately from the core signature status
  • extend subset canonicalization to preserve exact node visibility, selected axes of omitted elements, first-discontinuity namespace redeclaration, hidden xml:base context across selected element owners, version-specific xml:id inheritance, document-level separators, and all 28 Merlin canonical outputs byte-for-byte
  • enforce XPath grammar whitespace at expression boundaries instead of accepting broader Unicode whitespace
  • add end-to-end signing, negative-path, tampering, donor-vector, and reciprocal xmlsec1 1.3.12 interoperability coverage, including non-well-balanced canonical octets from selected axes without their owner
  • reposition the README around the project's pure-Rust libxmlsec1 replacement goal, publish an accurate implementation matrix, move detailed XMLDSig and XMLEnc guidance into focused package documentation, and compile-test the published XML Encryption examples
  • document the crate's explicit SHA-256/MGF1-SHA-256 RSA-OAEP wire defaults separately from XMLEnc 1.1's implicit legacy defaults

Validation

  • cargo check --all-targets --all-features
  • cargo check --no-default-features --features c14n
  • cargo check --no-default-features --features xmldsig
  • cargo check --examples --all-features
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo nextest run --all-features (785 passed)
  • cargo test --doc --all-features (6 passed)
  • cargo fmt --all -- --check
  • RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps
  • cargo package --all-features --allow-dirty
  • cargo update --dry-run (5 Rust 1.92-compatible updates available; library lockfile is not tracked)

Closes #100
Closes #101
Closes #102

- classify Phaos negative signature and certificate vectors
- implement Base64 reference transforms end to end
- add exact XPath 1.0 and XPath Filter 2.0 node sets
- validate Merlin canonical subsets and reciprocal xmlsec1 interop

Closes #100
Closes #101
Closes #102
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • src/xmldsig/xpath.rs
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d41c46e1-e3b2-4efb-8d06-9a4068c46221

📥 Commits

Reviewing files that changed from the base of the PR and between 884b140 and 94446ab.

📒 Files selected for processing (1)
  • src/xmldsig/xpath.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added Base64, XPath 1.0, and XPath Filter 2.0 transforms for XML signatures.
    • Added configurable XPath here() semantics, visibility-aware canonicalization, UTF-16 XML support, and explicit RSA-OAEP SHA-256 parameters.
  • Bug Fixes

    • Corrected xml:id inheritance, namespace handling, and XML base resolution in canonicalized subsets.
    • Improved bounded canonicalization and decoded-XML processing.
  • Security

    • Added safeguards for references, transforms, XPath evaluation, node-set sizes, namespaces, and Base64 data.
  • Documentation

    • Added XMLDSig and XMLEnc guides with usage examples.

Walkthrough

The change adds Base64, XPath 1.0, and XPath Filter 2.0 XMLDSig transforms, exact node-set tracking, visibility-aware canonicalization, configurable here() semantics, bounded processing, and expanded interoperability, documentation, and negative-vector coverage.

Changes

XMLDSig transform and canonicalization flow

Layer / File(s) Summary
Visibility-aware canonicalization
src/c14n/*
Canonicalization tracks element, attribute, and namespace visibility. It renders selected axes from omitted elements and updates C14N 1.1 XML attribute inheritance and xml:base behavior.
Exact node sets and XPath evaluation
src/xmldsig/types.rs, src/xmldsig/xpath.rs
NodeSet stores exact projected nodes. XPath evaluation supports XMLDSig functions, namespace bindings, bounded work, and ordered Filter 2.0 operations.
Transform parsing and execution
src/xmldsig/transforms.rs, src/xmldsig/whitespace.rs
Base64, XPath, and XPath Filter 2.0 transforms use strict parsing, bounded execution, binary-to-node-set adaptation, and visibility-aware canonicalization.
Public APIs and signing/verification
src/xmldsig/{mod,parse,builder,sign,verify}.rs, Cargo.toml
New transform types and URIs are exported. Reference parsing and builder validation are stricter. Signing and verification carry transform options and shared budgets. Safe XPath dependencies are enabled.
Validation and documentation
tests/*, README.md, docs/*, src/xmlenc/*
Tests cover transform behavior, signing, verification, tampering, C14N golden vectors, xmlsec1 interoperability, Phaos rejection boundaries, fixture completeness, XML validation, and XML encryption serialization.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Reference
  participant parse_transforms
  participant execute_transforms_with_options
  participant XPathEngine
  participant NodeSet
  participant canonicalize_with_visibility
  participant VerifyContext

  Reference->>parse_transforms: parse Base64/XPath/XPathFilter2
  VerifyContext->>execute_transforms_with_options: execute with TransformOptions
  execute_transforms_with_options->>XPathEngine: evaluate XPath or Filter 2.0
  XPathEngine->>NodeSet: project selected nodes
  execute_transforms_with_options->>canonicalize_with_visibility: canonicalize visible nodes
  canonicalize_with_visibility-->>VerifyContext: return pre-digest bytes
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The XML Encryption documentation, RSA-OAEP documentation change, and XML Encryption integration test are unrelated to issues #100, #101, and #102. Move the XML Encryption changes to a separate pull request or link them to an issue that defines their required scope.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address the requirements in issues #100, #101, and #102, including negative vectors, Base64, XPath, limits, interoperability, and typed failures.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly and concisely identifies the main change: completing XMLDSig transform coverage.
Description check ✅ Passed The description directly explains the XMLDSig transform, security, testing, documentation, and interoperability changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/#100-phaos-negative-vectors

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR completes XMLDSig transform support and expands canonicalization behavior. The main changes are:

  • Base64, XPath 1.0, and XPath Filter 2.0 transforms.
  • Exact element, attribute, and namespace node-set handling.
  • Bounded XPath evaluation and node-set materialization.
  • Stricter parsing, template building, and namespace validation.
  • Improved C14N subset, XML base, and document separator handling.
  • Expanded negative-vector and xmlsec1 interoperability tests.

Confidence Score: 5/5

This looks safe to merge.

No blocking issues found in the changed code.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the focused test command from the repository; it completed with exit code 0 and reported no failed, ignored, measured, or filtered tests.
  • The xmlsec1 target ran and completed successfully; CLI-dependent paths printed the explicit skip condition.
  • A separate availability check confirmed xmlsec1 is not installed (exit code 127), blocking only external reciprocal CLI execution.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/c14n/serialize.rs Adds exact node visibility, orphan axis processing, document separators, and revised XML attribute inheritance.
src/c14n/ns_common.rs Tracks visible namespace bindings separately from source namespace scope.
src/c14n/ns_exclusive.rs Adds namespace visibility and binding reconciliation for exclusive canonicalization.
src/c14n/xml_base.rs Limits C14N 1.1 XML base fixup to contiguous omitted ancestors.
src/xmldsig/xpath.rs Implements bounded XPath evaluation, XMLDSig functions, namespace handling, and exact node projection.
src/xmldsig/transforms.rs Adds Base64 and XPath transform execution across binary and node-set inputs.
src/xmldsig/types.rs Adds exact axis-node membership, materialization limits, and subtree exclusion.
src/xmldsig/builder.rs Aligns template validation and transform limits with parsing and execution.
Cargo.toml Adds safe-Rust SXD dependencies to the XMLDSig feature.

Reviews (19): Last reviewed commit: "fix(xmldsig): bound xpath mirror storage" | Re-trigger Greptile

Comment thread src/c14n/serialize.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/xmldsig/types.rs`:
- Around line 252-263: Restore set.with_comments to the requested with_comments
value after insert_subtree and comment filtering in collect_document, so
materializing nodes cannot override the caller’s setting. Preserve the existing
removal of comment Tree keys when comments are disabled and ensure
entire_document_without_comments() reports with_comments() == false.

In `@tests/c14n_golden.rs`:
- Around line 288-372: Update
merlin_xpath_subset_and_signed_info_match_all_28_golden_outputs so the final
signed_info_output comparison does not assert before the accumulated failures
are reported. Add any SignedInfo mismatch to the existing failures list with
consistent diagnostic context, or otherwise defer that assertion until after the
per-reference failures check, ensuring all mismatches are surfaced together.

In `@tests/xpath_transform_integration.rs`:
- Around line 1-12: Add end-to-end signing and verification cases in the
integration tests for plain Transform::XPath and XPathFilterOperation::Union,
alongside the existing XPathFilter2 Intersect/Subtract coverage. Reuse the
established fixtures, builders, and verification flow so both missing transform
cases are exercised without changing existing coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b254107a-d800-4c2d-a4d0-e8f72b84b1da

📥 Commits

Reviewing files that changed from the base of the PR and between 93ff852 and 335a8cc.

📒 Files selected for processing (27)
  • Cargo.toml
  • README.md
  • src/c14n/mod.rs
  • src/c14n/ns_common.rs
  • src/c14n/ns_exclusive.rs
  • src/c14n/ns_inclusive.rs
  • src/c14n/serialize.rs
  • src/c14n/xml_base.rs
  • src/xmldsig/builder.rs
  • src/xmldsig/mod.rs
  • src/xmldsig/parse.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/types.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/xpath.rs
  • tests/base64_transform_integration.rs
  • tests/c14n_golden.rs
  • tests/donor_negative_vectors.rs
  • tests/fixtures/xmldsig/README.md
  • tests/fixtures/xmldsig/merlin-xpath-filter2/sign-spec-subset.xml
  • tests/fixtures/xmldsig/phaos-xmldsig-three/certs/rsa-ca-cert.der
  • tests/fixtures/xmldsig/phaos-xmldsig-three/certs/rsa-cert.der
  • tests/fixtures_smoke.rs
  • tests/signature_builder.rs
  • tests/xmlsec1_interop.rs
  • tests/xpath_donor_vectors.rs
  • tests/xpath_transform_integration.rs

Comment thread src/xmldsig/types.rs
Comment thread tests/c14n_golden.rs
Comment thread tests/xpath_transform_integration.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 335a8cc3b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/xpath.rs Outdated
Comment thread src/xmldsig/transforms.rs Outdated
Comment thread src/xmldsig/xpath.rs Outdated
Comment thread src/xmldsig/transforms.rs
Comment thread src/c14n/serialize.rs Outdated
polaz added 9 commits July 23, 2026 09:57
Prove that selected attributes and namespaces emit no bytes when their owner element is absent from the canonical subset.
- Default here() to the XMLDSig XPath parameter element
- Add explicit libxmlsec Transform-node compatibility to sign and verify
- Preserve comment exclusion metadata while materializing node sets

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1315dc17b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/c14n/serialize.rs
Comment thread src/xmldsig/builder.rs
Comment thread src/xmldsig/xpath.rs Outdated
Comment thread src/xmldsig/transforms.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/xmldsig/transforms.rs (1)

326-349: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the shared XML-base64 normalization helper.

append_normalized_base64 duplicates the same space/tab/CR/LF-only normalization policy from src/xmldsig/whitespace.rs. Extract a shared byte-oriented helper usable from transforms.rs and verify.rs, and call it from the Base64 transform path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/xmldsig/transforms.rs` around lines 326 - 349, Move the shared
space/tab/CR/LF Base64 normalization logic from append_normalized_base64 into a
reusable byte-oriented helper in xmldsig::whitespace, preserving invalid-byte
rejection and error behavior. Update the Base64 transform path and verify.rs
callers to use that helper, then remove the duplicate local implementation from
transforms.rs.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/xmldsig/transforms.rs`:
- Around line 326-349: Move the shared space/tab/CR/LF Base64 normalization
logic from append_normalized_base64 into a reusable byte-oriented helper in
xmldsig::whitespace, preserving invalid-byte rejection and error behavior.
Update the Base64 transform path and verify.rs callers to use that helper, then
remove the duplicate local implementation from transforms.rs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f6d7c4cf-ed65-46bf-a728-34b758bc8e13

📥 Commits

Reviewing files that changed from the base of the PR and between 335a8cc and b1315dc.

📒 Files selected for processing (10)
  • src/c14n/serialize.rs
  • src/xmldsig/mod.rs
  • src/xmldsig/sign.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/types.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/xpath.rs
  • tests/base64_transform_integration.rs
  • tests/c14n_golden.rs
  • tests/xpath_transform_integration.rs

polaz added 10 commits July 23, 2026 12:17
Reproduce duplicate xml:base materialization when an omitted parent separates two included elements.
Stop C14N 1.1 xml:base materialization at the nearest included ancestor while preserving it as the URI resolution seed.
Reproduce malformed XPath elements when an expression namespace binding reuses the signature prefix for another URI.
Fail template validation when an XPath binding would move prefixed XMLDSig parameter elements into another namespace.
Reproduce the compatibility normalizer collapsing XPath word operators into function-like tokens.
Exclude XPath word operators from QName-to-function-call whitespace normalization.
Reproduce unbounded transform chains through both XML parsing and the public programmatic executor.
Reject references with more than 64 transforms at both XML parsing and public executor boundaries.
Route transform and signature verification byte streams through one XML-whitespace helper while retaining caller-specific alphabet validation.
@polaz

polaz commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai Fixed in deac05f: transform and SignatureValue verification now share a byte-oriented XML base64 normalizer with caller-specific alphabet validation; existing invalid-byte offsets and error mapping are preserved, with focused unit and integration coverage.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/c14n/escape.rs`:
- Around line 8-51: Update escape_text, escape_attr, and escape_cr to accumulate
contiguous unescaped byte ranges and emit each range with a single write_all
call, flushing the range before every escaped byte and after the loop. Preserve
the existing escaping mappings and output byte-for-byte behavior while avoiding
one write_all call per input byte.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5910ff78-8053-4022-b661-c3644394c186

📥 Commits

Reviewing files that changed from the base of the PR and between dfcaf47 and 449c6d2.

📒 Files selected for processing (10)
  • src/c14n/escape.rs
  • src/c14n/mod.rs
  • src/c14n/serialize.rs
  • src/xmldsig/builder.rs
  • src/xmldsig/parse.rs
  • src/xmldsig/sign.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/xpath.rs
  • tests/signature_builder.rs
  • tests/signing_digest.rs

Comment thread src/c14n/escape.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 449c6d2ad9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/xpath.rs Outdated
polaz added 2 commits August 3, 2026 15:54
- Share one XPath parse budget across SignedInfo and Manifest references
- Skip unauthenticated Manifest parsing after SignedInfo digest failure
- Rebuild Manifest negative fixtures before computing their authenticating digest
- Meter every repeated XPath string operation and argument coercion
- Batch contiguous C14N escape runs through bounded writers
- Add deterministic work-meter and write-call regressions

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f32748a5fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/xmldsig.md Outdated
- Distinguish core signature status from Manifest reference results
- Document required inspection in the guide and public API rustdoc

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0ccd5b392

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/types.rs
Comment thread src/xmldsig/verify.rs Outdated
Comment thread src/xmldsig/xpath.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/xmldsig/verify.rs (1)

1093-1096: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Terminal C14N/base64 check matches the current Transform variants.
The explicit allowlist coverage for no-transforms and a non-terminal binary transform before a final C14N/base64 can be added.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/xmldsig/verify.rs` around lines 1093 - 1096, Add explicit coverage around
the terminal `produces_binary` check for references with no transforms and for a
non-terminal binary transform followed by final C14N or Base64Decode. Verify
both cases respect `allowed.contains(DEFAULT_IMPLICIT_C14N_URI)` while
preserving the existing transform matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/xmldsig/xpath.rs`:
- Around line 221-289: Update xpath_string_scan_count to increment its scan
count for each =, <, and > encountered outside quoted literals, using the same
saturating behavior as comma counting; leave quoted operators ignored. Add a
regression test alongside xpath_filter_charges_each_repeated_string_scan
covering repeated comparisons such as /root/blob = 'missing' or /root/blob =
'absent' and verify each comparison contributes a string scan.

---

Outside diff comments:
In `@src/xmldsig/verify.rs`:
- Around line 1093-1096: Add explicit coverage around the terminal
`produces_binary` check for references with no transforms and for a non-terminal
binary transform followed by final C14N or Base64Decode. Verify both cases
respect `allowed.contains(DEFAULT_IMPLICIT_C14N_URI)` while preserving the
existing transform matching.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 76be4096-2b54-4770-aacc-de4cb94964f1

📥 Commits

Reviewing files that changed from the base of the PR and between 449c6d2 and a0ccd5b.

📒 Files selected for processing (6)
  • docs/xmldsig.md
  • src/c14n/escape.rs
  • src/xmldsig/parse.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/xpath.rs

Comment thread src/xmldsig/xpath.rs
- Defer Manifest processing until core signature validation succeeds
- Meter node-set exclusions, XPath parent axes, and comparison string scans
- Preserve Merlin interoperability and cover terminal transform allowlists

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b55e415d7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/verify.rs Outdated
- Recognize enveloped-signature as structure-preserving for ID-rooted Manifest and Object references
- Cover both authenticated target forms through the complete verification pipeline
@polaz

polaz commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai Re: terminal C14N/base64 allowlist coverage - this finding is outdated. enforce_reference_policies_checks_only_terminal_binary_output now covers references with no transforms and non-terminal Base64 followed by terminal C14N or Base64. It verifies that only node-set terminal output requires DEFAULT_IMPLICIT_C14N_URI. The current all-feature suite passes 775/775 tests.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '=== Candidate files ==='
fd -t f -e rs . src tests | sort | rg '/(verify|transforms|sign|xpath|.*integration)\.rs$' || true

printf '%s\n' '=== Policy implementation and named regression ==='
rg -n -C 14 --type rust \
  'enforce_reference_policies_checks_only_terminal_binary_output|DEFAULT_IMPLICIT_C14N_URI|enforce_reference_policies|implicit.*C14N|terminal.*binary|terminal.*output|allowed_transforms' \
  src tests || true

printf '%s\n' '=== Verify module outline ==='
ast-grep outline src/xmldsig/verify.rs --items all --type function,impl,enum,struct 2>/dev/null || true

Length of output: 50759


@polaz The policy implementation has the correct terminal-output behavior.

enforce_reference_policies checks only the final transform. It requires DEFAULT_IMPLICIT_C14N_URI only when the final output is a node set. A terminal Transform::C14n(_) or Transform::Base64Decode is binary.

The regression does verify that a no-transform reference requires implicit C14N. However, both terminal-binary cases use an allowlist that already contains DEFAULT_IMPLICIT_C14N_URI. The test therefore does not prove that terminal Base64Decode succeeds when implicit C14N is absent.

Please add a successful case for:

vec![Transform::Base64Decode, Transform::Base64Decode]

with without_implicit_c14n. This directly verifies the stated Base64 policy boundary. I did not run the test suite in this environment.

You are interacting with an AI system.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/xmldsig.md`:
- Around line 33-39: Update the Manifest-processing documentation around
VerifyContext::process_manifests and VerifyResult::manifest_references to state
that disabling process_manifests(false) also leaves manifest_references empty.
Clarify that callers must distinguish this “not processed” state from an enabled
processing pass that produced no authenticated Manifest references.

In `@src/xmldsig/verify.rs`:
- Around line 1846-1884: The test
verify_context_processes_manifest_after_noop_enveloped_transform currently
checks only status and manifest reporting, not the transformed bytes. Enable
store_pre_digest(true) on VerifyContext and assert that
signed_info_references[0].pre_digest_data contains the ds:Manifest element and
its child ds:Reference, preserving coverage of the structural behavior described
by transform_preserves_manifest_structure.
- Around line 1037-1050: Update src/xmldsig/verify.rs:1037-1050 in
transform_preserves_manifest_structure to return false for Transform::Enveloped
and revise its comment to remove the incorrect no-op explanation. In
src/xmldsig/verify.rs:1846-1884, update
verify_context_processes_manifest_after_noop_enveloped_transform to enable
store_pre_digest(true) and assert that signed_info_references[0].pre_digest_data
contains the ds:Manifest element and its child ds:Reference.
- Around line 2365-2399: Extend
enforce_reference_policies_checks_only_terminal_binary_output to run the
Base64Decode-only chain with without_implicit_c14n, while retaining the existing
allowlist cases and assertions. Verify that the terminal binary output succeeds
without DEFAULT_IMPLICIT_C14N_URI being allowlisted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 01f5a954-f524-4402-81fc-0530dfdd25a1

📥 Commits

Reviewing files that changed from the base of the PR and between a0ccd5b and cb889f3.

📒 Files selected for processing (5)
  • docs/xmldsig.md
  • src/xmldsig/transforms.rs
  • src/xmldsig/types.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/xpath.rs

Comment thread docs/xmldsig.md Outdated
Comment thread src/xmldsig/verify.rs
Comment thread src/xmldsig/verify.rs
Comment thread src/xmldsig/verify.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb889f31ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/c14n/xml_base.rs Outdated
polaz added 2 commits August 3, 2026 19:39
- Treat enveloped ID-rooted Manifest and Object references as structure-removing transforms
- Assert the empty pre-digest contract for both target forms
- Clarify disabled Manifest processing and isolate terminal Base64 allowlist coverage
- continue xml:base fixup past selected elements that do not emit a base
- cover omitted descendants beneath a selected base-less ancestor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31f41c2d33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/xpath.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/xmldsig/verify.rs`:
- Around line 1736-1764: Update
verify_context_skips_manifest_work_when_signature_value_is_invalid so its XML
mutation targets the Manifest DigestValue within ds:Object, matching the
positional approach used by
verify_context_reports_manifest_reference_parse_errors_explicitly, rather than
replacing SignatureValue text. Ensure the mutation actually produces malformed
nested Manifest content while preserving the invalid SignatureValue and the
test’s existing assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bc922ded-b9d4-480f-829a-c18a56bfe7e9

📥 Commits

Reviewing files that changed from the base of the PR and between a0ccd5b and 31f41c2.

📒 Files selected for processing (7)
  • docs/xmldsig.md
  • src/c14n/serialize.rs
  • src/c14n/xml_base.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/types.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/xpath.rs

Comment thread src/xmldsig/verify.rs
- charge numeric built-ins and arithmetic without misclassifying wildcard axes
- make malformed Manifest fixtures structurally target nested digest values

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 932ec789b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/xpath.rs
Comment thread src/xmldsig/xpath.rs
Comment thread src/xmldsig/types.rs
- Meter custom XPath string coercions and document comparison behavior
- Share owned node-set materialization limits across signature processing
- Cover resolver, projection, and binary adapter allocation paths
@polaz

polaz commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46a0ee4ce3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/transforms.rs Outdated
- Name specification and xmlsec legacy context nodes explicitly
- Document the XMLDSig parent-element contract at parse time
- Assert that specification here() is an element, not a text node

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 884b140b2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/xpath.rs Outdated
- Charge each independent XPath path branch before SXD evaluation
- Keep child, descendant, and parent-axis cost models distinct
- Reject repeated child-axis unions through the shared work budget
@polaz

polaz commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 94446ab64e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(xmldsig): support XPath transforms feat(xmldsig): support Base64 reference transforms test(xmldsig): classify Phaos negative vectors

1 participant