Skip to content

hash-signature (2): v1.3 spec with optional verity signature partition - #835

Draft
bfjelds (bfjelds) wants to merge 6 commits into
user/bfjelds/verity-roothash-sig-1-apifrom
user/bfjelds/verity-roothash-sig-2-cosi
Draft

bfjelds (bfjelds) wants to merge 6 commits into
user/bfjelds/verity-roothash-sig-1-apifrom
user/bfjelds/verity-roothash-sig-2-cosi

Conversation

@bfjelds

@bfjelds bfjelds (bfjelds) commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Second PR in a 3-part stack implementing an optional dm-verity root hash signature partition. Builds on #834.

This PR introduces COSI metadata specification version 1.3, carrying the same data/signature linkage as the HostConfiguration API addition in #834, and wires derivation of the new field when building a Host Configuration from a COSI image.

Changes

  • KnownMetadataVersion::V1_3 — documents the new spec version.
  • VerityMetadata.signature: Option<ImageFile> — optional detached PKCS#7/DER signature of the root hash, stored in its own partition.
  • filesystem_image_files() includes the signature file, so existing v1.2 partition-matching/size/hash validation automatically covers it (no new error variants needed).
  • derive_host_configuration_inner derives VerityDevice.signature_device_id by resolving the signature image's partition, mirroring the existing hash-partition derivation.
  • OsImageVerityHash.signature_image_file carries the mapped file through to the engine layer (consumed in PR3).

Stack

  1. hash-signature (1): add optional verity root hash signature #834
  2. (this pr) hash-signature (2): v1.3 spec with optional verity signature partition #835
  3. hash-signature (3): deploy and open verity root hash signature partitions #836

Testing

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@bfjelds bfjelds (bfjelds) changed the title cosi: add v1.3 spec with optional verity signature partition hash-signature (2): v1.3 spec with optional verity signature partition Oct 8, 2026
@bfjelds
bfjelds (bfjelds) force-pushed the user/bfjelds/verity-roothash-sig-2-cosi branch 3 times, most recently from 1021d24 to 9ca9233 Compare October 8, 2026 17:08
Introduces COSI metadata specification version 1.3, adding an
optional `signature` field to `VerityMetadata` that points at an
ImageFile holding a detached PKCS#7/DER signature of the verity root
hash.

- `KnownMetadataVersion::V1_3` documents the new version.
- `filesystem_image_files()` includes the signature file so existing
  V1_2 partition-matching/size/hash validation covers it automatically.
- `derive_host_configuration_inner` derives
  `VerityDevice.signature_device_id` by resolving the signature
  image's partition, linking the COSI image to the new HostConfig
  API field from the previous PR in this stack.
- `OsImageVerityHash.signature_image_file` carries the mapped file
  through to the engine layer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The public v1.3 specification/schema is missing, and the new signature path lacks positive test coverage.

2 open findings
What changed in this PR

Adds COSI v1.3 support for optional dm-verity root-hash signature partitions and propagates signature metadata toward the engine layer.

Changes:

  • Adds v1.3 metadata and optional signature image parsing.
  • Derives signature partition IDs in generated host configurations.
  • Carries signature image metadata through OS-image structures.
File Description
crates/​trident/​src/​osimage/​mod.rs Adds signature image metadata.
crates/​trident/​src/​osimage/​mock.rs Updates mock verity construction.
crates/​trident/​src/​osimage/​cosi/​mod.rs Converts COSI signature metadata.
crates/​trident/​src/​osimage/​cosi/​metadata.rs Adds v1.3 and signature schema types.
crates/​trident/​src/​osimage/​cosi/​derived_hc.rs Derives signature partition references.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/trident/src/osimage/cosi/mod.rs
Comment thread crates/trident/src/osimage/cosi/metadata.rs
Addresses review feedback on PR #835:
- Document the COSI 1.3 revision (signature field on VerityConfig) in
  Composable-OS-Image.md, with a changelog entry and revision summary row.
- Publish cosi-metadata-v1.3.schema.json alongside matching valid/invalid
  samples validated by the existing schema-validation workflow.
- Add a derive_host_configuration_inner test exercising a non-None
  VerityMetadata.signature, asserting the derived hash_signature_device_id
  resolves to the correct partition.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Version gating, storage-graph validation, and the signed-verity sample need correction.

3 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment thread crates/trident/src/osimage/cosi/derived_hc.rs
Comment thread crates/trident/src/osimage/cosi/metadata.rs
Comment thread tests/cosi/metadata_samples/v1.3/valid/verity-uki-systemd-boot.json
Addresses review feedback on PR #835:

The v1.3 verity-uki-systemd-boot.json sample declared a signature
stored in a dedicated partition, but disk.gptRegions only listed the
ESP and root partitions - no matching region for the root-verity hash
or root-verity-sig partitions the verity block itself references.
This made the sample schema-valid but not something Trident's own
partition-consistency checks could ever accept as a real COSI file.

Added matching gptRegions entries (partition numbers 3 and 4) for the
hash and signature images, reusing their existing ImageFile metadata
from the verity block so they stay byte-for-byte consistent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The signed-verity “valid” fixture declares partition images larger than its disk.

1 open finding
3 resolved since last review

🧠 Review effort: Balanced

Comment thread tests/cosi/metadata_samples/v1.3/valid/verity-uki-systemd-boot.json Outdated
…ions

Addresses follow-up review feedback on PR #835:

Adding GPT regions for the hash and signature partitions (previous
commit) made the sample internally consistent for partition
references, but the disk's declared size (1 GiB) was never big enough
to hold all four partition images (esp + root + root-verity hash +
root-verity-sig), which together need at least ~1.43 GiB uncompressed.

Enlarged disk.size to 2 GiB, comfortably above that total.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Signature path aliasing can bypass validation, and the public contract does not mandate the DER encoding required by its consumer.

0 open findings

1 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Reject signature paths aliased to image paths

crates/​trident/​src/​osimage/​cosi/​metadata.rs:180

Issue: A signature can alias the data or hash image path even though it must occupy its own dedicated partition. Evidence: this iterator is collected into a HashMap keyed by path in validation.rs:150-153; adding signature here means a duplicate path silently overwrites the earlier image, so validation may ignore one image's metadata and derivation can assign the same partition ID to both hash and signature devices. Suggestion: reject duplicate paths among filesystem, verity-hash, and signature image references before building the path map, and add a regression test for an aliased signature path.

Low severity Require DER-encoded detached PKCS#7 signatures

docs/​Reference/​Composable-OS-Image.md:295

Issue: The v1.3 contract does not require the signature to use DER encoding. Evidence: this field permits an unspecified PKCS#7 representation, while the stacked consumer in #836 passes the raw partition directly to veritysetup and explicitly relies on PKCS#7/DER being self-delimiting so partition padding is safe. A producer following this text could emit PEM or another encoding that is not compatible with that consumption model. Suggestion: specify that this MUST be a DER-encoded detached PKCS#7 signature here and in the v1.3 schema description.

🧠 Review effort: Balanced

bfjelds (bfjelds) and others added 2 commits October 10, 2026 16:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d61c42e7-3c43-4fe5-8c89-89d38ff9528b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d61c42e7-3c43-4fe5-8c89-89d38ff9528b
@bfjelds

Copy link
Copy Markdown
Member Author

Great comments. Addressed both previously missed findings from review 5479586725 in fbee98e: duplicate filesystem/hash/signature role paths are rejected before map construction, and the specification/schema explicitly require DER-encoded detached PKCS#7 signatures. Added aliasing regression coverage while retaining valid disk-region references.

This branch has not been deployed

No deployments
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.

2 participants