Skip to content

Fix C-WCOW dm-verity hash mismatch vs cplat runtime - #36

Closed
EmanuelOprea wants to merge 1 commit into
microsoft:mainfrom
EmanuelOprea:cwcow-confcom-fix
Closed

Fix C-WCOW dm-verity hash mismatch vs cplat runtime#36
EmanuelOprea wants to merge 1 commit into
microsoft:mainfrom
EmanuelOprea:cwcow-confcom-fix

Conversation

@EmanuelOprea

Copy link
Copy Markdown
Collaborator

Problem

dmverity-vhd produced per-layer and merged block-CIM dm-verity hashes that did not match the values the cplat runtime (containerd blockcim snapshotter) computes at pull time, which blocks hash-locked confidential Windows (C-WCOW) containers.

Two inputs to the dm-verity hash differed between confcom and the runtime:

  1. CIM name — the CIM name is part of the dm-verity-hashed content. confcom named each layer CIM <layerDigest>.cim while the runtime names every layer CIM layer.cim. Fixed by using the constant layer.cim.

  2. Parent-layer order — hcsshim's processNonBaseLayer merges each layer's registry delta against parentLayerPaths[0], and MergeBlockCIMLayersWithOpts expects source CIMs topmost-first (base last). The runtime supplies parents immediate-parent-first (containerd parent-chain order), producing a cumulative/chained registry merge; confcom accumulated them base-first (a flat merge against the original base), diverging from the 3rd layer onward. Fixed by adding orderedParentsForMerge() and applying it in tarToCim and generateMergedCim.

Change

Single file: cmd/dmverity-vhd/cim.go (+31/-3). No behavioral change beyond aligning the two hash inputs with the runtime.

dmverity-vhd produced per-layer and merged block-CIM dm-verity hashes that
did not match the values the cplat runtime (containerd blockcim snapshotter)
computes at pull time, which blocks hash-locked confidential Windows
containers. Two inputs to the hash differed:

1. CIM name: the CIM name is part of the dm-verity-hashed content. confcom
   named each layer CIM "<layerDigest>.cim" while the runtime names every
   layer CIM "layer.cim". Use the constant "layer.cim" to match.

2. Parent-layer order: hcsshim's processNonBaseLayer merges each layer's
   registry delta against parentLayerPaths[0], and MergeBlockCIMLayersWithOpts
   expects source CIMs topmost-first (base last). The runtime supplies parents
   immediate-parent-first (containerd parent-chain order), producing a
   cumulative/chained registry merge; confcom accumulated them base-first
   (a flat merge against the original base), diverging from the 3rd layer on.
   Add orderedParentsForMerge() and apply it in tarToCim and generateMergedCim.
@EmanuelOprea

Copy link
Copy Markdown
Collaborator Author

Superseded by #37, which is the same fix opened as a proper branch-based PR directly on microsoft/integrity-vhd (no fork). Please review #37 instead.

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.

1 participant