feat(pal/std): enforce session-scoped key isolation at vault access#591
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens session-scoped key isolation in the std PAL by enforcing session bindings at the vault access chokepoint, making the emulator/std PAL behavior match the reference firmware and the mock backend for session-availability keys.
Changes:
- Added session-binding enforcement in
StdHsmPalvault lookups soSession-availability keys are only visible within their creating session. - Exposed the stored per-key session binding from the std PAL
KeyVaultdriver to support the new enforcement check. - Added a new cross-session smoke test suite covering use-by-id, unmask/re-import, and delete semantics for App vs Session keys.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| fw/plat/std/pal/src/vault.rs | Adds assert_key_session_access and gates vault read/metadata access based on SQE session → physical session key mapping. |
| fw/plat/std/pal/src/drivers/vault.rs | Adds key_session_binding accessor to expose per-key session binding (session_key_id). |
| fw/plat/std/pal/Cargo.toml | Adds azihsm_fw_hsm_io dependency to interpret SQE session flags/IDs (Sqe). |
| ddi/mbor/types/tests/integration/cross_session_key_access_smoke.rs | Introduces new integration smoke tests validating App vs Session access across sessions for AES/ECC/RSA-unwrapped keys. |
| ddi/mbor/types/tests/azihsm_ddi_tests.rs | Registers the new cross-session smoke test module. |
jaygmsft
force-pushed
the
user/jayg/session-key-isolation
branch
from
July 20, 2026 21:38
eec13d2 to
1698dc8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
ddi/mbor/types/tests/integration/cross_session_key_access_smoke.rs:372
ecc_sign_withbuilds a 20-byte digest but passesDdiHashAlgorithm::Sha256. The EccSign handler requires at least the hash algorithm’s native digest length (32 bytes for SHA-256), so this will be rejected withInvalidArg(or could start failing if encoding changes). Use a 32-byte digest (matching other ECC sign tests) to ensure the test is validating session isolation rather than digest-length validation.
MborByteArray::new([1u8; 96], 20).expect("digest byte array"),
A key created with `Session` availability was resolvable — and thus usable and deletable — from any other session on the same partition, because the std PAL vault resolved key ids without checking the session binding. Only the mock enforced this. This closes that gap so the std PAL / emulator matches the reference firmware behaviour. Enforcement is added at the vault access chokepoint: a new `assert_key_session_access` gates `vault_key`, `vault_key_kind`, and `vault_key_attrs`. Session-bound keys are only visible from the session that created them (mapped via the SQE session id → physical session id); from any other session they report `KeyNotFound`. Partition-scoped `App`/persistent keys carry no binding and stay accessible everywhere, including internal firmware IOs whose SQE has no session. Because DeleteKey resolves attrs through the guarded path, delete inherits the same isolation. Adds a `cross_session_key_access_smoke` suite (9 smoke tests) covering the App-vs-Session semantics across three handler paths — use (`vault_key`), masked-blob re-import (`UnmaskKey`), and delete — over AES and ECC keys, plus RSA-unwrapped keys: - App key usable / unmaskable / deletable from another session - Session key not usable / not unmaskable / not deletable elsewhere - ECC App key signable cross-session; Session key only in its session - Session-key blob never re-importable (MK_SESSION is fresh-random per session, not seed-derived), same or different session seed The uno PAL vault is a separate crate and does not yet enforce this; tracked as a follow-up for the hardware bring-up. Test: emu azihsm_ddi_mbor_types full 597/597 passed; emu smoke gate 94/94 passed; mock cross-session suite 9/9 passed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 82c8bd53-6639-46fc-8a79-a7539921e4c1
jaygmsft
force-pushed
the
user/jayg/session-key-isolation
branch
from
July 20, 2026 22:14
1698dc8 to
884c0f3
Compare
jaygmsft
enabled auto-merge
July 20, 2026 22:19
vsonims
approved these changes
Jul 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A key created with
Sessionavailability was resolvable — and thus usable and deletable — from any other session on the same partition, because the std PAL vault resolved key ids without checking the session binding. Only the mock enforced this. This closes that gap so the std PAL / emulator matches the reference firmware behaviour.Enforcement is added at the vault access chokepoint: a new
assert_key_session_accessgatesvault_key,vault_key_kind, andvault_key_attrs. Session-bound keys are only visible from the session that created them (mapped via the SQE session id → physical session id); from any other session they reportKeyNotFound. Partition-scopedApp/persistent keys carry no binding and stay accessible everywhere, including internal firmware IOs whose SQE has no session. Because DeleteKey resolves attrs through the guarded path, delete inherits the same isolation.Adds a
cross_session_key_access_smokesuite (9 smoke tests) covering the App-vs-Session semantics across three handler paths — use (vault_key), masked-blob re-import (UnmaskKey), and delete — over AES and ECC keys, plus RSA-unwrapped keys:The uno PAL vault is a separate crate and does not yet enforce this; tracked as a follow-up for the hardware bring-up.
Test: emu azihsm_ddi_mbor_types full 597/597 passed; emu smoke gate 94/94 passed; mock cross-session suite 9/9 passed.
Copilot-Session: 82c8bd53-6639-46fc-8a79-a7539921e4c1