Skip to content

fix(vdr): reject VDR operations containing unknown protobuf fields - #237

Draft
yshyn-iohk wants to merge 1 commit into
mainfrom
fix/vdr-unknown-fields-60
Draft

fix(vdr): reject VDR operations containing unknown protobuf fields#237
yshyn-iohk wants to merge 1 commit into
mainfrom
fix/vdr-unknown-fields-60

Conversation

@yshyn-iohk

Copy link
Copy Markdown
Contributor

Summary

Fixes #60

VDR (storage) operations that carry unknown protobuf fields are now considered invalid and silently skipped during DID resolution. PRISM (SSI) operations are intentionally left lenient to preserve forward-compatibility with future protocol extensions.

The check covers both the outer PrismOperation wrapper and the inner storage-entry message (ProtoCreateStorageEntry / ProtoUpdateStorageEntry / ProtoDeactivateStorageEntry).

Changes

  • lib/did-prism/src/protocol/error.rs — new ProcessError::VdrOperationContainsUnknownFields variant
  • lib/did-prism/src/protocol/v1.rshas_unknown_fields() helper + guard at the top of create_storage, update_storage, and deactivate_storage
  • lib/did-prism/tests/storage_operation.rs — 5 new tests

Test plan

  • create_storage_with_unknown_fields_is_invalid — inner message unknown fields, entry is not recorded
  • update_storage_with_unknown_fields_is_invalid — inner message unknown fields, original entry unchanged
  • deactivate_storage_with_unknown_fields_is_invalid — inner message unknown fields, entry remains active
  • create_storage_with_unknown_fields_in_prism_operation_wrapper_is_invalid — outer wrapper unknown fields, entry is not recorded
  • create_did_with_unknown_fields_in_prism_operation_wrapper_is_still_valid — SSI operations tolerate unknown fields (forward-compat)
  • cargo fmt — clean
  • cargo clippy --all-features -- -D warnings — clean
  • cargo test --all-features — all tests pass (storage_operation suite: 25 → 30)

@yshyn-iohk
yshyn-iohk requested a review from a team as a code owner March 10, 2026 12:47
@yshyn-iohk yshyn-iohk self-assigned this Mar 10, 2026
…lds (#60)

VDR (storage) operations that carry unknown protobuf fields are now
considered invalid and silently skipped during DID resolution.  PRISM
(SSI) operations are intentionally left lenient to preserve
forward-compatibility with future protocol extensions.

Implementation:
- Add ProcessError::VdrOperationContainsUnknownFields error variant
- Add has_unknown_fields() helper that checks SpecialFields via
  UnknownFields::iter()
- Guard create_storage / update_storage / deactivate_storage in V1Processor
  against unknown fields on both the outer PrismOperation wrapper and the
  inner storage-entry message

Tests:
- create/update/deactivate storage with unknown fields in inner message
  are all rejected (storage entry absent / unchanged / still active)
- create storage with unknown fields on the outer PrismOperation wrapper
  is also rejected
- create_did with unknown fields on the outer PrismOperation wrapper is
  still valid (SSI tolerance confirmed)

Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
@yshyn-iohk
yshyn-iohk force-pushed the fix/vdr-unknown-fields-60 branch from 993cf47 to 399e406 Compare March 10, 2026 12:55
@sonarqubecloud

Copy link
Copy Markdown

@yshyn-iohk yshyn-iohk changed the title fix(did-prism): reject VDR operations containing unknown protobuf fields fix(vdr): reject VDR operations containing unknown protobuf fields Mar 10, 2026
@yshyn-iohk
yshyn-iohk enabled auto-merge (squash) March 10, 2026 13:54
operation: ProtoCreateStorageEntry,
prism_operation_special_fields: SpecialFields,
) -> Result<DidStateRc, ProcessError> {
ensure_no_vdr_unknown_fields(&prism_operation_special_fields, &operation.special_fields)?;

@patextreme patextreme Mar 10, 2026

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.

I think the desired behavior is slightly different. In the code, it will reject the operation and not update the storage state. What we want is for it to update the storage, but have a flag to mark it as invalid. Once the storage entry sees an operation with unknown fields, it becomes invalid and cannot be queried, which is not the case here.

I need to recheck the wording in the spec again, but you can already use this input to steer your agent.

@FabioPinheiro

Copy link
Copy Markdown
Contributor

@yshyn-iohk @patextreme Should we just close de PR and is that anything to fix here?

@patextreme

Copy link
Copy Markdown
Contributor

The storage state needs some work before merging. Let's keep this PR open and revisit when we have bandwidth to sort it out.

@yshyn-iohk
yshyn-iohk marked this pull request as draft April 8, 2026 06:46
auto-merge was automatically disabled April 8, 2026 06:46

Pull request was converted to draft

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Make VDR entry invalid when unknown fields exist

3 participants