Skip to content

Robust SED target-drive selection — don't just pick the first locked Opal drive #81

Open

Description

@walterchris

Context

During #79 hardware bring-up we discovered the PBA was unlocking the wrong drive.
selectSED chose the first NVMe controller that answered Level-0 Discovery as Opal.
The lab board exposes 4 NVMe drives, several Opal-capable; a blank Samsung 980 PRO
enumerated before the provisioned Swissbit SED, so the PBA queried the blank drive
→ StartSession returned 0x0c (its LockingSP is Manufactured-Inactive) and we spent
days misdiagnosing it as ComID contention / a firmware TCG wall. It was none of that —
just the wrong drive. On the correct (Swissbit) drive, unlock works (sed unlock ok).

The immediate fix narrowed selection to "the locked Opal drive with an active shadow
MBR" (d.Locked && d.MBREnabled) in selectSED (cmd/pba/sedunlock.go). That works on
the current single-locked-SED rig, but it is a heuristic, not a robust concept.

Problem

selectSED picks the first transport whose Discovery reports
OpalSSC && LockingSupported && Locked && MBREnabled. This is insufficient:

  • Multiple locked SEDs can be present → ambiguous which to unlock.
  • A target already unlocked earlier in boot (or with MBRDone set) won't match
    Locked && MBREnabled → "no SED found", false negative.
  • It does not tie unlock to the drive the PBA was actually booted from — the only
    drive we have a credential/policy for. Unlocking an arbitrary locked SED is wrong and
    a potential security concern (unlocking a drive that isn't the intended target).
  • The shadow-MBR PBA model implies a 1:1 relationship between the booted PBA image and
    its SED; selection should reflect that, deterministically.

What we need: a concept (ADR) for target-drive identification

Evaluate and pick one, ideally a prioritized chain with fail-closed fallback:

  1. Boot-device match (preferred). Identify the NVMe controller/namespace the PBA was
    loaded from by matching EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle (its device path) to
    the carrier handle's device path. Ties unlock to "the drive we booted from" —
    unambiguous and correct for the shadow-MBR model. Needs go-boot support to read the
    loaded-image device path and compare device paths.
  2. Policy-specified identity. The boot policy names the target SED by a stable
    identity (NVMe serial / model / EUI64 / WWN), read via NVMe Identify Controller.
    Robust across enumeration order; requires provisioning the identity into the policy.
  3. Credential-verified (last resort). Among locked SEDs, the target is the one our
    credential authenticates — but this attempts auth on each, consuming PIN-retry budget
    and risking lockout. Not preferred.

Security requirements (threat model + ADR)

  • Unlock only the intended drive; never an unintended SED.
  • Fail closed if the target cannot be identified unambiguously (0 matches, or >1
    ambiguous matches) — do not "pick one".
  • Decision belongs in the threat model and a dedicated ADR (security-critical behavior).

Acceptance criteria

  • ADR documenting the chosen target-drive identification concept + fail-closed rules.
  • selectSED implements it; the interim Locked && MBREnabled heuristic is replaced or
    explicitly backed by it.
  • Tests (extending cmd/pba/sedunlock_test.go):
    • decoy non-target Opal drive is skipped (already added: TestUnlockSEDSkipsNonTargetOpalDrive),
    • multiple locked SEDs → correct selection or fail-closed-on-ambiguity,
    • already-unlocked target handled,
    • boot-device match (if approach Enable branch protection on main #1).
  • go-boot support for the chosen identity source (loaded-image device-path match, or
    NVMe Identify Controller serial), with host stubs for testability.

References

Activity

  1. walterchris commented on Jul 4, 2026

    @walterchris
    OwnerAuthor

    Interim heuristic now merged (#86): selectSED selects the locked Opal SED with an active Shadow MBR (OpalSSC && LockingSupported && Locked && MBREnabled), fixing the #79 wrong-drive bug. This is a stopgap and the rework this issue tracks is still needed:

    • Config-file drive targeting (requested): allow a policy/config file to name the exact target SED by a stable identity — NVMe serial / model / EUI64 / WWN (read via NVMe Identify Controller) — overriding the heuristic. This is option (2) "policy-specified identity" in the issue body.
    • Known gap in the interim heuristic: it skips an already-unlocked target (Locked==false, e.g. warm reboot / retry), failing closed with "no locked Opal SED".
    • Fail-closed on ambiguity (0 or >1 matches) still required.

    A code comment at selectSED (cmd/pba/sedunlock.go) points here. The chosen mechanism should be recorded in an ADR when built.

  2. walterchris commented on Jul 5, 2026

    @walterchris
    OwnerAuthor

    Security review (2026-07-05) reinforces this — becomes MEDIUM once a real PIN prompt ships

    The SED/Opal-angle security review flagged this exact gap as finding F1, and raised its severity ceiling:

    selectSED (cmd/pba/sedunlock.go:76-97) picks the target purely by self-asserted Level-0 Discovery flags (OpalSSC && LockingSupported && Locked && MBREnabled) and takes the first enumeration match — nothing binds selection to the boot device or a verified drive identity.

    Attack (evil-maid): attach/reflash a rogue drive that answers Discovery with those flags and enumerates before the genuine SED. selectSED returns the rogue client and Client.Unlock transmits the StartSession HostChallenge — the PIN — to the attacker's drive (internal/opal/method.go:58-72, internal/opal/client.go:90), harvesting it.

    Severity: LOW today (the MVP PIN is compiled into the image and already extractable — R-003), but MEDIUM once ADR-0009's user-entered PIN replaces it. The review's explicit recommendation: bind selection to a verified drive identity — policy-pinned NVMe serial/WWN, or the firmware boot-device handle — before any real PIN source lands, and gate that change on the same human/ADR review as the PIN-prompt change.

    This is exactly the config-file drive-targeting rework already scoped here. Touches R-002 (accepted residual), threat-model A1/A7/§6.2. Please treat the drive-identity binding as a hard prerequisite for the production PIN work, not just a robustness improvement.

  3. walterchris commented on Aug 16, 2026

    @walterchris
    OwnerAuthor

    Status note (2026-08-16): building blocks for the robust-selection rework have landed since this was filed — go-boot v1.6.2-tpba.6 (merged, #108) added NVMe Identify-Controller serial read and ConnectController explicitly for serial-based drive targeting, and the NVMe-passthru carrier (#111) exposes Serial() per drive. The policy schema could now carry a target serial/WWN and selectSED could match it instead of the locked+MBREnabled heuristic. Still open; unchanged in priority (the heuristic works on the current single-locked-SED rig).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions