diff --git a/dag/gunbc/auth/privileged_effect_census.dag b/dag/gunbc/auth/privileged_effect_census.dag index f408c87efb6..b5b6426d567 100644 --- a/dag/gunbc/auth/privileged_effect_census.dag +++ b/dag/gunbc/auth/privileged_effect_census.dag @@ -310,6 +310,26 @@ fn route_qualification_effect() -> PrivilegedEffect { } } +// ROTATION ROUTE QUALIFICATION, CHANNEL-ACCESS SHAPE (cut O1a-2). The same qualification effect +// executed for an IPMI Set User Access request: one per controller and build. Its characteristics +// are stated as they are rather than copied from the password row. IRREVERSIBLE, AND SAID SO: a +// privilege write to the wrong user or channel can remove the last administrator's access over the +// LAN, and getting it back needs hands on the unit (a host-side interface or a reflash), which no +// reapply over the network can do. It applies NO credential: it changes a privilege limit, not a +// password. No dispatched run carries it; in this cut it is modeled with a dry realization only. +fn route_qualification_channel_access_effect() -> PrivilegedEffect { + PrivilegedEffect { + subject: "qualify a BMC channel-access route: execute one IPMI Set User Access request in its privilege-limit-only form on one controller at one firmware build and read it back with Get User Access" as NonEmptyStr, + frequency: DeviceOnce, + reversibility: IrreversibleEffect { what_is_lost: "a privilege write to the wrong user or channel can remove the last administrator's LAN access; recovering it needs hands on the unit, not a reapply" as NonEmptyStr }, + surface: ApiSurface, + workload_identity: WorkloadIdentityUnbindable { cause: "no dispatched run carries route qualification; in cut O1a-2 it is modeled with a dry realization only" as NonEmptyStr }, + minted_reach: MintsNoCredential, + billing: NoBillingConsequence, + witness_discharge: NoWitnessDischarge, + } +} + // BMCSECURE ACCOUNT ROTATION (cut O1b). The Apply arm of the state-shaped BmcSecure: set the managed // account to a stored and exact-fetched generation and retire the published account to a break-glass // generation, each write over a route admitted by admit_rotation_apply. IRREVERSIBLE, AND SAID SO: the @@ -642,11 +662,17 @@ data privileged_effect_census: List = [ divergence_reason: none, }, PrivilegedEffectSite { - site: site(module_path: "gunbc.machine_intake_bmc_rotation_route", decl_name: "qualify_rotation_route"), + site: site(module_path: "gunbc.machine_intake_bmc_rotation_route", decl_name: "admit_password_route_qualification"), effect: route_qualification_effect(), realized: RealizedApprovalCapability, divergence_reason: none, }, + PrivilegedEffectSite { + site: site(module_path: "gunbc.machine_intake_bmc_rotation_route", decl_name: "admit_privilege_limit_route_qualification"), + effect: route_qualification_channel_access_effect(), + realized: RealizedApprovalCapability, + divergence_reason: none, + }, PrivilegedEffectSite { site: site(module_path: "gunbc.machine_intake_bmc_secure", decl_name: "plan_bmc_account_action"), effect: bmc_secure_account_rotation_effect(), diff --git a/dag/gunbc/bmc_model.dag b/dag/gunbc/bmc_model.dag index 2bbb9af7cea..0c46980e40b 100644 --- a/dag/gunbc/bmc_model.dag +++ b/dag/gunbc/bmc_model.dag @@ -4,7 +4,7 @@ import std.types { Bool, Int, List } import std.measure { Second, second, second_count } import v2.std.optional { Present, Absent } import v2.std.algebra { any, filter } -import extdeps.bmc.ipmi_channel { IpmiUserId } +import extdeps.bmc.ipmi_channel { IpmiChannelNumber, IpmiUserId, IpmiUserChannelAccess, IpmiChannelPrivilegeLimit } import extdeps.bmc.ipmi_chassis_control { IpmiChassisControlAction, IpmiChassisPowerDown, IpmiChassisPowerUp, IpmiChassisPowerCycle, IpmiChassisHardReset, } @@ -74,13 +74,14 @@ type BmcWorld { sol_drop_after_boot: Second? web: BmcWebWorld ipmi_users: List + ipmi_user_access: List } fn bmc_world(power: BmcPower) -> BmcWorld { BmcWorld { power: power, pending: [], fired: [], boot_override: BootOverrideNone, sel: [], sol_session_open: false, cycle_off_interval: second(count: 5), host_booted_at: none, booted_via_override: false, sol_drop_after_boot: none, - web: bmc_web_world_untouched, ipmi_users: [], + web: bmc_web_world_untouched, ipmi_users: [], ipmi_user_access: [], } } @@ -148,7 +149,7 @@ fn bmc_with_power(world: BmcWorld, power: BmcPower) -> BmcWorld { power: power, pending: world.pending, fired: world.fired, boot_override: world.boot_override, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, - web: world.web, ipmi_users: world.ipmi_users, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -157,7 +158,7 @@ fn bmc_with_web(world: BmcWorld, web: BmcWebWorld) -> BmcWorld { power: world.power, pending: world.pending, fired: world.fired, boot_override: world.boot_override, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, - web: web, ipmi_users: world.ipmi_users, + web: web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -266,7 +267,7 @@ fn bmc_with_override(world: BmcWorld, over: BmcBootOverride) -> BmcWorld { power: world.power, pending: world.pending, fired: world.fired, boot_override: over, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, - web: world.web, ipmi_users: world.ipmi_users, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -275,7 +276,7 @@ fn bmc_with_sol_session(world: BmcWorld, open: Bool) -> BmcWorld { power: world.power, pending: world.pending, fired: world.fired, boot_override: world.boot_override, sel: world.sel, sol_session_open: open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, - web: world.web, ipmi_users: world.ipmi_users, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -284,7 +285,7 @@ fn bmc_with_pending(world: BmcWorld, pending: List, fired: Li power: world.power, pending: pending, fired: fired, boot_override: world.boot_override, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, - web: world.web, ipmi_users: world.ipmi_users, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -300,7 +301,7 @@ fn bmc_host_boots(world: BmcWorld, now: Second) -> BmcWorld { power: BmcPowerOn, pending: pending, fired: world.fired, boot_override: BootOverrideNone, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: Present { value: now }, booted_via_override: via, sol_drop_after_boot: world.sol_drop_after_boot, - web: world.web, ipmi_users: world.ipmi_users, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -401,7 +402,7 @@ fn bmc_with_sol_drop_after_boot(world: BmcWorld, after: Second) -> BmcWorld { power: world.power, pending: world.pending, fired: world.fired, boot_override: world.boot_override, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: Present { value: after }, - web: world.web, ipmi_users: world.ipmi_users, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: world.ipmi_user_access, } } @@ -432,7 +433,7 @@ fn bmc_with_ipmi_users(world: BmcWorld, users: List) -> BmcWorld { power: world.power, pending: world.pending, fired: world.fired, boot_override: world.boot_override, sel: world.sel, sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, - web: world.web, ipmi_users: users, + web: world.web, ipmi_users: users, ipmi_user_access: world.ipmi_user_access, } } @@ -455,3 +456,42 @@ fn bmc_ipmi_set_user_password(world: BmcWorld, user: IpmiUserId, password: Strin fn bmc_ipmi_user_accepts(world: BmcWorld, user: IpmiUserId, password: String) -> Bool { any(world.ipmi_users, u => (u.id as Int) == (user as Int) && u.password == password) } + +// ── IPMI USER ACCESS ───────────────────────────────────────────────────────────────────────────── +// +// THE CONTROLLER'S PER-CHANNEL USER ACCESS TABLE: one (channel, user, privilege limit) row per pair +// the controller holds, the shape Get User Access returns (extdeps.bmc.ipmi_channel). The transition +// is the Set User Access command of the public IPMI v2.0 specification (App NetFn, command 43h): it +// sets one user's privilege limit on one channel and changes nothing else -- not the password, not +// the row of any other channel or user. A write for a user the IPMI user table does not hold changes +// nothing and is not completed. +type BmcIpmiSetUserAccessStep { + world: BmcWorld + completed: Bool +} + +fn bmc_with_ipmi_user_access(world: BmcWorld, rows: List) -> BmcWorld { + BmcWorld { + power: world.power, pending: world.pending, fired: world.fired, boot_override: world.boot_override, sel: world.sel, + sol_session_open: world.sol_session_open, cycle_off_interval: world.cycle_off_interval, + host_booted_at: world.host_booted_at, booted_via_override: world.booted_via_override, sol_drop_after_boot: world.sol_drop_after_boot, + web: world.web, ipmi_users: world.ipmi_users, ipmi_user_access: rows, + } +} + +fn bmc_ipmi_set_user_access(world: BmcWorld, access: IpmiUserChannelAccess) -> BmcIpmiSetUserAccessStep { + if any(world.ipmi_users, u => (u.id as Int) == (access.user as Int)) { + let others = filter(world.ipmi_user_access, r => !((r.user as Int) == (access.user as Int) && (r.channel as Int) == (access.channel as Int))) + BmcIpmiSetUserAccessStep { world: bmc_with_ipmi_user_access(world: world, rows: list_append(others, access)), completed: true } + } else { + BmcIpmiSetUserAccessStep { world: world, completed: false } + } +} + +// Get User Access for one (channel, user): the readback a channel-access write is judged by, +// independent of the write's completion. Absent when the controller holds no row for the pair. +fn bmc_ipmi_get_user_access(world: BmcWorld, user: IpmiUserId, channel: IpmiChannelNumber) -> IpmiChannelPrivilegeLimit? { + let wanted: IpmiChannelPrivilegeLimit? = none + filter(world.ipmi_user_access, r => (r.user as Int) == (user as Int) && (r.channel as Int) == (channel as Int)) + |> fold(init: wanted, f: (acc, r) => match acc { Absent => Present { value: r.privilege } Present { value: _ } => acc }) +} diff --git a/dag/gunbc/machine_intake/bmc_rotation_route.dag b/dag/gunbc/machine_intake/bmc_rotation_route.dag index 8c7ce292b95..b997639aa7c 100644 --- a/dag/gunbc/machine_intake/bmc_rotation_route.dag +++ b/dag/gunbc/machine_intake/bmc_rotation_route.dag @@ -1,6 +1,8 @@ module gunbc.machine_intake_bmc_rotation_route import std.types { Bool, Int, NonEmptyStr, String } +import std.scoped_authorization { AttemptIdentity } +import v2.std.algebra { any, filter, length } import std.disposition { Disposition, Terminal } import std.dissolution { DissolutionCondition, unbound_dissolution } import std.decl_ref { DeclarationRef, DeclField, WholeDeclaration, NamedField, TypeParameter, decl_ref, decl_field_ref, declaration_ref_eq } @@ -9,11 +11,14 @@ import extdeps.external_authority { ExternalAuthority } import extdeps.bmc.endpoint { AmiMegaRac, BmcControllerEndpoint, BmcFirmwareFamily, OpenBmc } import extdeps.bmc.capability { BmcFirmwareReleaseIdentity, bmc_firmware_release_identity_eq } import extdeps.bmc.access_profile { BmcAccessSurface } -import extdeps.bmc.ipmi_channel { IpmiUserId } +import extdeps.bmc.ipmi_channel { + IpmiUserId, IpmiUserChannelAccess, IpmiChannelPrivilegeLimit, IpmiChannelNumber, + IpmiPrivilegeCallback, IpmiPrivilegeUser, IpmiPrivilegeOperator, IpmiPrivilegeAdministrator, IpmiPrivilegeOem, IpmiPrivilegeNoAccess, +} import gunbc.machine_intake_receipt { EvidenceRef } import gunbc.auth.approval_capability { ProposeApprove, ProposeDeny } import gunbc.auth.approval_broker { Redemption, RedemptionAdmitted, RedemptionRefused, RedemptionRefusal } -import gunbc.bmc_model { BmcWorld, bmc_ipmi_set_user_password, bmc_ipmi_user_accepts } +import gunbc.bmc_model { BmcWorld, bmc_ipmi_set_user_password, bmc_ipmi_user_accepts, bmc_ipmi_set_user_access, bmc_ipmi_get_user_access } data bmc_rotation_route_disposition: Disposition = Terminal { reason: "The rotation route standing is the terminal form of the AccessDiscover route answer (docs/plans/managed-host-untangle.md, cut O1a): one sealed standing per controller and firmware build, bound to the evidence that grounds it, and the separate qualification effect that is the only crossing from a candidate to an executed-request grounding. It replaces the family-keyed rotation answer that gunbc.bmc_implementation_dispatch used to give; nothing here is staged pending a different construction." as NonEmptyStr, @@ -35,9 +40,19 @@ data bmc_rotation_route_disposition: Disposition = Terminal { // over the controller's IPMI LAN route; it is what mtcollins1 executed. RedfishAccountPasswordWrite // names the modeled Redfish account-password operation and action shape by reference; on MegaRAC it // is only ever a candidate today, because no AccountService write has been executed on any MegaRAC -// controller this repository has receipts for. +// controller this repository has receipts for. IpmiSetUserPrivilegeLimit is ONLY the privilege-limit +// form of the public IPMI v2.0 Set User Access command (App NetFn, command 43h): request byte 1 bit 7 +// clear, so the callback, link-authentication and IPMI-messaging bits are NOT changed, and only the +// user's privilege limit on one channel is set; no session limit is written. It is carried as the same +// (channel, user, privilege) row Get User Access returns (extdeps.bmc.ipmi_channel IpmiUserChannelAccess), +// which is a projection of that command's result, not the full command. A future live transport must +// issue exactly this mode, and a route grounded by it grounds this restricted operation only: it is not +// evidence for any other use of Set User Access. It is the write that closes a published account on a channel -- a password +// write cannot set a channel privilege to NO ACCESS -- and no execution of it is committed for any +// controller, so it is only ever a candidate today. type BmcAccountWriteRequest = IpmiSetUserPassword { user: IpmiUserId } + | IpmiSetUserPrivilegeLimit { access: IpmiUserChannelAccess } | RedfishAccountPasswordWrite { transport_operation: DeclarationRef, action_shape: DeclarationRef } // WHY A CANDIDATE IS WORTH TRYING. Either a surface was observed on THIS controller (the read surface @@ -51,11 +66,22 @@ type RouteCandidateEvidence // RouteGroundedByExecutedRequest, plus a route grounded by a source cited for this build. Only the // two Grounded arms admit an ordinary rotation Apply (admit_rotation_apply). type BmcRotationRouteGrounding - = RouteGroundedByExecutedRequest { request: BmcAccountWriteRequest, request_receipt: EvidenceRef, response_receipt: EvidenceRef } + = RouteGroundedByExecutedRequest { request: BmcAccountWriteRequest, request_receipt: EvidenceRef, response_receipt: EvidenceRef, effect: RouteEffectStanding } | RouteGroundedByCitedSource { request: BmcAccountWriteRequest, citation: ExternalAuthority } | RouteQualificationCandidate { request: BmcAccountWriteRequest, evidence: RouteCandidateEvidence } | RouteUngrounded +// WHAT AN EXECUTED REQUEST GROUNDS: that the controller ACCEPTED the operation, and -- only when the +// run could tell -- that it TOOK EFFECT. A write whose requested value equals the value already present +// reads back identically whether the controller applied it or silently ignored it, so it grounds +// acceptance only. The effect is observed exactly when the reading taken BEFORE the write differed from +// the requested value and the readback AFTER it matches; that comparison is made by whoever mints the +// response, never declared by a caller. A privilege-lowering Apply relies on the effect and requires +// EffectObserved (admit_rotation_apply). +type RouteEffectStanding + = EffectObserved + | AcceptedEffectUnobserved + // SEALED: the endpoint and build are joined to their grounding only by the mints in this module, so // no other module can pair one controller's executed request with another controller or build. The // grounding coproduct itself is not sealed (sole_constructor is discarded on a coproduct right-hand @@ -97,6 +123,7 @@ fn rotation_route_from_committed_execution( request: BmcAccountWriteRequest, request_receipt: EvidenceRef, response_receipt: EvidenceRef, + effect: RouteEffectStanding, ) -> BmcRotationRouteStanding admit_callers: [ decl_ref(module_path: "gunbc.machine_intake_bmc_rotation_route_evidence", decl_name: "mtcollins1_rotation_route_standing"), @@ -105,7 +132,7 @@ fn rotation_route_from_committed_execution( BmcRotationRouteStanding { endpoint: endpoint, firmware: firmware, - grounding: RouteGroundedByExecutedRequest { request: request, request_receipt: request_receipt, response_receipt: response_receipt }, + grounding: RouteGroundedByExecutedRequest { request: request, request_receipt: request_receipt, response_receipt: response_receipt, effect: effect }, } } @@ -121,9 +148,13 @@ fn rotation_route_from_citation( admit_callers: [ decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "a_cited_route_admits_apply_and_is_bound_to_its_build"), decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "a_rotation_approval_for_one_controller_does_not_admit_another"), + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "lockout_verdict"), decl_ref(module_path: "test.claim.machine_intake_bmc_secure_state_witness", decl_name: "cited_lab_route_managed_user"), decl_ref(module_path: "test.claim.machine_intake_bmc_secure_state_witness", decl_name: "cited_lab_route_published_user"), decl_ref(module_path: "test.claim.machine_intake_bmc_secure_state_witness", decl_name: "cited_lab_route_managed_user_previous_build"), + decl_ref(module_path: "test.claim.machine_intake_bmc_secure_state_witness", decl_name: "an_open_channel_is_closed_only_over_a_grounded_channel_access_route"), + decl_ref(module_path: "test.claim.machine_intake_bmc_secure_state_witness", decl_name: "the_channel_close_readback_is_bound_to_the_observed_run_and_account"), + decl_ref(module_path: "test.claim.machine_intake_bmc_secure_state_witness", decl_name: "a_planned_channel_close_is_applied_read_back_and_converges"), ] { BmcRotationRouteStanding { @@ -147,7 +178,7 @@ type HistoricalRotationRouteObservation { fn rotation_route_is_grounded(standing: BmcRotationRouteStanding) -> Bool { match standing.grounding { - RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _ } => true + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => true RouteGroundedByCitedSource { request: _, citation: _ } => true RouteQualificationCandidate { request: _, evidence: _ } => false RouteUngrounded => false @@ -157,6 +188,8 @@ fn rotation_route_is_grounded(standing: BmcRotationRouteStanding) -> Bool { fn account_write_request_text(request: BmcAccountWriteRequest) -> NonEmptyStr { match request { IpmiSetUserPassword { user: u } => join(["IPMI Set User Password (App 47h) user ", to_string(u as Int)], "") as NonEmptyStr + IpmiSetUserPrivilegeLimit { access: a } => + join(["IPMI Set User Access, privilege limit only (App 43h, byte 1 bit 7 clear) user ", to_string(a.user as Int), " channel ", to_string(a.channel as Int), " privilege ", canonical_ipmi_privilege(privilege: a.privilege)], "") as NonEmptyStr RedfishAccountPasswordWrite { transport_operation: op, action_shape: _ } => join(["Redfish account password write via ", op.module_path as String, " ", op.decl_name as String], "") as NonEmptyStr } @@ -174,17 +207,69 @@ fn account_write_request_eq(a: BmcAccountWriteRequest, b: BmcAccountWriteRequest IpmiSetUserPassword { user: ua } => match b { IpmiSetUserPassword { user: ub } => (ua as Int) == (ub as Int) + IpmiSetUserPrivilegeLimit { access: _ } => false + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => false + } + IpmiSetUserPrivilegeLimit { access: xa } => + match b { + IpmiSetUserPassword { user: _ } => false + IpmiSetUserPrivilegeLimit { access: xb } => + (xa.user as Int) == (xb.user as Int) + && (xa.channel as Int) == (xb.channel as Int) + && xa.privilege == xb.privilege + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => false + } + RedfishAccountPasswordWrite { transport_operation: oa, action_shape: sa } => + match b { + IpmiSetUserPassword { user: _ } => false + IpmiSetUserPrivilegeLimit { access: _ } => false + RedfishAccountPasswordWrite { transport_operation: ob, action_shape: sb } => + declaration_ref_eq(a: oa, b: ob) && declaration_ref_eq(a: sa, b: sb) + } + } +} + +// THE OPERATION a request performs, without its arguments: which command (or which modeled Redfish +// operation and action shape). A route grounds an OPERATION on a controller and build -- an executed +// Set User Password on user 3 shows that controller performs Set User Password -- while the exact +// arguments are what an approval names. So the Apply admission compares shapes, and the approval +// identity compares every field. +fn account_write_request_same_operation(a: BmcAccountWriteRequest, b: BmcAccountWriteRequest) -> Bool { + match a { + IpmiSetUserPassword { user: _ } => + match b { + IpmiSetUserPassword { user: _ } => true + IpmiSetUserPrivilegeLimit { access: _ } => false + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => false + } + IpmiSetUserPrivilegeLimit { access: _ } => + match b { + IpmiSetUserPassword { user: _ } => false + IpmiSetUserPrivilegeLimit { access: _ } => true RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => false } RedfishAccountPasswordWrite { transport_operation: oa, action_shape: sa } => match b { IpmiSetUserPassword { user: _ } => false + IpmiSetUserPrivilegeLimit { access: _ } => false RedfishAccountPasswordWrite { transport_operation: ob, action_shape: sb } => declaration_ref_eq(a: oa, b: ob) && declaration_ref_eq(a: sa, b: sb) } } } +fn canonical_ipmi_privilege(privilege: IpmiChannelPrivilegeLimit) -> String { + match privilege { + IpmiPrivilegeCallback => "callback" + IpmiPrivilegeUser => "user" + IpmiPrivilegeOperator => "operator" + IpmiPrivilegeAdministrator => "administrator" + IpmiPrivilegeOem => "oem" + IpmiPrivilegeNoAccess => "no-access" + } +} + + fn canonical_component(text: String) -> String { join([to_string(length(text)), ":", text], "") } @@ -204,6 +289,8 @@ fn canonical_decl_ref(r: DeclarationRef) -> String { fn canonical_account_write_request(request: BmcAccountWriteRequest) -> String { match request { IpmiSetUserPassword { user: u } => join(["ipmi-set-user-password;", canonical_component(text: to_string(u as Int))], "") + IpmiSetUserPrivilegeLimit { access: a } => + join(["ipmi-set-user-privilege-limit;", canonical_component(text: to_string(a.user as Int)), canonical_component(text: to_string(a.channel as Int)), canonical_component(text: canonical_ipmi_privilege(privilege: a.privilege))], "") RedfishAccountPasswordWrite { transport_operation: op, action_shape: act } => join(["redfish-account-password-write;", canonical_decl_ref(r: op), canonical_decl_ref(r: act)], "") } @@ -278,6 +365,7 @@ type RouteQualificationLiveResponse sole_constructor { response_receipt: EvidenceRef completed: Bool readback_accepted: Bool + effect: RouteEffectStanding } type ModeledRouteQualificationResponse sole_constructor { @@ -286,6 +374,11 @@ type ModeledRouteQualificationResponse sole_constructor { response_receipt: EvidenceRef completed: Bool readback_accepted: Bool + effect: RouteEffectStanding +} + +fn effect_of(before_matched: Bool, after_matched: Bool) -> RouteEffectStanding { + if !before_matched && after_matched { EffectObserved } else { AcceptedEffectUnobserved } } type DryRouteQualificationStep { @@ -293,16 +386,47 @@ type DryRouteQualificationStep { response: ModeledRouteQualificationResponse? } -// THE DRY REALIZATION. The request is the IPMI Set User Password transition of gunbc.bmc_model; the -// readback is that model's authentication of the same user with the same password, independent of -// the write's completion. The receipts digest the rendered request and response; the password is +// THE DRY REALIZATION. A Set User Password request is gunbc.bmc_model's password transition, read +// back by that model's authentication of the same user with the same password; a Set User Access +// request is its channel-access transition, read back by Get User Access for the same (channel, +// user). Each readback is independent of the write's completion. The receipts digest the rendered request and response; the password is // never rendered into either. A request the model does not carry (the Redfish account write: the // model holds no Redfish account surface) yields no response, so the classifier refuses rather than // reading a success from nothing. fn dry_route_qualification_request(world: BmcWorld, subject: RouteQualificationSubject, password: String) -> DryRouteQualificationStep { match subject.request { RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => DryRouteQualificationStep { world: world, response: none } + IpmiSetUserPrivilegeLimit { access: x } => { + let before = match bmc_ipmi_get_user_access(world: world, user: x.user, channel: x.channel) { + Present { value: p } => p == x.privilege + Absent => false + } + let step = bmc_ipmi_set_user_access(world: world, access: x) + let accepted = match bmc_ipmi_get_user_access(world: step.world, user: x.user, channel: x.channel) { + Present { value: p } => p == x.privilege + Absent => false + } + let request_text = join(["modeled ", account_write_request_text(request: subject.request) as String, " at ", subject.endpoint.host as String, " firmware ", subject.firmware.raw_version as String], "") as NonEmptyStr + let response_text = join( + [request_text as String, " -> completed=", if step.completed { "true" } else { "false" }, " get-user-access=", if accepted { "matches" } else { "differs" }], + "", + ) as NonEmptyStr + DryRouteQualificationStep { + world: step.world, + response: Present { + value: ModeledRouteQualificationResponse { + subject: subject, + request_receipt: EvidenceRef { label: request_text, digest: content_hash_of_value(value: request_text) }, + response_receipt: EvidenceRef { label: response_text, digest: content_hash_of_value(value: response_text) }, + completed: step.completed, + readback_accepted: accepted, + effect: effect_of(before_matched: before, after_matched: accepted), + }, + }, + } + } IpmiSetUserPassword { user: u } => { + let before = bmc_ipmi_user_accepts(world: world, user: u, password: password) let step = bmc_ipmi_set_user_password(world: world, user: u, password: password) let accepted = bmc_ipmi_user_accepts(world: step.world, user: u, password: password) let request_text = join(["modeled ", account_write_request_text(request: subject.request) as String, " at ", subject.endpoint.host as String, " firmware ", subject.firmware.raw_version as String, ", password length ", to_string(length(password))], "") as NonEmptyStr @@ -319,6 +443,7 @@ fn dry_route_qualification_request(world: BmcWorld, subject: RouteQualificationS response_receipt: EvidenceRef { label: response_text, digest: content_hash_of_value(value: response_text) }, completed: step.completed, readback_accepted: accepted, + effect: effect_of(before_matched: before, after_matched: accepted), }, }, } @@ -368,7 +493,7 @@ fn route_qualification_refusal( readback_accepted: Bool, ) -> RouteQualificationRefusal? { match standing.grounding { - RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _ } => Present { value: QualificationSubjectNotACandidate } + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => Present { value: QualificationSubjectNotACandidate } RouteGroundedByCitedSource { request: _, citation: _ } => Present { value: QualificationSubjectNotACandidate } RouteUngrounded => Present { value: QualificationSubjectNotACandidate } RouteQualificationCandidate { request: req, evidence: _ } => @@ -397,7 +522,7 @@ fn candidate_refusal_without_response(standing: BmcRotationRouteStanding, approv Present { value: refusal } => refusal Absent => QualificationRequestUnrealized } - RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _ } => QualificationSubjectNotACandidate + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => QualificationSubjectNotACandidate RouteGroundedByCitedSource { request: _, citation: _ } => QualificationSubjectNotACandidate RouteUngrounded => QualificationSubjectNotACandidate } @@ -424,7 +549,7 @@ fn qualify_rotation_route( standing: BmcRotationRouteStanding { endpoint: standing.endpoint, firmware: standing.firmware, - grounding: RouteGroundedByExecutedRequest { request: r.subject.request, request_receipt: r.request_receipt, response_receipt: r.response_receipt }, + grounding: RouteGroundedByExecutedRequest { request: r.subject.request, request_receipt: r.request_receipt, response_receipt: r.response_receipt, effect: r.effect }, }, } } @@ -433,7 +558,7 @@ fn qualify_rotation_route( // THE MODELED VERDICT: what the same classifier says of a modeled run. No arm carries a standing. type ModeledRouteQualificationVerdict - = ModeledQualificationWouldQualify { subject: RouteQualificationSubject, request_receipt: EvidenceRef, response_receipt: EvidenceRef } + = ModeledQualificationWouldQualify { subject: RouteQualificationSubject, request_receipt: EvidenceRef, response_receipt: EvidenceRef, effect: RouteEffectStanding } | ModeledQualificationRefused { cause: RouteQualificationRefusal } fn classify_modeled_route_qualification( @@ -446,13 +571,151 @@ fn classify_modeled_route_qualification( Present { value: r } => match route_qualification_refusal(standing: standing, approval: approval, answered: r.subject, response_receipt: r.response_receipt, completed: r.completed, readback_accepted: r.readback_accepted) { Present { value: refusal } => ModeledQualificationRefused { cause: refusal } - Absent => ModeledQualificationWouldQualify { subject: r.subject, request_receipt: r.request_receipt, response_receipt: r.response_receipt } + Absent => ModeledQualificationWouldQualify { subject: r.subject, request_receipt: r.request_receipt, response_receipt: r.response_receipt, effect: r.effect } + } + } +} + +// ── THE PRE-WRITE QUALIFICATION ADMISSION: the only value a transport call may be made from ────── +// +// THE FIRST DANGEROUS WRITE IS THE QUALIFICATION, NOT THE APPLY. Qualifying a route executes a real +// account write, so every guard the Apply has must hold BEFORE that write too. Each request shape has +// its own qualification entrypoint -- the effect boundary its census row names -- and each produces +// AdmittedRouteQualificationRequest, sealed, minted only here, and the ONLY input from which the live +// realization may make its transport call (route_qualification_live_frontier). A privilege-limit write +// is admitted only beside a same-run ManagedAdministratorReadback for the same controller and build: +// the managed account read back, uniquely, at ADMINISTRATOR on that channel, and not the account being +// lowered. No receipt, no transport call. +type AdmittedRouteQualificationRequest sole_constructor { + subject: RouteQualificationSubject + attempt: AttemptIdentity + decided_by: NonEmptyStr +} + +type RouteQualificationRequestRefusal + = QualificationRequestForAnotherOperation { candidate: BmcAccountWriteRequest } + | QualificationRequestRefusedByClassifier { cause: RouteQualificationRefusal } + | QualificationRequestWouldLeaveNoAdministrator { cause: AdministratorRetentionRefusal } + +type RouteQualificationRequestAdmission + = RouteQualificationRequestAdmitted { request: AdmittedRouteQualificationRequest } + | RouteQualificationRequestRefused { cause: RouteQualificationRequestRefusal } + +fn admit_route_qualification_request( + standing: BmcRotationRouteStanding, + approval: Redemption, + readback: ManagedAdministratorReadback?, +) -> RouteQualificationRequestAdmission { + match standing.grounding { + RouteQualificationCandidate { request: req, evidence: _ } => + match qualification_approval_refusal(standing: standing, request: req, approval: approval) { + Present { value: refusal } => RouteQualificationRequestRefused { cause: QualificationRequestRefusedByClassifier { cause: refusal } } + Absent => + match approval { + RedemptionRefused { cause: c } => RouteQualificationRequestRefused { cause: QualificationRequestRefusedByClassifier { cause: QualificationApprovalRefused { cause: c } } } + RedemptionAdmitted { claims: cl, decided_by: by } => + match qualification_retention_refusal(standing: standing, request: req, readback: readback, approved_attempt: cl.attempt) { + Present { value: c } => RouteQualificationRequestRefused { cause: QualificationRequestWouldLeaveNoAdministrator { cause: c } } + Absent => + RouteQualificationRequestAdmitted { + request: AdmittedRouteQualificationRequest { + subject: RouteQualificationSubject { endpoint: standing.endpoint, firmware: standing.firmware, request: req }, + attempt: cl.attempt, + decided_by: by, + }, + } + } + } + } + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => RouteQualificationRequestRefused { cause: QualificationRequestRefusedByClassifier { cause: QualificationSubjectNotACandidate } } + RouteGroundedByCitedSource { request: _, citation: _ } => RouteQualificationRequestRefused { cause: QualificationRequestRefusedByClassifier { cause: QualificationSubjectNotACandidate } } + RouteUngrounded => RouteQualificationRequestRefused { cause: QualificationRequestRefusedByClassifier { cause: QualificationSubjectNotACandidate } } + } +} + +// AT THE QUALIFICATION BOUNDARY a privilege-limit request that does not lower anything is admitted +// only as an IDEMPOTENT RE-ASSERTION OF THE MANAGED ACCOUNT'S OWN CURRENT VALUE: the request's target user +// IS the readback's managed account, and that account's unique row for the target channel already holds +// exactly the requested limit. The second half is not a separate check: a non-lowering request IS +// ADMINISTRATOR, and administrator_retention_refusal (applied first) already requires the managed +// account's unique row on that channel to be ADMINISTRATOR. So a managed id that changed after the +// reflash, or a target that does not already hold the value, issues no request at all, rather than +// granting a privilege. A lowering request +// at qualification is an effectful act and passes the ordinary retention precondition. +fn qualification_retention_refusal(standing: BmcRotationRouteStanding, request: BmcAccountWriteRequest, readback: ManagedAdministratorReadback?, approved_attempt: AttemptIdentity) -> AdministratorRetentionRefusal? { + match administrator_retention_refusal(standing: standing, request: request, readback: readback, approved_attempt: approved_attempt) { + Present { value: c } => Present { value: c } + Absent => + match request { + IpmiSetUserPrivilegeLimit { access: x } => + if lowers_privilege(privilege: x.privilege) { + none + } else { + match readback { + Absent => Present { value: ManagedReadbackAbsent } + Present { value: r } => + if (r.managed_user as Int) != (x.user as Int) { + Present { value: QualificationTargetIsNotTheManagedAccount { target: x.user, managed_user: r.managed_user } } + } else { + none + } + } + } + IpmiSetUserPassword { user: _ } => none + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => none + } + } +} + +fn candidate_request(standing: BmcRotationRouteStanding) -> BmcAccountWriteRequest? { + match standing.grounding { + RouteQualificationCandidate { request: r, evidence: _ } => Present { value: r } + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => none + RouteGroundedByCitedSource { request: _, citation: _ } => none + RouteUngrounded => none + } +} + +fn is_password_request(request: BmcAccountWriteRequest) -> Bool { + match request { + IpmiSetUserPassword { user: _ } => true + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => true + IpmiSetUserPrivilegeLimit { access: _ } => false + } +} + +// THE PASSWORD QUALIFICATION EFFECT. Census: route_qualification_effect. +fn admit_password_route_qualification(standing: BmcRotationRouteStanding, approval: Redemption) -> RouteQualificationRequestAdmission { + match candidate_request(standing: standing) { + Present { value: r } => + if is_password_request(request: r) { + admit_route_qualification_request(standing: standing, approval: approval, readback: none) + } else { + RouteQualificationRequestRefused { cause: QualificationRequestForAnotherOperation { candidate: r } } + } + Absent => admit_route_qualification_request(standing: standing, approval: approval, readback: none) + } +} + +// THE PRIVILEGE-LIMIT QUALIFICATION EFFECT. Census: route_qualification_channel_access_effect. +fn admit_privilege_limit_route_qualification( + standing: BmcRotationRouteStanding, + approval: Redemption, + readback: ManagedAdministratorReadback?, +) -> RouteQualificationRequestAdmission { + match candidate_request(standing: standing) { + Present { value: r } => + if is_password_request(request: r) { + RouteQualificationRequestRefused { cause: QualificationRequestForAnotherOperation { candidate: r } } + } else { + admit_route_qualification_request(standing: standing, approval: approval, readback: readback) } + Absent => admit_route_qualification_request(standing: standing, approval: approval, readback: readback) } } data route_qualification_live_frontier: DissolutionCondition = unbound_dissolution( - description: "dissolves when a live realization of the route-qualification request mints RouteQualificationLiveResponse in this module from a transport call against the controller, bound to the exact RouteQualificationSubject it was made against, under that controller's own operator go-ahead redeemed through gunbc.auth.approval_broker, with request and response bytes committed as content-addressed evidence, and qualify_rotation_route is called with it; until then RouteQualificationLiveResponse has no mint and no candidate can be grounded by qualification. NOT satisfied by the dry realization over gunbc.bmc_model BmcWorld (its ModeledRouteQualificationResponse cannot construct a standing), by a workflow entry that has not executed, or by a receipt that names no controller and build" as NonEmptyStr, + description: "dissolves when a live realization of the route-qualification request mints RouteQualificationLiveResponse in this module from a transport call against the controller made ONLY from an AdmittedRouteQualificationRequest whose pre-write receipt satisfied managed_administrator_readback_live_frontier in full (goal-bound account authentication and subject binding, unique channel/user evidence, pre-write ordering) (admit_password_route_qualification or admit_privilege_limit_route_qualification, so every pre-write guard including the same-run administrator-retention receipt has held) and, for a privilege-limit request, issued in the privilege-limit-only mode of Set User Access, bound to the exact RouteQualificationSubject it was made against, with its effect standing computed from an ESTABLISHED pre-write reading of the target that DIFFERS from the requested value and a post-write readback that MATCHES it (EffectObserved), and AcceptedEffectUnobserved otherwise -- a missing or unread pre-state is never evidence of a difference, under that controller's own operator go-ahead redeemed through gunbc.auth.approval_broker, with request and response bytes committed as content-addressed evidence, and qualify_rotation_route is called with it; until then RouteQualificationLiveResponse has no mint and no candidate can be grounded by qualification. NOT satisfied by the dry realization over gunbc.bmc_model BmcWorld (its ModeledRouteQualificationResponse cannot construct a standing), by a workflow entry that has not executed, or by a receipt that names no controller and build" as NonEmptyStr, ) // ── THE ORDINARY ROTATION APPLY CONSUMES ONLY A GROUNDED ROUTE ────────────────────────────────── @@ -463,20 +726,185 @@ data route_qualification_live_frontier: DissolutionCondition = unbound_dissoluti // controller or build refuses a write to another, so mtcollins1's executed IPMI route can never // authorize mtjade1. The approval must name the rotation authority AND this exact controller, build // and request (rotation_route_request_identity): an approval given for one controller is a different -// decision on every other, refused as RotationApplyApprovalForAnotherRequest. +// decision on every other, refused as RotationApplyApprovalForAnotherRequest. The Apply names the +// request it will make, and a route grounds one OPERATION: a grounded Set User Password route does not +// admit a Set User Access write, refused as RotationApplyRouteForAnotherOperation. type RotationApplyAdmission = RotationApplyAdmitted { standing: BmcRotationRouteStanding, request: BmcAccountWriteRequest, decided_by: NonEmptyStr } | RotationApplyRouteNotGrounded { standing: BmcRotationRouteStanding } | RotationApplyRouteForAnotherController { route_endpoint: BmcControllerEndpoint, target_endpoint: BmcControllerEndpoint } | RotationApplyRouteForAnotherBuild { route_firmware: BmcFirmwareReleaseIdentity, target_firmware: BmcFirmwareReleaseIdentity } + | RotationApplyRouteForAnotherOperation { grounded: BmcAccountWriteRequest, requested: BmcAccountWriteRequest } + | RotationApplyRouteEffectUnobserved { standing: BmcRotationRouteStanding } | RotationApplyApprovalRefused { cause: RedemptionRefusal } | RotationApplyApprovalDenied | RotationApplyApprovalForAnotherAuthority { authority: NonEmptyStr } | RotationApplyApprovalForAnotherRequest { approved: NonEmptyStr, requested: NonEmptyStr } + | RotationApplyWouldLeaveNoAdministrator { channel: IpmiChannelNumber, cause: AdministratorRetentionRefusal } + +// THE LOCKOUT HAZARD IS A REFUSAL, NOT A NOTE. A Set User Access write that lowers a user's privilege +// on a channel (anything other than ADMINISTRATOR) could remove the last administrator-capable account +// from that channel. It is admissible only beside a typed precondition: the MANAGED account -- a +// different user from the one being closed -- read back at ADMINISTRATOR on that same channel with +// Get User Access, IN THE SAME RUN, which is the attempt the approval names, ON THE SAME CONTROLLER AND +// BUILD as the route. +// +// THE READBACK IS SEALED, so the precondition is not a caller-supplied Boolean in a record. Its +// production mint, managed_administrator_readback_projected, is a projection of the BmcSecure account +// observation performed inside the BmcSecure plan mint; it is live only once that observation is +// (managed_administrator_readback_live_frontier). The one other mint is admitted only to the exact +// witness claims that consume the readback they mint and return a Bool, so no admitted caller hands a +// readback to anyone else. +type ManagedAdministratorReadback sole_constructor { + endpoint: BmcControllerEndpoint + firmware: BmcFirmwareReleaseIdentity + attempt: AttemptIdentity + managed_user: IpmiUserId + access: List +} + +fn managed_administrator_readback_fixture( + endpoint: BmcControllerEndpoint, + firmware: BmcFirmwareReleaseIdentity, + attempt: AttemptIdentity, + managed_user: IpmiUserId, + access: List, +) -> ManagedAdministratorReadback + admit_callers: [ + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "a_channel_access_write_that_could_lock_out_every_administrator_is_unplannable"), + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "a_readback_from_another_controller_or_build_does_not_unlock_a_close"), + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "a_duplicated_managed_readback_row_refuses"), + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "the_prewrite_admission_admits_only_with_the_same_run_receipt"), + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "an_accept_only_grounding_does_not_admit_the_closing_write"), + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "the_idempotent_qualification_requires_the_target_pair_to_already_hold_the_value"), + ] +{ + ManagedAdministratorReadback { endpoint: endpoint, firmware: firmware, attempt: attempt, managed_user: managed_user, access: access } +} + +// THE PRODUCTION MINT: A PROJECTION OF THE ACCOUNT OBSERVATION THE PLAN ASSESSED. This module sits below +// gunbc.machine_intake_bmc_secure and cannot name its observation type, so the projection is performed +// there, by project_managed_administrator_readback, and this mint admits that one function and nothing +// else. That function runs inside the BmcSecure plan mint, over the very BmcAccountStateObservation the +// plan assessed: the readback is therefore bound by construction to that observation's machine/intake +// subject, its goal-bound managed reference, its managed-account authentication (accepted at or after +// the read floor), its census evidence and its observer time -- all ordered before the plan, which is +// before any write -- and it is never received from a caller. +fn managed_administrator_readback_projected( + endpoint: BmcControllerEndpoint, + firmware: BmcFirmwareReleaseIdentity, + attempt: AttemptIdentity, + managed_user: IpmiUserId, + access: List, +) -> ManagedAdministratorReadback + admit_callers: [ + decl_ref(module_path: "gunbc.machine_intake_bmc_secure", decl_name: "project_managed_administrator_readback"), + ] +{ + ManagedAdministratorReadback { endpoint: endpoint, firmware: firmware, attempt: attempt, managed_user: managed_user, access: access } +} + +data managed_administrator_readback_live_frontier: DissolutionCondition = unbound_dissolution( + description: "dissolves when the BmcAccountStateObservation that managed_administrator_readback_projected is projected from is itself minted ONLY from a live read in the same run (gunbc.machine_intake_bmc_secure bmc_secure_state_live_read_frontier), against the controller, that establishes ALL of: (1) successful authentication of the GOAL-BOUND managed account (the account the BmcSecure goal names, bound to the machine/intake subject), so the reading is that account's and not a cached or supplied row; (2) the endpoint and the firmware build observed in that run, and the run's attempt; (3) a Get User Access result for every (channel, user) pair it carries, unique per pair, with the response bytes committed as content-addressed evidence; (4) an observer-clock time ordered BEFORE the write the readback admits. Missing, unreadable, duplicated or conflicting, stale, other-controller, other-build or other-account readings refuse. Until then the only observations a readback is projected from are the dry realization's, so no live privilege-limit write can be planned. NOT satisfied by the witness fixture, by a reading from another run, by a cached access row, or by a reading timed after the write" as NonEmptyStr, +) + +type AdministratorRetentionRefusal + = ManagedReadbackAbsent + | ManagedReadbackFromAnotherController { readback: BmcControllerEndpoint, route: BmcControllerEndpoint } + | ManagedReadbackFromAnotherBuild { readback: BmcFirmwareReleaseIdentity, route: BmcFirmwareReleaseIdentity } + | ManagedReadbackFromAnotherRun { readback: AttemptIdentity, approved: AttemptIdentity } + | ManagedAccountIsTheClosedAccount { user: IpmiUserId } + | ManagedAccountNotAdministratorOnChannel { managed_user: IpmiUserId } + | ManagedReadbackDuplicateRow { managed_user: IpmiUserId, count: Int } + | QualificationTargetIsNotTheManagedAccount { target: IpmiUserId, managed_user: IpmiUserId } + +fn lowers_privilege(privilege: IpmiChannelPrivilegeLimit) -> Bool { + match privilege { + IpmiPrivilegeAdministrator => false + IpmiPrivilegeCallback => true + IpmiPrivilegeUser => true + IpmiPrivilegeOperator => true + IpmiPrivilegeOem => true + IpmiPrivilegeNoAccess => true + } +} + +fn administrator_retention_refusal(standing: BmcRotationRouteStanding, request: BmcAccountWriteRequest, readback: ManagedAdministratorReadback?, approved_attempt: AttemptIdentity) -> AdministratorRetentionRefusal? { + match request { + IpmiSetUserPassword { user: _ } => none + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => none + IpmiSetUserPrivilegeLimit { access: x } => + match readback { + Absent => Present { value: ManagedReadbackAbsent } + Present { value: r } => + if (r.endpoint.host as String) != (standing.endpoint.host as String) { + Present { value: ManagedReadbackFromAnotherController { readback: r.endpoint, route: standing.endpoint } } + } else if !bmc_firmware_release_identity_eq(a: r.firmware, b: standing.firmware) { + Present { value: ManagedReadbackFromAnotherBuild { readback: r.firmware, route: standing.firmware } } + } else if (r.attempt as String) != (approved_attempt as String) { + Present { value: ManagedReadbackFromAnotherRun { readback: r.attempt, approved: approved_attempt } } + } else if lowers_privilege(privilege: x.privilege) && (r.managed_user as Int) == (x.user as Int) { + Present { value: ManagedAccountIsTheClosedAccount { user: x.user } } + } else { + let rows = filter(r.access, a => (a.user as Int) == (r.managed_user as Int) && (a.channel as Int) == (x.channel as Int)) + if length(rows) > 1 { + Present { value: ManagedReadbackDuplicateRow { managed_user: r.managed_user, count: length(rows) } } + } else if any(rows, a => !lowers_privilege(privilege: a.privilege)) { + none + } else { + Present { value: ManagedAccountNotAdministratorOnChannel { managed_user: r.managed_user } } + } + } + } + } +} + + +fn lowering_request(request: BmcAccountWriteRequest) -> Bool { + match request { + IpmiSetUserPrivilegeLimit { access: x } => lowers_privilege(privilege: x.privilege) + IpmiSetUserPassword { user: _ } => false + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => false + } +} + +// A route whose grounding observed the operation take effect: an executed request with EffectObserved, +// or a source cited for this build (the citation states the operation's effect). An accept-only +// execution does not qualify. +fn route_effect_observed(standing: BmcRotationRouteStanding) -> Bool { + match standing.grounding { + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: e } => + match e { EffectObserved => true AcceptedEffectUnobserved => false } + RouteGroundedByCitedSource { request: _, citation: _ } => true + RouteQualificationCandidate { request: _, evidence: _ } => false + RouteUngrounded => false + } +} + +// THE WITNESS'S EXECUTED-ROUTE FIXTURE: the only way to hold an executed grounding with a chosen effect +// standing while no live response mint exists. Admitted only to the one claim that consumes it and +// returns a Bool. +fn rotation_route_executed_fixture( + endpoint: BmcControllerEndpoint, + firmware: BmcFirmwareReleaseIdentity, + request: BmcAccountWriteRequest, + receipt: EvidenceRef, + effect: RouteEffectStanding, +) -> BmcRotationRouteStanding + admit_callers: [ + decl_ref(module_path: "test.claim.machine_intake_bmc_rotation_route_witness_test", decl_name: "an_accept_only_grounding_does_not_admit_the_closing_write"), + ] +{ + BmcRotationRouteStanding { + endpoint: endpoint, + firmware: firmware, + grounding: RouteGroundedByExecutedRequest { request: request, request_receipt: receipt, response_receipt: receipt, effect: effect }, + } +} fn grounded_request(standing: BmcRotationRouteStanding) -> BmcAccountWriteRequest? { match standing.grounding { - RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _ } => Present { value: r } + RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _, effect: _ } => Present { value: r } RouteGroundedByCitedSource { request: r, citation: _ } => Present { value: r } RouteQualificationCandidate { request: _, evidence: _ } => none RouteUngrounded => none @@ -487,15 +915,21 @@ fn admit_rotation_apply( standing: BmcRotationRouteStanding, target_endpoint: BmcControllerEndpoint, target_firmware: BmcFirmwareReleaseIdentity, + request: BmcAccountWriteRequest, + managed_readback: ManagedAdministratorReadback?, approval: Redemption, ) -> RotationApplyAdmission { match grounded_request(standing: standing) { Absent => RotationApplyRouteNotGrounded { standing: standing } - Present { value: request } => + Present { value: grounded } => if (standing.endpoint.host as String) != (target_endpoint.host as String) { RotationApplyRouteForAnotherController { route_endpoint: standing.endpoint, target_endpoint: target_endpoint } } else if !bmc_firmware_release_identity_eq(a: standing.firmware, b: target_firmware) { RotationApplyRouteForAnotherBuild { route_firmware: standing.firmware, target_firmware: target_firmware } + } else if !account_write_request_same_operation(a: grounded, b: request) { + RotationApplyRouteForAnotherOperation { grounded: grounded, requested: request } + } else if lowering_request(request: request) && !route_effect_observed(standing: standing) { + RotationApplyRouteEffectUnobserved { standing: standing } } else { match approval { RedemptionRefused { cause: c } => RotationApplyApprovalRefused { cause: c } @@ -508,7 +942,15 @@ fn admit_rotation_apply( } else if cl.request_revision != rotation_route_request_identity(standing: standing, request: request) { RotationApplyApprovalForAnotherRequest { approved: cl.request_revision, requested: rotation_route_request_identity(standing: standing, request: request) } } else { - RotationApplyAdmitted { standing: standing, request: request, decided_by: by } + match request { + IpmiSetUserPrivilegeLimit { access: x } => + match administrator_retention_refusal(standing: standing, request: request, readback: managed_readback, approved_attempt: cl.attempt) { + Present { value: c } => RotationApplyWouldLeaveNoAdministrator { channel: x.channel, cause: c } + Absent => RotationApplyAdmitted { standing: standing, request: request, decided_by: by } + } + IpmiSetUserPassword { user: _ } => RotationApplyAdmitted { standing: standing, request: request, decided_by: by } + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => RotationApplyAdmitted { standing: standing, request: request, decided_by: by } + } } } } diff --git a/dag/gunbc/machine_intake/bmc_rotation_route_evidence.dag b/dag/gunbc/machine_intake/bmc_rotation_route_evidence.dag index 0740ee294bf..d1705aba790 100644 --- a/dag/gunbc/machine_intake/bmc_rotation_route_evidence.dag +++ b/dag/gunbc/machine_intake/bmc_rotation_route_evidence.dag @@ -1,10 +1,11 @@ module gunbc.machine_intake_bmc_rotation_route_evidence -import std.types { NonEmptyStr, String } +import std.types { Int, NonEmptyStr, String } +import std.dissolution { DissolutionCondition, unbound_dissolution } import std.content_hash { Sha256Hash } import std.content_hash { sha256_hex_digest } -import extdeps.bmc.endpoint { BmcControllerEndpoint } -import extdeps.bmc.capability { bmc_firmware_release_identity_of_wire } +import extdeps.bmc.endpoint { AmiMegaRac, BmcControllerEndpoint } +import extdeps.bmc.capability { BmcFirmwareReleaseIdentity, bmc_firmware_release_identity_of_wire } import extdeps.bmc.access_profile { SurfaceManagerIdentity } import extdeps.network.ipv4 { render_ipv4_address } import gunbc.machine_intake_receipt { EvidenceRef } @@ -19,9 +20,11 @@ import gunbc.machine_intake_mtjade1_access_observation { } import gunbc.machine_intake_mtcollins1_access_observation { mtcollins1_endpoint, mtcollins1_firmware } import gunbc.machine_intake_mtcollins1_bmc_secure_observation { mtcollins1_user3_route_evidence } +import extdeps.bmc.ipmi_channel { IpmiPrivilegeAdministrator, ipmi_user_channel_access, extdeps_external_authority_anchor } +import extdeps.ampere.mt_collins_firmware_release { mt_collins_bmc_0_45_3_hpm } import gunbc.machine_intake_bmc_rotation_route { - BmcRotationRouteStanding, HistoricalRotationRouteObservation, IpmiSetUserPassword, ObservedSurfaceRead, - rotation_route_from_committed_execution, redfish_account_password_write, + BmcRotationRouteStanding, HistoricalRotationRouteObservation, IpmiSetUserPassword, IpmiSetUserPrivilegeLimit, ObservedSurfaceRead, + PublicStandardOperation, EffectObserved, rotation_route_candidate, rotation_route_from_committed_execution, redfish_account_password_write, } // THE ROTATION ROUTE STANDING OF EACH CONTROLLER THIS FLEET HAS EVIDENCE FOR, derived from that @@ -33,7 +36,9 @@ import gunbc.machine_intake_bmc_rotation_route { // store round-trip, and the controller answered "Set User Password command successful"; step (d) // then authenticated as that user over IPMI and the web API at the same address. The request and // its response are both recorded in that one transcript, so both receipts name it: the transcript -// is the request receipt and the response receipt, at its committed digest. It is consumed for the +// is the request receipt and the response receipt, at its committed digest. THE EFFECT WAS OBSERVED: +// the value set was a newly minted secret the account did not hold before (steps b and c), and step (d) +// then authenticated with it over IPMI and the web API, so the before and after readings differ. It is consumed for the // same rotation by gunbc.machine_intake_mtcollins1_bmc_secure_observation as RotationApplied. fn mtcollins1_rotation_route_standing() -> BmcRotationRouteStanding { rotation_route_from_committed_execution( @@ -42,6 +47,65 @@ fn mtcollins1_rotation_route_standing() -> BmcRotationRouteStanding { request: IpmiSetUserPassword { user: 3 }, request_receipt: mtcollins1_user3_route_evidence, response_receipt: mtcollins1_user3_route_evidence, + effect: EffectObserved, + ) +} + +// MTCOLLINS1'S CHANNEL-ACCESS ROUTE (cut O1a-2): A CANDIDATE, NOT GROUNDED. The BmcSecure conjunction +// needs the published account refused on every LAN census member, and a password write cannot set a +// channel privilege limit to NO ACCESS; Set User Access can. No execution of it on this controller is +// committed, so the standing is a qualification candidate and nothing more. +// +// THE CONTROLLER AND BUILD ARE THE CURRENT ONES. The endpoint is the unit's controller address. The +// build is BMC 0.45.3, the release extdeps.ampere.mt_collins_firmware_release mt_collins_bmc_0_45_3_hpm +// installed on 2026-10-02 (gunbc.fleet.mtcollins_firmware_converge credential_effect_of records that +// reflash), so it is NOT mtcollins1_firmware (0.32), and the executed password route on 0.32 does not +// carry over to it (admit_rotation_apply refuses another build). The raw string is the release's own +// version; no post-reflash version readback is committed (see the evidence note below). +// +// THE QUALIFYING REQUEST IS CHOSEN TO BE NON-DESTRUCTIVE. It re-asserts the MANAGED account's own +// ADMINISTRATOR limit on LAN channel 1 -- user 3, the gunbc account's IPMI id before the reflash -- rather +// than closing the factory administrator. It is safe because the pre-write admission +// (admit_privilege_limit_route_qualification) requires a same-run Get User Access readback, on this +// controller and build, showing that user ALREADY at ADMINISTRATOR on channel 1 as the unique row for +// the pair: so the write sets exactly the value just read, changes no access, and still exercises the +// command and its readback. If the post-reflash managed id or channel differs, that readback refuses +// and nothing is written. +// +// WHAT THIS QUALIFICATION CAN AND CANNOT GROUND, stated because the first wording of this paragraph got +// it wrong (review 76375). Because the write sets the value already read, its before and after readings +// match, so a live run of it grounds the operation as AcceptedEffectUnobserved: the controller accepts +// the privilege-limit request, and nothing more. admit_rotation_apply refuses every privilege-LOWERING +// Apply over such a route (RotationApplyRouteEffectUnobserved). Closing the factory administrator (user +// 2 to NO ACCESS on the channels the operator reports it still holds, eager-gull-22 2026-10-04) is +// therefore NOT reachable from this candidate. It needs a second, effect-observing qualification +// (mtcollins1_channel_close_effect_qualification_frontier). +// +// EVIDENCE IS THE PUBLIC STANDARD ONLY. The IPMI v2.0 specification defines Set User Access +// (extdeps.bmc.ipmi_channel's cited authority). NO post-reflash channel-access observation is +// committed, so none is cited. The read-only observations missing, each to be committed as a +// content-addressed receipt from the controller at its current address: Get Channel Info for every +// channel 0h-Fh (the post-reflash channel census), Get User Access for the published user on every +// channel that census returns, and a version readback (Get Device ID / mc info) naming the installed +// BMC build. +data mtcollins1_channel_close_effect_qualification_frontier: DissolutionCondition = unbound_dissolution( + description: "dissolves when a channel-access qualification on mtcollins1's current controller and build grounds the privilege-limit operation with EffectObserved: a request that is both non-destructive and discriminating, whose ESTABLISHED pre-write reading differs from the requested value and whose post-write readback matches it -- for example a spare user slot that a committed post-reflash Get User Access observation shows disabled or unused on a channel, changed, read back, then restored and read back -- so that admit_rotation_apply can admit the factory administrator's close; NOT satisfied by the idempotent re-assertion candidate above (accept-only by construction), by a modeled run, or by a slot chosen without a committed observation identifying it" as NonEmptyStr, +) + +fn mtcollins1_current_bmc_firmware() -> BmcFirmwareReleaseIdentity { + let v = mt_collins_bmc_0_45_3_hpm.version + bmc_firmware_release_identity_of_wire( + family: AmiMegaRac, + wire: join([to_string(v.major as Int), ".", to_string(v.minor as Int), ".", to_string(v.patch as Int)], "") as NonEmptyStr, + ) +} + +fn mtcollins1_channel_access_route_standing() -> BmcRotationRouteStanding { + rotation_route_candidate( + endpoint: mtcollins1_endpoint, + firmware: mtcollins1_current_bmc_firmware(), + request: IpmiSetUserPrivilegeLimit { access: ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeAdministrator) }, + evidence: PublicStandardOperation { authority: extdeps_external_authority_anchor }, ) } diff --git a/dag/gunbc/machine_intake/bmc_secure.dag b/dag/gunbc/machine_intake/bmc_secure.dag index 04eb56100dc..52cfa98eb31 100644 --- a/dag/gunbc/machine_intake/bmc_secure.dag +++ b/dag/gunbc/machine_intake/bmc_secure.dag @@ -1,6 +1,8 @@ module gunbc.machine_intake_bmc_secure import std.types { Bool, EpochMs, Int, List, Map, NonEmptyStr, String, list_length } +import v2.std.algebra { filter } +import std.decl_ref { decl_ref } import std.content_hash { ContentHash, content_hash_of_value } import std.dissolution { DissolutionCondition, unbound_dissolution } import std.algebra { FreeSemigroup } @@ -29,7 +31,8 @@ import extdeps.cloud.gcp.secret_manager { } import gunbc.clock_read { ObserverClockInstant, observer_clock_modeled, observer_instant_millis, observer_instant_precedes } import gunbc.host_convergence_protocol { HostEffectDomainProjection, inspect_via_host_effect_projection } -import gunbc.auth.approval_broker { Redemption } +import gunbc.auth.approval_broker { Redemption, RedemptionAdmitted, RedemptionRefused } +import std.scoped_authorization { AttemptIdentity } import gunbc.auth.secret_ref_credential { SecretCredentialFetch, SecretCredentialReady, @@ -38,7 +41,7 @@ import gunbc.auth.secret_ref_credential { SecretCredentialFetchRefused, SecretCredentialResolvedVersionMismatch, } -import gunbc.bmc_model { BmcWorld, BmcIpmiSetUserPasswordStep, bmc_ipmi_set_user_password, bmc_ipmi_user_accepts } +import gunbc.bmc_model { BmcWorld, BmcIpmiSetUserPasswordStep, bmc_ipmi_set_user_password, bmc_ipmi_user_accepts, bmc_ipmi_set_user_access } import gunbc.machine_intake_bmc_rotation_route { BmcRotationRouteStanding, BmcAccountWriteRequest, @@ -53,12 +56,20 @@ import gunbc.machine_intake_bmc_rotation_route { RotationApplyApprovalDenied, RotationApplyApprovalForAnotherAuthority, RotationApplyApprovalForAnotherRequest, + RotationApplyRouteForAnotherOperation, + RotationApplyRouteEffectUnobserved, + RotationApplyWouldLeaveNoAdministrator, + IpmiSetUserPrivilegeLimit, + ManagedAdministratorReadback, + managed_administrator_readback_projected, + rotation_route_request_identity, account_write_request_text, admit_rotation_apply, } import extdeps.bmc.endpoint { BmcControllerEndpoint } import extdeps.bmc.types { RedfishAccountRole } import extdeps.bmc.ipmi_channel { + ipmi_controller_channel_census, IpmiChannelCensusMember, IpmiChannelNumber, IpmiControllerChannelCensus, @@ -69,6 +80,7 @@ import extdeps.bmc.ipmi_channel { IpmiPrivilegeNoAccess, IpmiUserChannelAccess, IpmiUserId, + ipmi_user_channel_access, } import extdeps.network.ipv4 { Ipv4Address } import extdeps.cloud.gcp.secret_ref { SecretRef, HashPending, gcp_resource_names_this_secret } @@ -1230,6 +1242,8 @@ type BmcAccountStateObservation sole_constructor { endpoint: BmcControllerEndpoint firmware: BmcFirmwareReleaseIdentity managed: ManagedCredentialReference + managed_user: IpmiUserId + attempt: AttemptIdentity read_floor: ObserverClockInstant managed_probe: ObservedCredentialProbe channel_census: IpmiControllerChannelCensus @@ -1248,6 +1262,8 @@ fn observed_bmc_account_state( endpoint: BmcControllerEndpoint, firmware: BmcFirmwareReleaseIdentity, managed: ManagedCredentialReference, + managed_user: IpmiUserId, + attempt: AttemptIdentity, read_floor: ObserverClockInstant, managed_probe: ObservedCredentialProbe, channel_census: IpmiControllerChannelCensus, @@ -1259,12 +1275,18 @@ fn observed_bmc_account_state( break_glass: ManagedCredentialReference, break_glass_probe: ObservedCredentialProbe, controller_clock: ControllerClockReading?, -) -> BmcAccountStateObservation { +) -> BmcAccountStateObservation + admit_callers: [ + decl_ref(module_path: "gunbc.machine_intake_bmc_secure", decl_name: "dry_read_bmc_account_state"), + ] +{ BmcAccountStateObservation { subject: subject, endpoint: endpoint, firmware: firmware, managed: managed, + managed_user: managed_user, + attempt: attempt, read_floor: read_floor, managed_probe: managed_probe, channel_census: channel_census, @@ -1360,13 +1382,15 @@ type BmcSecureStateRefusal // establish a state; it is never a deviation, because writing on an unread controller is the // absorbing fallback DESIGN §5 forbids. Everything else -- an ordering, a duplicated or unmatched // reading, a retention under a ProdRisk-admitting policy -- refuses the assessment. -// THE ONLY ADMITTED ACTION IS A PASSWORD WRITE (IpmiSetUserPassword over a grounded route). It cannot -// give a LAN channel an address, set a channel's privilege to NO ACCESS, or put the factory password -// back, so a deviation only those operations change is not remediable here: it refuses with the -// missing operation named, rather than planning a password write that cannot clear it. -type MissingAccountOperation - = ChannelAccessWrite - | PublishedFactoryCredentialRestore +// TWO ADMITTED ACTIONS: a password write (IpmiSetUserPassword) and, since cut O1a-2, a channel-access +// write (the privilege-limit-only Set User Access, IpmiSetUserPrivilegeLimit). A published account still +// holding access on a LAN channel -- addressed or not -- is therefore a DEVIATION the plan remedies, and +// it is admissible ONLY over a GROUNDED channel-access route: the plan mint computes each channel write's +// admission with admit_rotation_apply and refuses on every other arm, so "no admitted route performs a +// channel-access write" is now a typed plan refusal rather than an assessment refusal. Putting the +// factory password back is still not an admitted action, so that deviation still refuses with the +// missing operation named. +type MissingAccountOperation = | PublishedFactoryCredentialRestore type ConjunctionCauseClass = CauseRemediableByAccountAction @@ -1393,8 +1417,8 @@ fn conjunction_cause_class(cause: BmcSecureRefusalCause) -> ConjunctionCauseClas PublishedCredentialAccountPrecedesRotation { applied_at: _, observed_at: _ } => CauseReadingPrecedesFloor PublishedCredentialCensusNotTaken => CauseUnestablishedReading PublishedCredentialNoAddressableLanMember => CauseUnestablishedReading - PublishedCredentialLanMemberUnaddressed { channel: _ } => CauseNeedsUngroundedOperation { operation: ChannelAccessWrite } - PublishedCredentialChannelAccessNotClosed { channel: _ } => CauseNeedsUngroundedOperation { operation: ChannelAccessWrite } + PublishedCredentialLanMemberUnaddressed { channel: _ } => CauseRemediableByAccountAction + PublishedCredentialChannelAccessNotClosed { channel: _ } => CauseRemediableByAccountAction PublishedCredentialUserAccessUnestablished { channel: _ } => CauseUnestablishedReading PublishedCredentialUserAccessDuplicate { channel: _ } => CauseRefusesAssessment PublishedCredentialCensusMemberUnprobed { channel: _ } => CauseUnestablishedReading @@ -1553,7 +1577,6 @@ fn bmc_secure_state_refusal_label(cause: BmcSecureStateRefusal) -> NonEmptyStr { AccountStateConjunctionRefused { cause: c } => bmc_secure_refusal_label(cause: c) AccountDeviationNeedsUngroundedOperation { cause: _, operation: op } => match op { - ChannelAccessWrite => "the deviation needs a channel-access write, and no admitted route performs one; a password write cannot clear it" PublishedFactoryCredentialRestore => "the policy retains the factory credential and it is not accepted; restoring it is not an admitted operation" } AccountRetentionNotGoalBound { retained: _, goal: _ } => "the break-glass account retained by policy is not the generation the goal names" @@ -1729,6 +1752,7 @@ type BmcAccountActionPlan sole_constructor { due: BmcAccountActionDue managed_write: PlannedAccountWrite published_write: PlannedAccountWrite + channel_writes: List planned_at: ObserverClockInstant } @@ -1743,6 +1767,11 @@ type BmcAccountPlanRefusal | PublishedGenerationNotGoalBound { generation: ManagedCredentialReference, goal: ManagedCredentialReference } | GenerationFetchedAfterPlan { target: AccountWriteTarget, fetched_at: ObserverClockInstant, planned_at: ObserverClockInstant } | PlanPrecedesDivergedReading { read_floor: ObserverClockInstant, planned_at: ObserverClockInstant } + | PlanPrecedesReading { planned_at: ObserverClockInstant } + | ManagedUserNotTheAuthenticatedAccount { supplied: IpmiUserId, authenticated: IpmiUserId } + | ChannelCloseRouteNotSupplied { channels: List } + | ChannelCloseApprovalAbsent { channel: IpmiChannelNumber } + | ChannelWriteNotAdmitted { channel: IpmiChannelNumber, admission: RotationApplyAdmission } type BmcAccountPlanOutcome = BmcAccountPlanned { plan: BmcAccountActionPlan } @@ -1758,12 +1787,14 @@ fn admitted_account_write( generation: ManagedCredentialGenerationFetched, planned_at: ObserverClockInstant, ) -> PlannedAccountWriteAdmission { - let admission = admit_rotation_apply(standing: route, target_endpoint: endpoint, target_firmware: firmware, approval: approval) + let admission = admit_rotation_apply(standing: route, target_endpoint: endpoint, target_firmware: firmware, request: IpmiSetUserPassword { user: user }, managed_readback: none, approval: approval) match admission { RotationApplyAdmitted { standing: s, request: req, decided_by: by } => match req { RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => PlannedAccountWriteRefused { cause: AccountWriteRequestNotIpmiUser { target: target, request: req } } + IpmiSetUserPrivilegeLimit { access: _ } => + PlannedAccountWriteRefused { cause: AccountWriteRequestNotIpmiUser { target: target, request: req } } IpmiSetUserPassword { user: u } => if (u as Int) != (user as Int) { PlannedAccountWriteRefused { cause: AccountWriteRequestForAnotherUser { target: target, admitted: u, required: user } } @@ -1782,6 +1813,157 @@ fn admitted_account_write( RotationApplyApprovalDenied => PlannedAccountWriteRefused { cause: AccountWriteNotAdmitted { target: target, admission: admission } } RotationApplyApprovalForAnotherAuthority { authority: _ } => PlannedAccountWriteRefused { cause: AccountWriteNotAdmitted { target: target, admission: admission } } RotationApplyApprovalForAnotherRequest { approved: _, requested: _ } => PlannedAccountWriteRefused { cause: AccountWriteNotAdmitted { target: target, admission: admission } } + RotationApplyRouteForAnotherOperation { grounded: _, requested: _ } => PlannedAccountWriteRefused { cause: AccountWriteNotAdmitted { target: target, admission: admission } } + RotationApplyRouteEffectUnobserved { standing: _ } => PlannedAccountWriteRefused { cause: AccountWriteNotAdmitted { target: target, admission: admission } } + RotationApplyWouldLeaveNoAdministrator { channel: _, cause: _ } => PlannedAccountWriteRefused { cause: AccountWriteNotAdmitted { target: target, admission: admission } } + } +} + +// ── THE CHANNEL-ACCESS WRITES (cut O1a-2) ──────────────────────────────────────────────────────── +// +// Every census member on which the published account still holds access (its unique Get User Access +// row is not NO ACCESS) gets one privilege-limit-only Set User Access write setting it to NO +// ACCESS, over the supplied channel-access route. Each write's admission is COMPUTED by +// admit_rotation_apply: the route must be grounded with its effect observed for this controller and +// build, the approval must name this exact write, and the administrator-retention readback is +// PROJECTED here from the very observation the plan assessed -- the managed account authenticated in +// that read, and its own unique Get User Access row on the channel at ADMINISTRATOR -- never received. +type PlannedChannelAccessWrite { + channel: IpmiChannelNumber + route: BmcRotationRouteStanding + request: BmcAccountWriteRequest + decided_by: NonEmptyStr +} + +type ChannelCloseInput { + route: BmcRotationRouteStanding + approvals: List +} + +fn census_member_channel(m: IpmiChannelCensusMember) -> IpmiChannelNumber { + match m { + IpmiNonLanChannelMember { channel: ch, medium: _ } => ch + IpmiLanChannelMember { channel: ch, medium: _, ipv4: _ } => ch + } +} + +// Every census member -- LAN, addressed or not, and non-LAN such as a serial channel -- on which the +// published account's unique Get User Access row is not NO ACCESS. A missing or duplicated row is not +// listed here: the conjunction already refuses those readings before any plan. +fn published_channels_left_open(observed: BmcAccountStateObservation) -> List { + let index = index_published_user_access(rows: observed.channel_census.user_access) + fold(observed.channel_census.members, init: [], f: (acc, m) => + match map_get(index, published_user_access_key(channel: census_member_channel(m: m), user: observed.published_user)) { + Absent => acc + Present { value: slot } => + match slot { + SeveralUserAccess => acc + OneUserAccess { access: row } => if row.privilege == IpmiPrivilegeNoAccess { acc } else { concat(acc, [census_member_channel(m: m)]) } + } + }) +} + +// THE PROJECTION. Present only when the observation established the managed account's authentication +// at or after its read floor and took its census at or after that floor; the access rows are the +// census's Get User Access rows for the AUTHENTICATED managed user the observation recorded, and the +// readback carries the observation's own endpoint, build and attempt -- all set by the observation's +// producer, none by a consumer. The admission then compares that attempt with the approval's, so an +// approval for another run refuses. Admitted only to admitted_channel_writes: no facade returns it. +fn project_managed_administrator_readback(observed: BmcAccountStateObservation) -> ManagedAdministratorReadback? + admit_callers: [ + decl_ref(module_path: "gunbc.machine_intake_bmc_secure", decl_name: "admitted_channel_writes"), + ] +{ + match observed.managed_probe { + ObservedCredentialAccepted { reading: r } => + if observer_instant_precedes(earlier: r.observed_at, later: observed.read_floor) || observer_instant_precedes(earlier: observed.census_observed_at, later: observed.read_floor) { + none + } else { + Present { + value: managed_administrator_readback_projected( + endpoint: observed.endpoint, + firmware: observed.firmware, + attempt: observed.attempt, + managed_user: observed.managed_user, + access: filter(observed.channel_census.user_access, a => (a.user as Int) == (observed.managed_user as Int)), + ), + } + } + ObservedCredentialRejected { reading: _ } => none + ObservedCredentialUnestablished { detail: _ } => none + } +} + +fn managed_probe_instant(probe: ObservedCredentialProbe, fallback: ObserverClockInstant) -> ObserverClockInstant { + match probe { + ObservedCredentialAccepted { reading: r } => r.observed_at + ObservedCredentialRejected { reading: r } => r.observed_at + ObservedCredentialUnestablished { detail: _ } => fallback + } +} + +fn approval_for_request(route: BmcRotationRouteStanding, request: BmcAccountWriteRequest, approvals: List) -> Redemption? { + let wanted = rotation_route_request_identity(standing: route, request: request) + let none_yet: Redemption? = none + fold(approvals, init: none_yet, f: (acc, a) => + match acc { + Present { value: _ } => acc + Absent => + match a { + RedemptionAdmitted { claims: cl, decided_by: _ } => if cl.request_revision == wanted { Present { value: a } } else { acc } + RedemptionRefused { cause: _ } => acc + } + }) +} + +type ChannelWritesAdmission + = ChannelWritesAdmitted { writes: List } + | ChannelWritesRefused { cause: BmcAccountPlanRefusal } + +fn admitted_channel_writes(observed: BmcAccountStateObservation, input: ChannelCloseInput?) -> ChannelWritesAdmission { + let open = published_channels_left_open(observed: observed) + if list_length(items: open) == 0 { + ChannelWritesAdmitted { writes: [] } + } else { + match input { + Absent => ChannelWritesRefused { cause: ChannelCloseRouteNotSupplied { channels: open } } + Present { value: inp } => + fold(open, init: ChannelWritesAdmitted { writes: [] }, f: (acc, ch) => + match acc { + ChannelWritesRefused { cause: _ } => acc + ChannelWritesAdmitted { writes: done } => { + let request = IpmiSetUserPrivilegeLimit { access: ipmi_user_channel_access(channel: ch, user: observed.published_user, privilege: IpmiPrivilegeNoAccess) } + match approval_for_request(route: inp.route, request: request, approvals: inp.approvals) { + Absent => ChannelWritesRefused { cause: ChannelCloseApprovalAbsent { channel: ch } } + Present { value: approval } => { + let readback = project_managed_administrator_readback(observed: observed) + let admission = admit_rotation_apply( + standing: inp.route, + target_endpoint: observed.endpoint, + target_firmware: observed.firmware, + request: request, + managed_readback: readback, + approval: approval, + ) + match admission { + RotationApplyAdmitted { standing: st, request: req, decided_by: by } => + ChannelWritesAdmitted { writes: concat(done, [PlannedChannelAccessWrite { channel: ch, route: st, request: req, decided_by: by }]) } + RotationApplyRouteNotGrounded { standing: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyRouteForAnotherController { route_endpoint: _, target_endpoint: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyRouteForAnotherBuild { route_firmware: _, target_firmware: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyRouteForAnotherOperation { grounded: _, requested: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyRouteEffectUnobserved { standing: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyApprovalRefused { cause: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyApprovalDenied => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyApprovalForAnotherAuthority { authority: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyApprovalForAnotherRequest { approved: _, requested: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + RotationApplyWouldLeaveNoAdministrator { channel: _, cause: _ } => ChannelWritesRefused { cause: ChannelWriteNotAdmitted { channel: ch, admission: admission } } + } + } + } + } + }) + } } } @@ -1802,6 +1984,7 @@ fn plan_bmc_account_action( published_route: BmcRotationRouteStanding, published_approval: Redemption, published_generation: ManagedCredentialGenerationFetched, + channel_close: ChannelCloseInput?, planned_at: ObserverClockInstant, ) -> BmcAccountPlanOutcome { match inspect_bmc_secure_state(subject: subject, goal: goal, reading: reading) { @@ -1813,6 +1996,10 @@ fn plan_bmc_account_action( Apply { plan: due } => if observer_instant_precedes(earlier: planned_at, later: o.read_floor) { BmcAccountPlanRefused { cause: PlanPrecedesDivergedReading { read_floor: o.read_floor, planned_at: planned_at } } + } else if observer_instant_precedes(earlier: planned_at, later: o.census_observed_at) || observer_instant_precedes(earlier: planned_at, later: managed_probe_instant(probe: o.managed_probe, fallback: o.read_floor)) { + BmcAccountPlanRefused { cause: PlanPrecedesReading { planned_at: planned_at } } + } else if (managed_user as Int) != (o.managed_user as Int) { + BmcAccountPlanRefused { cause: ManagedUserNotTheAuthenticatedAccount { supplied: managed_user, authenticated: o.managed_user } } } else { let next = fetched_generation_reference(fetched: managed_generation) let in_force = goal.managed @@ -1829,6 +2016,9 @@ fn plan_bmc_account_action( match admitted_account_write(target: PublishedAccountTarget, user: o.published_user, route: published_route, endpoint: o.endpoint, firmware: o.firmware, approval: published_approval, generation: published_generation, planned_at: planned_at) { PlannedAccountWriteRefused { cause: c } => BmcAccountPlanRefused { cause: c } PlannedAccountWriteAdmitted { write: pw } => + match admitted_channel_writes(observed: o, input: channel_close) { + ChannelWritesRefused { cause: c } => BmcAccountPlanRefused { cause: c } + ChannelWritesAdmitted { writes: cw } => BmcAccountPlanned { plan: BmcAccountActionPlan { subject: subject, @@ -1839,9 +2029,11 @@ fn plan_bmc_account_action( due: due, managed_write: mw, published_write: pw, + channel_writes: cw, planned_at: planned_at, }, } + } } } } @@ -1859,6 +2051,7 @@ type BmcAccountApplication sole_constructor { plan: BmcAccountActionPlan managed_write_completed: Bool published_write_completed: Bool + channel_writes_completed: Bool request_receipt: EvidenceRef response_receipt: EvidenceRef applied_at: ObserverClockInstant @@ -1887,7 +2080,7 @@ type BmcSecurePhaseReceipt sole_constructor { type BmcSecurePhaseRefusal = PhaseReadingUnobserved { cause: BmcSecureStateRefusal } | PhaseNotHeld { decision: UpsertDecision } - | ApplicationIncomplete { managed_write_completed: Bool, published_write_completed: Bool, response_receipt: EvidenceRef } + | ApplicationIncomplete { managed_write_completed: Bool, published_write_completed: Bool, channel_writes_completed: Bool, response_receipt: EvidenceRef } | PostReadForAnotherController { expected: BmcControllerEndpoint, found: BmcControllerEndpoint } | PostReadPrecedesApplication { applied_at: ObserverClockInstant, read_floor: ObserverClockInstant } | ApplicationPrecedesPlan { planned_at: ObserverClockInstant, applied_at: ObserverClockInstant } @@ -1922,11 +2115,12 @@ fn bmc_secure_phase_applied( post_read: BmcAccountStateObservation, ) -> BmcSecurePhaseOutcome { let plan = application.plan - if !(application.managed_write_completed && application.published_write_completed) { + if !(application.managed_write_completed && application.published_write_completed && application.channel_writes_completed) { BmcSecurePhaseRefused { cause: ApplicationIncomplete { managed_write_completed: application.managed_write_completed, published_write_completed: application.published_write_completed, + channel_writes_completed: application.channel_writes_completed, response_receipt: application.response_receipt, }, } @@ -2016,7 +2210,11 @@ fn dry_published_lan_probes( } // ONE READ OF THE WORLD'S ACCOUNT STATE. read_at_millis is the realization's observer schedule; every -// reading in the observation is taken at it. +// reading in the observation is taken at it. The census MEMBERS (which channels exist, their media and +// LAN addresses) are the supplied channel layout; every Get User Access row is read from the world, so a +// readback after a channel-access write reports what the write did. managed_user is the IPMI user the +// managed probe authenticated as, and attempt is the run this read belongs to: both are recorded here, +// by the producer, and never assigned later by a consumer. fn dry_read_bmc_account_state( world: BmcWorld, subject: MachineIntakeSubject, @@ -2031,6 +2229,7 @@ fn dry_read_bmc_account_state( published_account: PublishedAccountKind, break_glass: ManagedCredentialReference, break_glass_password: String, + attempt: AttemptIdentity, read_at_millis: EpochMs, ) -> BmcAccountStateObservation { let at = dry_bmc_account_instant(millis: read_at_millis) @@ -2039,9 +2238,11 @@ fn dry_read_bmc_account_state( endpoint: endpoint, firmware: firmware, managed: managed, + managed_user: managed_user, + attempt: attempt, read_floor: at, managed_probe: dry_probe(world: world, user: managed_user, password: managed_password, what: "managed", at: at), - channel_census: census, + channel_census: ipmi_controller_channel_census(members: census.members, user_access: world.ipmi_user_access), census_evidence: dry_evidence(text: join(["dry channel census of ", endpoint.host as String, " at ", to_string(read_at_millis as Int)], "")), census_observed_at: at, published_probes: dry_published_lan_probes(world: world, census: census, published_user: published_user, published_password: published_password, at: at), @@ -2057,6 +2258,11 @@ fn dry_read_bmc_account_state( ) } +type BmcChannelWritesDryStep { + world: BmcWorld + completed: Bool +} + type BmcAccountDryStep { world: BmcWorld application: BmcAccountApplication @@ -2091,20 +2297,33 @@ fn dry_apply_bmc_account_plan( Absent => BmcIpmiSetUserPasswordStep { world: managed_step.world, completed: false } Present { value: pw } => bmc_ipmi_set_user_password(world: managed_step.world, user: plan.published_write.user, password: pw) } + let channel_steps = fold(plan.channel_writes, init: BmcChannelWritesDryStep { world: published_step.world, completed: true }, f: (acc, w) => + match w.request { + IpmiSetUserPrivilegeLimit { access: x } => { + let step = bmc_ipmi_set_user_access(world: acc.world, access: x) + BmcChannelWritesDryStep { world: step.world, completed: acc.completed && step.completed } + } + IpmiSetUserPassword { user: _ } => BmcChannelWritesDryStep { world: acc.world, completed: false } + RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => BmcChannelWritesDryStep { world: acc.world, completed: false } + }) let request_text = join( - ["dry ", account_write_request_text(request: plan.managed_write.request) as String, " then ", account_write_request_text(request: plan.published_write.request) as String, " on ", plan.endpoint.host as String], + concat( + ["dry ", account_write_request_text(request: plan.managed_write.request) as String, " then ", account_write_request_text(request: plan.published_write.request) as String], + concat(map(plan.channel_writes, w => concat(" then ", account_write_request_text(request: w.request) as String)), [" on ", plan.endpoint.host as String]), + ), "", ) let response_text = join( - [request_text, " -> managed completed=", if managed_step.completed { "true" } else { "false" }, " published completed=", if published_step.completed { "true" } else { "false" }], + [request_text, " -> managed completed=", if managed_step.completed { "true" } else { "false" }, " published completed=", if published_step.completed { "true" } else { "false" }, " channel writes completed=", if channel_steps.completed { "true" } else { "false" }], "", ) BmcAccountDryStep { - world: published_step.world, + world: channel_steps.world, application: BmcAccountApplication { plan: plan, managed_write_completed: managed_step.completed, published_write_completed: published_step.completed, + channel_writes_completed: channel_steps.completed, request_receipt: dry_evidence(text: request_text), response_receipt: dry_evidence(text: response_text), applied_at: dry_bmc_account_instant(millis: applied_at_millis), diff --git a/dag/test/claim/machine_intake/machine_intake_arrival_converge_witness_test.dag b/dag/test/claim/machine_intake/machine_intake_arrival_converge_witness_test.dag index 72d7beca47b..2df668ae98f 100644 --- a/dag/test/claim/machine_intake/machine_intake_arrival_converge_witness_test.dag +++ b/dag/test/claim/machine_intake/machine_intake_arrival_converge_witness_test.dag @@ -20,8 +20,8 @@ import gunbc.machine_intake_mtjade1_access_observation { SmbiosBaseBoardDecode, SmbiosBaseBoardSerial, SmbiosBaseBoardRefused, SmbiosSerialLineCount, decode_smbios_type2_capture, sol_session_controller, ControllerClockRendered, ControllerClockUnread, read_mtjade1_current_manager_read, } import gunbc.machine_intake_bmc_rotation_route { - BmcRotationRouteStanding, RouteQualificationCandidate, RouteGroundedByExecutedRequest, RouteGroundedByCitedSource, RouteUngrounded, - RedfishAccountPasswordWrite, IpmiSetUserPassword, ObservedSurfaceRead, PublicStandardOperation, + BmcRotationRouteStanding, BmcAccountWriteRequest, RouteQualificationCandidate, RouteGroundedByExecutedRequest, RouteGroundedByCitedSource, RouteUngrounded, + RedfishAccountPasswordWrite, IpmiSetUserPassword, IpmiSetUserPrivilegeLimit, ObservedSurfaceRead, PublicStandardOperation, RotationApplyAdmitted, RotationApplyRouteNotGrounded, rotation_apply_authority, rotation_route_request_identity, rotation_route_is_grounded, admit_rotation_apply, } @@ -78,9 +78,9 @@ fn instance_step_is(s: StepInstanceStanding Bool { match route.grounding { RouteQualificationCandidate { request: r, evidence: e } => - (match r { RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => true IpmiSetUserPassword { user: _ } => false }) + (match r { RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => true IpmiSetUserPassword { user: _ } => false IpmiSetUserPrivilegeLimit { access: _ } => false }) && (match e { ObservedSurfaceRead { surface: _, receipt: rc } => (rc.label as String) == "artifacts/bmc/mtjade1-redfish-manager-self-192.168.1.246-2026-10-04T043605Z.json" PublicStandardOperation { authority: _ } => false }) - RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _ } => false + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => false RouteGroundedByCitedSource { request: _, citation: _ } => false RouteUngrounded => false } @@ -493,10 +493,19 @@ test fn w_a_refused_access_leaves_identity_bind_not_reached_blocked_by_it() -> B // SUPPLIED: an operator approval of the rotation that names this exact controller, build and request, // so the only thing left to refuse is the route. A Manager GET alone yields a candidate, and the // ordinary rotation Apply refuses it as not grounded. +fn route_request_of(s: BmcRotationRouteStanding) -> BmcAccountWriteRequest { + match s.grounding { + RouteQualificationCandidate { request: r, evidence: _ } => r + RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _, effect: _ } => r + RouteGroundedByCitedSource { request: r, citation: _ } => r + RouteUngrounded => IpmiSetUserPassword { user: 3 } + } +} + fn rotation_approval_for(s: BmcRotationRouteStanding) -> Redemption { let request = match s.grounding { RouteQualificationCandidate { request: r, evidence: _ } => r - RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _ } => r + RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _, effect: _ } => r RouteGroundedByCitedSource { request: r, citation: _ } => r RouteUngrounded => IpmiSetUserPassword { user: 3 } } @@ -523,7 +532,7 @@ test fn w_a_manager_get_alone_cannot_construct_an_account_write_route_at_the_cur Absent => false Present { value: a } => rotation_route_is_grounded(standing: a.route) == false - && match admit_rotation_apply(standing: a.route, target_endpoint: a.access.endpoint, target_firmware: a.access.firmware, approval: rotation_approval_for(s: a.route)) { + && match admit_rotation_apply(standing: a.route, target_endpoint: a.access.endpoint, target_firmware: a.access.firmware, request: route_request_of(s: a.route), managed_readback: none, approval: rotation_approval_for(s: a.route)) { RotationApplyRouteNotGrounded { standing: _ } => true _ => false } diff --git a/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_forged_probe_witness_test.dag b/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_forged_probe_witness_test.dag index 259cfa6ce0e..757a64a1adc 100644 --- a/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_forged_probe_witness_test.dag +++ b/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_forged_probe_witness_test.dag @@ -15,7 +15,7 @@ data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly // source to the compiler through the diagnostic-census harness and requires the refusal CLASS at each // SUBJECT by name, so a probe refusing for any other reason measures another wall; the class-scoped // control shows a clean source reading the same module through its real producer emits neither class. -data forged_probe_source: String = "module probe_rotation_route_forged\n\nimport std.types { Bool, NonEmptyStr }\nimport std.content_hash { content_hash_of_value }\nimport extdeps.uri { uri_https }\nimport extdeps.external_authority { ExternalAuthority }\nimport gunbc.machine_intake_receipt { EvidenceRef }\nimport gunbc.machine_intake_mtcollins1_access_observation { mtcollins1_endpoint, mtcollins1_firmware }\nimport gunbc.machine_intake_mtcollins1_bmc_secure_observation { mtcollins1_user3_route_evidence }\nimport gunbc.machine_intake_bmc_rotation_route {\n BmcRotationRouteStanding, RouteQualificationLiveResponse, ModeledRouteQualificationResponse, RouteQualificationSubject, IpmiSetUserPassword, RouteGroundedByExecutedRequest,\n rotation_route_from_committed_execution, rotation_route_from_citation,\n}\n\nfn forged_grounded_standing() -> BmcRotationRouteStanding {\n BmcRotationRouteStanding {\n endpoint: mtcollins1_endpoint,\n firmware: mtcollins1_firmware,\n grounding: RouteGroundedByExecutedRequest { request: IpmiSetUserPassword { user: 3 }, request_receipt: mtcollins1_user3_route_evidence, response_receipt: mtcollins1_user3_route_evidence },\n }\n}\n\nfn forged_subject() -> RouteQualificationSubject {\n RouteQualificationSubject { endpoint: mtcollins1_endpoint, firmware: mtcollins1_firmware, request: IpmiSetUserPassword { user: 3 } }\n}\n\nfn forged_modeled_response() -> ModeledRouteQualificationResponse {\n ModeledRouteQualificationResponse {\n subject: forged_subject(),\n request_receipt: mtcollins1_user3_route_evidence,\n response_receipt: mtcollins1_user3_route_evidence,\n completed: true,\n readback_accepted: true,\n }\n}\n\nfn forged_response() -> RouteQualificationLiveResponse {\n RouteQualificationLiveResponse {\n subject: forged_subject(),\n request_receipt: mtcollins1_user3_route_evidence,\n response_receipt: mtcollins1_user3_route_evidence,\n completed: true,\n readback_accepted: true,\n }\n}\n\nfn forged_committed_execution() -> BmcRotationRouteStanding {\n rotation_route_from_committed_execution(\n endpoint: mtcollins1_endpoint,\n firmware: mtcollins1_firmware,\n request: IpmiSetUserPassword { user: 3 },\n request_receipt: mtcollins1_user3_route_evidence,\n response_receipt: mtcollins1_user3_route_evidence,\n )\n}\n\nfn forged_citation() -> BmcRotationRouteStanding {\n rotation_route_from_citation(\n endpoint: mtcollins1_endpoint,\n firmware: mtcollins1_firmware,\n request: IpmiSetUserPassword { user: 3 },\n citation: ExternalAuthority { uri: uri_https(locator: \"example.invalid/forged\") },\n )\n}\n" +data forged_probe_source: String = "module probe_rotation_route_forged\n\nimport std.types { Bool, NonEmptyStr }\nimport std.content_hash { content_hash_of_value }\nimport extdeps.uri { uri_https }\nimport extdeps.external_authority { ExternalAuthority }\nimport gunbc.machine_intake_receipt { EvidenceRef }\nimport gunbc.machine_intake_mtcollins1_access_observation { mtcollins1_endpoint, mtcollins1_firmware }\nimport gunbc.machine_intake_mtcollins1_bmc_secure_observation { mtcollins1_user3_route_evidence }\nimport gunbc.machine_intake_bmc_rotation_route {\n BmcRotationRouteStanding, RouteQualificationLiveResponse, ModeledRouteQualificationResponse, RouteQualificationSubject, IpmiSetUserPassword, RouteGroundedByExecutedRequest, EffectObserved,\n rotation_route_from_committed_execution, rotation_route_from_citation, rotation_route_executed_fixture,\n ManagedAdministratorReadback, managed_administrator_readback_fixture, AdmittedRouteQualificationRequest,\n}\nimport std.scoped_authorization { AttemptIdentity }\n\nfn forged_grounded_standing() -> BmcRotationRouteStanding {\n BmcRotationRouteStanding {\n endpoint: mtcollins1_endpoint,\n firmware: mtcollins1_firmware,\n grounding: RouteGroundedByExecutedRequest { request: IpmiSetUserPassword { user: 3 }, request_receipt: mtcollins1_user3_route_evidence, response_receipt: mtcollins1_user3_route_evidence, effect: EffectObserved },\n }\n}\n\nfn forged_subject() -> RouteQualificationSubject {\n RouteQualificationSubject { endpoint: mtcollins1_endpoint, firmware: mtcollins1_firmware, request: IpmiSetUserPassword { user: 3 } }\n}\n\nfn forged_modeled_response() -> ModeledRouteQualificationResponse {\n ModeledRouteQualificationResponse {\n subject: forged_subject(),\n request_receipt: mtcollins1_user3_route_evidence,\n response_receipt: mtcollins1_user3_route_evidence,\n completed: true,\n readback_accepted: true,\n effect: EffectObserved,\n }\n}\n\nfn forged_response() -> RouteQualificationLiveResponse {\n RouteQualificationLiveResponse {\n subject: forged_subject(),\n request_receipt: mtcollins1_user3_route_evidence,\n response_receipt: mtcollins1_user3_route_evidence,\n completed: true,\n readback_accepted: true,\n effect: EffectObserved,\n }\n}\n\nfn forged_committed_execution() -> BmcRotationRouteStanding {\n rotation_route_from_committed_execution(\n endpoint: mtcollins1_endpoint,\n firmware: mtcollins1_firmware,\n request: IpmiSetUserPassword { user: 3 },\n request_receipt: mtcollins1_user3_route_evidence,\n response_receipt: mtcollins1_user3_route_evidence,\n effect: EffectObserved,\n )\n}\n\nfn forged_citation() -> BmcRotationRouteStanding {\n rotation_route_from_citation(\n endpoint: mtcollins1_endpoint,\n firmware: mtcollins1_firmware,\n request: IpmiSetUserPassword { user: 3 },\n citation: ExternalAuthority { uri: uri_https(locator: \"example.invalid/forged\") },\n )\n}\n\nfn forged_executed_fixture() -> BmcRotationRouteStanding {\n rotation_route_executed_fixture(endpoint: mtcollins1_endpoint, firmware: mtcollins1_firmware, request: IpmiSetUserPassword { user: 3 }, receipt: mtcollins1_user3_route_evidence, effect: EffectObserved)\n}\n\nfn forged_admitted_request() -> AdmittedRouteQualificationRequest {\n AdmittedRouteQualificationRequest { subject: forged_subject(), attempt: \"attempt-1\" as AttemptIdentity, decided_by: \"forger\" }\n}\n\nfn forged_readback() -> ManagedAdministratorReadback {\n ManagedAdministratorReadback { endpoint: mtcollins1_endpoint, firmware: mtcollins1_firmware, attempt: \"attempt-1\" as AttemptIdentity, managed_user: 3, access: [] }\n}\n\nfn forged_readback_through_the_fixture() -> ManagedAdministratorReadback {\n managed_administrator_readback_fixture(endpoint: mtcollins1_endpoint, firmware: mtcollins1_firmware, attempt: \"attempt-1\" as AttemptIdentity, managed_user: 3, access: [])\n}\n" data harness_control_source: String = "module probe_rotation_route_harness_control\nimport gunbc.machine_intake_bmc_rotation_route { BmcRotationRouteStanding }\nimport gunbc.machine_intake_bmc_rotation_route_evidence { mtcollins1_rotation_route_standing }\nfn standing() -> BmcRotationRouteStanding { mtcollins1_rotation_route_standing() }\n" @@ -54,6 +54,8 @@ test fn a_forged_route_standing_and_response_are_refused_at_their_literals() -> blocking_count_for_class_and_subject(c: c, wanted: "SoleConstructorViolation", subject: "BmcRotationRouteStanding") >= 1 && blocking_count_for_class_and_subject(c: c, wanted: "SoleConstructorViolation", subject: "RouteQualificationLiveResponse") >= 1 && blocking_count_for_class_and_subject(c: c, wanted: "SoleConstructorViolation", subject: "ModeledRouteQualificationResponse") >= 1 + && blocking_count_for_class_and_subject(c: c, wanted: "SoleConstructorViolation", subject: "ManagedAdministratorReadback") >= 1 + && blocking_count_for_class_and_subject(c: c, wanted: "SoleConstructorViolation", subject: "AdmittedRouteQualificationRequest") >= 1 } // The committed-execution and citation mints refuse a caller outside their admitted roots. @@ -61,4 +63,6 @@ test fn the_grounding_mints_refuse_an_outside_caller() -> Bool { let c = probe() blocking_count_for_class_and_subject(c: c, wanted: "ConstructorCallAdmissionRefused", subject: "rotation_route_from_committed_execution") >= 1 && blocking_count_for_class_and_subject(c: c, wanted: "ConstructorCallAdmissionRefused", subject: "rotation_route_from_citation") >= 1 + && blocking_count_for_class_and_subject(c: c, wanted: "ConstructorCallAdmissionRefused", subject: "managed_administrator_readback_fixture") >= 1 + && blocking_count_for_class_and_subject(c: c, wanted: "ConstructorCallAdmissionRefused", subject: "rotation_route_executed_fixture") >= 1 } diff --git a/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_witness_test.dag b/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_witness_test.dag index 985b177b43c..bafb24fd09d 100644 --- a/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_witness_test.dag +++ b/dag/test/claim/machine_intake/machine_intake_bmc_rotation_route_witness_test.dag @@ -1,6 +1,6 @@ module test.claim.machine_intake_bmc_rotation_route_witness_test -import std.types { Bool, NonEmptyStr, String, Timestamp } +import std.types { Bool, Int, List, NonEmptyStr, String, Timestamp } import std.decl_ref { decl_field_ref } import std.scoped_authorization { AttemptIdentity } import std.content_hash { content_hash_of_value } @@ -17,12 +17,14 @@ import gunbc.auth.approval_capability { ApprovalCapabilityClaims, ProposeApprove import gunbc.auth.approval_broker { Redemption, RedemptionAdmitted } import gunbc.auth.authorization_pattern_selection { OperatorApprovedCapability, PatternSelected, select_authorization_pattern } import gunbc.auth.privileged_effect_census { Conforms, privileged_effect_census, site_verdict } -import gunbc.bmc_model { BmcWorld, BmcIpmiUser, BmcPowerOn, bmc_world, bmc_with_ipmi_users, bmc_ipmi_user_accepts } +import gunbc.bmc_model { BmcWorld, BmcIpmiUser, BmcPowerOn, bmc_world, bmc_with_ipmi_users, bmc_ipmi_user_accepts, bmc_ipmi_get_user_access, bmc_ipmi_set_user_access } +import extdeps.bmc.ipmi_channel { IpmiChannelPrivilegeLimit, IpmiPrivilegeNoAccess, IpmiPrivilegeAdministrator, IpmiPrivilegeOperator, IpmiPrivilegeUser, IpmiUserChannelAccess, ipmi_user_channel_access } import gunbc.machine_intake_mtcollins1_access_observation { mtcollins1_endpoint, mtcollins1_firmware } import gunbc.machine_intake_mtcollins1_bmc_secure_observation { mtcollins1_user3_route_digest } import gunbc.machine_intake_mtjade1_access_observation { read_mtjade1_recorded_manager_identity } import gunbc.machine_intake_bmc_rotation_route { - BmcRotationRouteStanding, BmcAccountWriteRequest, IpmiSetUserPassword, RedfishAccountPasswordWrite, + RouteQualificationRequestAdmission, + BmcRotationRouteStanding, BmcAccountWriteRequest, IpmiSetUserPassword, IpmiSetUserPrivilegeLimit, RedfishAccountPasswordWrite, ObservedSurfaceRead, PublicStandardOperation, RouteGroundedByExecutedRequest, RouteGroundedByCitedSource, RouteQualificationCandidate, RouteUngrounded, RouteQualified, RouteQualificationRefused, RouteQualificationSubject, HistoricalRotationRouteObservation, @@ -32,8 +34,13 @@ import gunbc.machine_intake_bmc_rotation_route { QualificationResponseForAnotherSubject, QualificationRequestUnrealized, QualificationRequestNotCompleted, QualificationReadbackRefused, RotationApplyAdmitted, RotationApplyRouteNotGrounded, RotationApplyRouteForAnotherController, - RotationApplyRouteForAnotherBuild, RotationApplyApprovalRefused, RotationApplyApprovalDenied, - RotationApplyApprovalForAnotherAuthority, RotationApplyApprovalForAnotherRequest, + RotationApplyRouteForAnotherBuild, RotationApplyRouteForAnotherOperation, RotationApplyRouteEffectUnobserved, RotationApplyApprovalRefused, + EffectObserved, AcceptedEffectUnobserved, RouteEffectStanding, rotation_route_executed_fixture, RotationApplyApprovalDenied, + RotationApplyApprovalForAnotherAuthority, RotationApplyApprovalForAnotherRequest, RotationApplyWouldLeaveNoAdministrator, + ManagedAdministratorReadback, managed_administrator_readback_fixture, ManagedReadbackAbsent, ManagedReadbackFromAnotherController, ManagedReadbackFromAnotherBuild, ManagedReadbackFromAnotherRun, ManagedAccountIsTheClosedAccount, ManagedAccountNotAdministratorOnChannel, ManagedReadbackDuplicateRow, QualificationTargetIsNotTheManagedAccount, + RouteQualificationRequestAdmitted, RouteQualificationRequestRefused, QualificationRequestForAnotherOperation, + QualificationRequestRefusedByClassifier, QualificationRequestWouldLeaveNoAdministrator, + admit_password_route_qualification, admit_privilege_limit_route_qualification, route_qualification_authority, rotation_apply_authority, rotation_route_ungrounded, rotation_route_candidate, rotation_route_from_citation, rotation_route_request_identity, rotation_route_is_grounded, @@ -41,7 +48,7 @@ import gunbc.machine_intake_bmc_rotation_route { account_write_request_eq, redfish_account_password_write, } import gunbc.machine_intake_bmc_rotation_route_evidence { - mtcollins1_rotation_route_standing, mtjade1_historical_rotation_route_observation, historical_route_observation_from_manager_read, + mtcollins1_rotation_route_standing, mtcollins1_channel_access_route_standing, mtjade1_historical_rotation_route_observation, historical_route_observation_from_manager_read, } data live_tree_disposition: LiveTreeDisposition = ReadsLiveTree @@ -71,7 +78,7 @@ fn approval(authority: NonEmptyStr, revision: NonEmptyStr) -> Redemption { fn standing_request(s: BmcRotationRouteStanding) -> BmcAccountWriteRequest { match s.grounding { - RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _ } => r + RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _, effect: _ } => r RouteGroundedByCitedSource { request: r, citation: _ } => r RouteQualificationCandidate { request: r, evidence: _ } => r RouteUngrounded => IpmiSetUserPassword { user: 3 } @@ -140,7 +147,7 @@ fn refusal_name(c: RouteQualificationRefusal) -> String { // The modeled verdict for a candidate, an approval and a modeled run against `answered`. fn modeled_verdict(candidate: BmcRotationRouteStanding, approval_value: Redemption, world: BmcWorld, answered: RouteQualificationSubject) -> String { match classify_modeled_route_qualification(standing: candidate, approval: approval_value, response: dry_route_qualification_request(world: world, subject: answered, password: "new-Secret!1").response) { - ModeledQualificationWouldQualify { subject: _, request_receipt: _, response_receipt: _ } => "would-qualify" + ModeledQualificationWouldQualify { subject: _, request_receipt: _, response_receipt: _, effect: _ } => "would-qualify" ModeledQualificationRefused { cause: c } => refusal_name(c: c) } } @@ -150,21 +157,28 @@ fn refusal_of(world: BmcWorld, request: BmcAccountWriteRequest, approval_value: } fn apply_verdict(standing: BmcRotationRouteStanding, target: BmcControllerEndpoint, firmware: BmcFirmwareReleaseIdentity, approval_value: Redemption) -> String { - match admit_rotation_apply(standing: standing, target_endpoint: target, target_firmware: firmware, approval: approval_value) { + apply_verdict_for(standing: standing, target: target, firmware: firmware, request: standing_request(s: standing), approval_value: approval_value) +} + +fn apply_verdict_for(standing: BmcRotationRouteStanding, target: BmcControllerEndpoint, firmware: BmcFirmwareReleaseIdentity, request: BmcAccountWriteRequest, approval_value: Redemption) -> String { + match admit_rotation_apply(standing: standing, target_endpoint: target, target_firmware: firmware, request: request, managed_readback: none, approval: approval_value) { RotationApplyAdmitted { standing: _, request: _, decided_by: _ } => "admitted" RotationApplyRouteNotGrounded { standing: _ } => "route-not-grounded" RotationApplyRouteForAnotherController { route_endpoint: _, target_endpoint: _ } => "another-controller" RotationApplyRouteForAnotherBuild { route_firmware: _, target_firmware: _ } => "another-build" + RotationApplyRouteForAnotherOperation { grounded: _, requested: _ } => "another-operation" + RotationApplyRouteEffectUnobserved { standing: _ } => "effect-unobserved" RotationApplyApprovalRefused { cause: _ } => "approval-refused" RotationApplyApprovalDenied => "approval-denied" RotationApplyApprovalForAnotherAuthority { authority: _ } => "another-authority" RotationApplyApprovalForAnotherRequest { approved: _, requested: _ } => "another-request" + RotationApplyWouldLeaveNoAdministrator { channel: _, cause: _ } => "would-leave-no-administrator" } } fn grounding_kind(standing: BmcRotationRouteStanding) -> String { match standing.grounding { - RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _ } => "executed" + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => "executed" RouteGroundedByCitedSource { request: _, citation: _ } => "cited" RouteQualificationCandidate { request: _, evidence: _ } => "candidate" RouteUngrounded => "ungrounded" @@ -186,9 +200,10 @@ test fn mtcollins1_is_grounded_by_its_executed_ipmi_request() -> Bool { (s.endpoint.host as String) == "192.168.1.228" && (s.firmware.raw_version as String) == "0.32" && match s.grounding { - RouteGroundedByExecutedRequest { request: r, request_receipt: q, response_receipt: p } => + RouteGroundedByExecutedRequest { request: r, request_receipt: q, response_receipt: p, effect: _ } => match r { IpmiSetUserPassword { user: u } => (u as Int) == 3 + IpmiSetUserPrivilegeLimit { access: _ } => false RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => false } && q.digest == mtcollins1_user3_route_digest @@ -335,7 +350,7 @@ test fn requests_differing_only_in_transport_or_action_shape_are_different_reque fn classify_names(candidate: BmcRotationRouteStanding, approval_value: Redemption) -> String { match classify_modeled_route_qualification(standing: candidate, approval: approval_value, response: none) { - ModeledQualificationWouldQualify { subject: _, request_receipt: _, response_receipt: _ } => "would-qualify" + ModeledQualificationWouldQualify { subject: _, request_receipt: _, response_receipt: _, effect: _ } => "would-qualify" ModeledQualificationRefused { cause: c } => refusal_name(c: c) } } @@ -372,7 +387,7 @@ test fn a_cited_route_admits_apply_and_is_bound_to_its_build() -> Bool { // over its stated characteristics: the selection returns the operator-approved capability, and the // row's realization (an admitted Redemption) conforms to it. test fn the_qualification_effect_is_classified_operator_approved_and_conforms() -> Bool { - let rows = filter(privileged_effect_census, r => (r.site.module_path as String) == "gunbc.machine_intake_bmc_rotation_route" && (r.site.decl_name as String) == "qualify_rotation_route") + let rows = filter(privileged_effect_census, r => (r.site.module_path as String) == "gunbc.machine_intake_bmc_rotation_route" && (r.site.decl_name as String) == "admit_password_route_qualification") length(rows) == 1 && all(rows, r => match select_authorization_pattern(e: r.effect) { @@ -414,3 +429,270 @@ test fn a_rotation_approval_for_one_controller_does_not_admit_another() -> Bool && apply_verdict(standing: lab, target: lab_endpoint, firmware: lab_firmware(), approval_value: rotation_approval_for(s: lab)) == "admitted" && apply_verdict(standing: lab, target: lab_endpoint, firmware: lab_firmware(), approval_value: denied) == "approval-denied" } + +// ── cut O1a-2: the channel-access request shape ───────────────────────────────────────────────── + +fn access_write(user: Int, channel: Int, privilege: IpmiChannelPrivilegeLimit) -> BmcAccountWriteRequest { + IpmiSetUserPrivilegeLimit { access: ipmi_user_channel_access(channel: channel, user: user, privilege: privilege) } +} + +// EVERY FIELD IS IN THE IDENTITY. Set User Access requests differing ONLY in the channel, ONLY in the +// privilege limit, or ONLY in the user are different requests: unequal, and an approval for the base +// request refuses each as another request. +test fn channel_access_requests_differing_in_any_one_field_are_different_requests() -> Bool { + let base = access_write(user: 2, channel: 2, privilege: IpmiPrivilegeNoAccess) + let other_channel = access_write(user: 2, channel: 3, privilege: IpmiPrivilegeNoAccess) + let other_privilege = access_write(user: 2, channel: 2, privilege: IpmiPrivilegeUser) + let other_user = access_write(user: 4, channel: 2, privilege: IpmiPrivilegeNoAccess) + let c_channel = lab_candidate(request: other_channel) + let c_privilege = lab_candidate(request: other_privilege) + let c_user = lab_candidate(request: other_user) + account_write_request_eq(a: base, b: base) + && !account_write_request_eq(a: base, b: other_channel) + && !account_write_request_eq(a: base, b: other_privilege) + && !account_write_request_eq(a: base, b: other_user) + && classify_names(candidate: c_channel, approval_value: qualification_approval_for(standing: c_channel, request: base)) == "another-request" + && classify_names(candidate: c_privilege, approval_value: qualification_approval_for(standing: c_privilege, request: base)) == "another-request" + && classify_names(candidate: c_user, approval_value: qualification_approval_for(standing: c_user, request: base)) == "another-request" +} + +// mtcollins1's channel-access route is a candidate on its CURRENT controller and build (0.45.3, not +// the 0.32 its password route was executed on), naming the NON-DESTRUCTIVE qualifying request (the +// managed account, user 3, re-asserted at ADMINISTRATOR on channel 1), with the public standard as its +// only evidence. It is not grounded, and an Apply refuses it. +test fn mtcollins1_channel_access_route_is_an_ungrounded_candidate_on_its_current_build() -> Bool { + let s = mtcollins1_channel_access_route_standing() + (s.endpoint.host as String) == "192.168.1.228" + && (s.firmware.raw_version as String) == "0.45.3" + && !rotation_route_is_grounded(standing: s) + && match s.grounding { + RouteQualificationCandidate { request: r, evidence: e } => + account_write_request_eq(a: r, b: access_write(user: 3, channel: 1, privilege: IpmiPrivilegeAdministrator)) + && match e { PublicStandardOperation { authority: _ } => true ObservedSurfaceRead { surface: _, receipt: _ } => false } + RouteGroundedByExecutedRequest { request: _, request_receipt: _, response_receipt: _, effect: _ } => false + RouteGroundedByCitedSource { request: _, citation: _ } => false + RouteUngrounded => false + } + && apply_verdict(standing: s, target: s.endpoint, firmware: s.firmware, approval_value: rotation_approval_for(s: s)) == "route-not-grounded" +} + +// THE MODELED CHANNEL-ACCESS RUN: the Set User Access transition sets exactly that (channel, user) +// row, Get User Access reads it back, and the classifier says it would qualify -- with no standing. +// A user the IPMI table does not hold is not completed. +test fn a_modeled_channel_access_run_would_qualify_but_grounds_nothing() -> Bool { + let request = access_write(user: 3, channel: 2, privilege: IpmiPrivilegeNoAccess) + let candidate = lab_candidate(request: request) + let step = dry_route_qualification_request(world: lab_world_with_user3(), subject: subject_at(endpoint: lab_endpoint, request: request), password: "unused") + match bmc_ipmi_get_user_access(world: step.world, user: 3, channel: 2) { + Present { value: p } => match p { IpmiPrivilegeNoAccess => true _ => false } + Absent => false + } + && match bmc_ipmi_get_user_access(world: step.world, user: 3, channel: 3) { Absent => true Present { value: _ } => false } + && modeled_verdict(candidate: candidate, approval_value: qualification_approval_for(standing: candidate, request: request), world: lab_world_with_user3(), answered: subject_at(endpoint: lab_endpoint, request: request)) == "would-qualify" + && grounding_kind(standing: candidate) == "candidate" + && refusal_of(world: lab_world_with_user3(), request: access_write(user: 9, channel: 2, privilege: IpmiPrivilegeNoAccess), approval_value: qualification_approval_for(standing: lab_candidate(request: access_write(user: 9, channel: 2, privilege: IpmiPrivilegeNoAccess)), request: access_write(user: 9, channel: 2, privilege: IpmiPrivilegeNoAccess))) == "not-completed" +} + +// A GROUNDED ROUTE FOR ONE OPERATION DOES NOT ADMIT ANOTHER. mtcollins1's grounded Set User Password +// route, on its own controller and build, with an exact approval of a Set User Access write, refuses +// as another operation; the same route with an exact approval of a password write is admitted. +test fn a_grounded_password_route_does_not_admit_a_channel_access_apply() -> Bool { + let collins = mtcollins1_rotation_route_standing() + let access = access_write(user: 2, channel: 2, privilege: IpmiPrivilegeNoAccess) + apply_verdict_for(standing: collins, target: mtcollins1_endpoint, firmware: mtcollins1_firmware, request: access, approval_value: approval(authority: rotation_apply_authority, revision: rotation_route_request_identity(standing: collins, request: access))) == "another-operation" + && apply_verdict_for(standing: collins, target: mtcollins1_endpoint, firmware: mtcollins1_firmware, request: IpmiSetUserPassword { user: 3 }, approval_value: approval(authority: rotation_apply_authority, revision: rotation_route_request_identity(standing: collins, request: IpmiSetUserPassword { user: 3 }))) == "admitted" +} + +// The census row for qualifying the channel-access shape, classified by EXECUTING the selection over +// its own characteristics (not the password row's): the selection returns the operator-approved +// capability and the row's realization conforms. +test fn the_channel_access_qualification_effect_is_classified_by_executing_the_selection() -> Bool { + let rows = filter(privileged_effect_census, r => (r.site.module_path as String) == "gunbc.machine_intake_bmc_rotation_route" && (r.site.decl_name as String) == "admit_privilege_limit_route_qualification") + length(rows) == 1 + && all(rows, r => + match select_authorization_pattern(e: r.effect) { + PatternSelected { pattern: p, receipt: _ } => match p { OperatorApprovedCapability => true _ => false } + _ => false + } + && match site_verdict(row: r).conformance { Conforms => true _ => false }) +} + +// THE LOCKOUT HAZARD IS UNPLANNABLE. On a grounded channel-access route (a cited one, the grounded +// arm a witness may construct), closing user 2 on channel 2 with an exact approval of that write: +// with no managed readback -> refused; with the managed account (user 3) read back at ADMINISTRATOR on +// channel 2 in the approval's own attempt -> admitted; the same readback from another run, a readback +// whose managed account IS the closed one, and a managed account at ADMINISTRATOR only on another +// channel -> each refused with its own typed cause. +fn lockout_verdict(readback: ManagedAdministratorReadback?) -> String { + let request = access_write(user: 2, channel: 2, privilege: IpmiPrivilegeNoAccess) + let route = rotation_route_from_citation( + endpoint: lab_endpoint, + firmware: lab_firmware(), + request: access_write(user: 2, channel: 3, privilege: IpmiPrivilegeNoAccess), + citation: ExternalAuthority { uri: uri_https(locator: "example.invalid/route-witness-citation" as NonEmptyStr) }, + ) + match admit_rotation_apply( + standing: route, + target_endpoint: lab_endpoint, + target_firmware: lab_firmware(), + request: request, + managed_readback: readback, + approval: approval(authority: rotation_apply_authority, revision: rotation_route_request_identity(standing: route, request: request)), + ) { + RotationApplyAdmitted { standing: _, request: _, decided_by: _ } => "admitted" + RotationApplyWouldLeaveNoAdministrator { channel: ch, cause: c } => + if (ch as Int) != 2 { "wrong-channel" } else { + match c { + ManagedReadbackAbsent => "readback-absent" + ManagedReadbackFromAnotherController { readback: _, route: _ } => "another-controller" + ManagedReadbackFromAnotherBuild { readback: _, route: _ } => "another-build" + ManagedReadbackFromAnotherRun { readback: _, approved: _ } => "another-run" + ManagedAccountIsTheClosedAccount { user: _ } => "managed-is-closed" + ManagedAccountNotAdministratorOnChannel { managed_user: _ } => "not-administrator-on-channel" + ManagedReadbackDuplicateRow { managed_user: _, count: _ } => "duplicate-row" + QualificationTargetIsNotTheManagedAccount { target: _, managed_user: _ } => "target-not-managed" + } + } + _ => "other-refusal" + } +} + +// Every readback below is minted by managed_administrator_readback_fixture IN THE CLAIM THAT CONSUMES IT: +// the fixture admits exactly those claims, and no function here returns a readback or a standing. +test fn a_channel_access_write_that_could_lock_out_every_administrator_is_unplannable() -> Bool { + let admin_on_2 = [ipmi_user_channel_access(channel: 2, user: 3, privilege: IpmiPrivilegeAdministrator)] + let admin_on_1 = [ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeAdministrator)] + lockout_verdict(readback: none) == "readback-absent" + && lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_2) }) == "admitted" + && lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-0" as AttemptIdentity, managed_user: 3, access: admin_on_2) }) == "another-run" + && lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 2, access: [ipmi_user_channel_access(channel: 2, user: 2, privilege: IpmiPrivilegeAdministrator)]) }) == "managed-is-closed" + && lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_1) }) == "not-administrator-on-channel" +} + +// A READBACK FROM CONTROLLER A CANNOT UNLOCK A CLOSE ON CONTROLLER B, nor one from another build of the +// same controller: the same readback that admits the close on its own controller and build refuses on +// the route's controller B and on build 0.33. +test fn a_readback_from_another_controller_or_build_does_not_unlock_a_close() -> Bool { + let admin_on_2 = [ipmi_user_channel_access(channel: 2, user: 3, privilege: IpmiPrivilegeAdministrator)] + lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint_b, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_2) }) == "another-controller" + && lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: bmc_firmware_release_identity_of_wire(family: AmiMegaRac, wire: "0.33" as NonEmptyStr), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_2) }) == "another-build" + && lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_2) }) == "admitted" +} + +// A DUPLICATE (channel, user) RESULT REFUSES: an ADMINISTRATOR row beside a contradictory NO ACCESS row +// for the same managed user and channel is not a unique reading. +test fn a_duplicated_managed_readback_row_refuses() -> Bool { + lockout_verdict(readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: [ + ipmi_user_channel_access(channel: 2, user: 3, privilege: IpmiPrivilegeAdministrator), + ipmi_user_channel_access(channel: 2, user: 3, privilege: IpmiPrivilegeNoAccess), + ]) }) == "duplicate-row" +} + +// ── THE PRE-WRITE QUALIFICATION ADMISSION (side-chat review of 7887d74ed2, item 1) ────────────────── + +fn prewrite_verdict(a: RouteQualificationRequestAdmission) -> String { + match a { + RouteQualificationRequestAdmitted { request: _ } => "admitted" + RouteQualificationRequestRefused { cause: c } => + match c { + QualificationRequestForAnotherOperation { candidate: _ } => "another-operation" + QualificationRequestRefusedByClassifier { cause: k } => refusal_name(c: k) + QualificationRequestWouldLeaveNoAdministrator { cause: k } => + match k { + ManagedReadbackAbsent => "readback-absent" + ManagedReadbackFromAnotherController { readback: _, route: _ } => "another-controller" + QualificationTargetIsNotTheManagedAccount { target: _, managed_user: _ } => "target-not-managed" + ManagedAccountNotAdministratorOnChannel { managed_user: _ } => "not-administrator-on-channel" + _ => "retention-refused" + } + } + } +} + +// THE MTCOLLINS1 CANDIDATE CANNOT REACH A TRANSPORT CALL WITHOUT A CURRENT RECEIPT. With its exact +// qualification approval and no managed-administrator readback, the privilege-limit entrypoint refuses +// before any write: no AdmittedRouteQualificationRequest exists, and that sealed value is the only input +// the live transport is permitted. The password entrypoint refuses the candidate as another operation. +test fn the_mtcollins1_channel_access_candidate_cannot_issue_a_request_without_a_current_receipt() -> Bool { + let s = mtcollins1_channel_access_route_standing() + let exact = qualification_approval_for(standing: s, request: standing_request(s: s)) + prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: s, approval: exact, readback: none)) == "readback-absent" + && prewrite_verdict(a: admit_password_route_qualification(standing: s, approval: exact)) == "another-operation" +} + +// THE POSITIVE, ON A LAB CANDIDATE WITH THE NON-DESTRUCTIVE SHAPE: re-asserting the managed account's +// ADMINISTRATOR limit on channel 1, with the exact approval and a same-run readback showing it already +// ADMINISTRATOR there, is admitted; the same with a readback from another controller refuses; and a +// rotation approval refuses at the classifier. +test fn the_prewrite_admission_admits_only_with_the_same_run_receipt() -> Bool { + let request = access_write(user: 3, channel: 1, privilege: IpmiPrivilegeAdministrator) + let c = lab_candidate(request: request) + let exact = qualification_approval_for(standing: c, request: request) + let admin_on_1 = [ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeAdministrator)] + prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: c, approval: exact, readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_1) })) == "admitted" + && prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: c, approval: exact, readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint_b, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_1) })) == "another-controller" + && prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: c, approval: rotation_approval_for(s: c), readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: admin_on_1) })) == "another-authority" +} + +// ── WHAT A QUALIFICATION GROUNDS: acceptance, and effect only when the run could tell ─────────────── + +fn modeled_effect(candidate: BmcRotationRouteStanding, world: BmcWorld, request: BmcAccountWriteRequest) -> String { + match classify_modeled_route_qualification(standing: candidate, approval: qualification_approval_for(standing: candidate, request: request), response: dry_route_qualification_request(world: world, subject: subject_at(endpoint: lab_endpoint, request: request), password: "unused").response) { + ModeledQualificationWouldQualify { subject: _, request_receipt: _, response_receipt: _, effect: e } => match e { EffectObserved => "observed" AcceptedEffectUnobserved => "accepted-only" } + ModeledQualificationRefused { cause: _ } => "refused" + } +} + +fn world_with_user3_admin_on_1() -> BmcWorld { + bmc_ipmi_set_user_access(world: lab_world_with_user3(), access: ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeAdministrator)).world +} + +// THE IDEMPOTENT QUALIFYING REQUEST GROUNDS ACCEPTANCE ONLY. Re-asserting a value already present reads +// back identically whether applied or ignored: the modeled run reports accepted-only. The same request +// against a world where the value differed beforehand reports the effect observed. +test fn an_idempotent_qualifying_write_grounds_acceptance_only() -> Bool { + let request = access_write(user: 3, channel: 1, privilege: IpmiPrivilegeAdministrator) + let c = lab_candidate(request: request) + modeled_effect(candidate: c, world: world_with_user3_admin_on_1(), request: request) == "accepted-only" + && modeled_effect(candidate: c, world: lab_world_with_user3(), request: request) == "observed" +} + +// AN ACCEPT-ONLY GROUNDING DOES NOT ADMIT THE CLOSING WRITE. A grounded privilege-limit route whose +// effect was unobserved, with an exact approval of closing user 2 on channel 2 and a valid same-run +// managed-administrator readback, refuses as effect-unobserved; the same with EffectObserved is admitted. +fn closing_verdict(route: BmcRotationRouteStanding, readback: ManagedAdministratorReadback?) -> String { + let close = access_write(user: 2, channel: 2, privilege: IpmiPrivilegeNoAccess) + match admit_rotation_apply( + standing: route, + target_endpoint: lab_endpoint, + target_firmware: lab_firmware(), + request: close, + managed_readback: readback, + approval: approval(authority: rotation_apply_authority, revision: rotation_route_request_identity(standing: route, request: close)), + ) { + RotationApplyAdmitted { standing: _, request: _, decided_by: _ } => "admitted" + RotationApplyRouteEffectUnobserved { standing: _ } => "effect-unobserved" + _ => "other-refusal" + } +} + +test fn an_accept_only_grounding_does_not_admit_the_closing_write() -> Bool { + let qualifying = access_write(user: 3, channel: 1, privilege: IpmiPrivilegeAdministrator) + let readback = Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: [ipmi_user_channel_access(channel: 2, user: 3, privilege: IpmiPrivilegeAdministrator)]) } + closing_verdict(route: rotation_route_executed_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), request: qualifying, receipt: lab_surface_receipt, effect: AcceptedEffectUnobserved), readback: readback) == "effect-unobserved" + && closing_verdict(route: rotation_route_executed_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), request: qualifying, receipt: lab_surface_receipt, effect: EffectObserved), readback: readback) == "admitted" +} + +// THE NON-DESTRUCTIVE QUALIFICATION RE-ASSERTS THE MANAGED ACCOUNT'S OWN CURRENT VALUE (side-chat review +// of 6d277411fd, item 2). For the target (user 3, channel 1, ADMINISTRATOR): a receipt for managed user 4 +// -- ADMINISTRATOR on channel 1, and even carrying an ADMINISTRATOR row for user 3 -- issues no request, +// refused only because the target is not the managed account; a receipt for user 3 whose channel-1 row +// is OPERATOR issues none; user 3's exact current ADMINISTRATOR reading is admitted. +test fn the_idempotent_qualification_requires_the_target_pair_to_already_hold_the_value() -> Bool { + let request = access_write(user: 3, channel: 1, privilege: IpmiPrivilegeAdministrator) + let c = lab_candidate(request: request) + let exact = qualification_approval_for(standing: c, request: request) + prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: c, approval: exact, readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 4, access: [ipmi_user_channel_access(channel: 1, user: 4, privilege: IpmiPrivilegeAdministrator), ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeAdministrator)]) })) == "target-not-managed" + && prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: c, approval: exact, readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: [ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeOperator)]) })) == "not-administrator-on-channel" + && prewrite_verdict(a: admit_privilege_limit_route_qualification(standing: c, approval: exact, readback: Present { value: managed_administrator_readback_fixture(endpoint: lab_endpoint, firmware: lab_firmware(), attempt: "attempt-1" as AttemptIdentity, managed_user: 3, access: [ipmi_user_channel_access(channel: 1, user: 3, privilege: IpmiPrivilegeAdministrator)]) })) == "admitted" +} diff --git a/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_forged_probe_witness_test.dag b/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_forged_probe_witness_test.dag index fc9d11613a4..591fb8b14ff 100644 --- a/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_forged_probe_witness_test.dag +++ b/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_forged_probe_witness_test.dag @@ -17,7 +17,7 @@ data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly // diagnostic-census harness and requires each refusal CLASS at its SUBJECT by name, so a probe refusing // for another reason measures another wall; the class-scoped control shows a clean source reading the // same modules emits none of them. -data forged_probe_source: String = "module probe_bmc_secure_state_forged\n\nimport std.types { Bool, EpochMs, NonEmptyStr, String }\nimport std.content_hash { content_hash_of_value }\nimport gunbc.clock_read { ObserverClockInstant, ObserverClockModeled, observer_clock_modeled }\nimport gunbc.machine_intake_receipt { EvidenceRef }\nimport gunbc.machine_intake_bmc_rotation_route { BmcRotationRouteStanding }\nimport test.claim.machine_intake_bmc_secure_state_witness { cited_lab_route_managed_user }\nimport gunbc.machine_intake_subject { MachineIntakeSubject }\nimport extdeps.bmc.endpoint { BmcControllerEndpoint }\nimport extdeps.bmc.capability { BmcFirmwareReleaseIdentity }\nimport extdeps.bmc.ipmi_channel { IpmiControllerChannelCensus }\nimport gunbc.machine_intake_bmc_secure {\n ControllerClockReading, ObservedCredentialProbe, ObservedCredentialAccepted,\n ManagedCredentialGenerationStored, ManagedCredentialGenerationFetched, BmcAccountActionPlan,\n BmcAccountApplication, BmcSecurePhaseReceipt, BmcAccountStateObservation,\n ManagedCredentialReference, ObservedPublishedAccount, observed_bmc_account_state,\n ObservedReading, PublishedAccountKind,\n}\n\nfn evidence() -> EvidenceRef {\n EvidenceRef { label: \"forged\", digest: content_hash_of_value(value: \"forged\" as NonEmptyStr) }\n}\n\nfn forged_instant() -> ObserverClockInstant {\n ObserverClockInstant { millis: 946684800000, source: ObserverClockModeled { realization: \"forged\" } }\n}\n\nfn forged_modeled_instant() -> ObserverClockInstant {\n observer_clock_modeled(millis: 946684800000, realization: \"forged\" as NonEmptyStr)\n}\n\nfn controller_time_as_read_floor(\n subject: MachineIntakeSubject,\n endpoint: BmcControllerEndpoint,\n firmware: BmcFirmwareReleaseIdentity,\n managed: ManagedCredentialReference,\n reading: ControllerClockReading,\n probe: ObservedCredentialProbe,\n census: IpmiControllerChannelCensus,\n instant: ObserverClockInstant,\n account: ObservedPublishedAccount,\n) -> BmcAccountStateObservation {\n observed_bmc_account_state(\n subject: subject,\n endpoint: endpoint,\n firmware: firmware,\n managed: managed,\n read_floor: reading,\n managed_probe: probe,\n channel_census: census,\n census_evidence: evidence(),\n census_observed_at: instant,\n published_probes: [],\n published_user: 2,\n published_account: account,\n break_glass: managed,\n break_glass_probe: probe,\n controller_clock: none,\n )\n}\n\nfn forged_stored(s: ManagedCredentialGenerationStored) -> ManagedCredentialGenerationStored {\n ManagedCredentialGenerationStored { reference: s.reference, stored_version: s.stored_version, stored_at: s.stored_at }\n}\n\nfn forged_fetched(s: ManagedCredentialGenerationStored) -> ManagedCredentialGenerationFetched {\n ManagedCredentialGenerationFetched { stored: s, fetched_at: s.stored_at }\n}\n\nfn forged_application(p: BmcAccountActionPlan) -> BmcAccountApplication {\n BmcAccountApplication {\n plan: p,\n managed_write_completed: true,\n published_write_completed: true,\n request_receipt: evidence(),\n response_receipt: evidence(),\n applied_at: p.planned_at,\n }\n}\n\nfn forged_receipt(r: BmcSecurePhaseReceipt) -> BmcSecurePhaseReceipt {\n BmcSecurePhaseReceipt { subject: r.subject, phase: r.phase, goal: r.goal, decision: r.decision, held: r.held }\n}\n\nfn forged_plan(p: BmcAccountActionPlan) -> BmcAccountActionPlan {\n BmcAccountActionPlan {\n subject: p.subject,\n endpoint: p.endpoint,\n firmware: p.firmware,\n goal: p.goal,\n diverged: p.diverged,\n due: p.due,\n managed_write: p.managed_write,\n published_write: p.published_write,\n planned_at: p.planned_at,\n }\n}\n\nfn forged_observation(o: BmcAccountStateObservation) -> BmcAccountStateObservation {\n BmcAccountStateObservation {\n subject: o.subject,\n endpoint: o.endpoint,\n managed: o.managed,\n read_floor: o.read_floor,\n managed_probe: o.managed_probe,\n channel_census: o.channel_census,\n census_evidence: o.census_evidence,\n census_observed_at: o.census_observed_at,\n published_probes: o.published_probes,\n published_user: o.published_user,\n published_account: o.published_account,\n controller_clock: o.controller_clock,\n }\n}\n\nfn controller_time_in_a_reading_field(reading: ControllerClockReading) -> ObservedReading {\n ObservedReading { evidence: evidence(), observed_at: reading }\n}\n\nfn controller_time_in_an_account_field(kind: PublishedAccountKind, reading: ControllerClockReading) -> ObservedPublishedAccount {\n ObservedPublishedAccount { kind: kind, evidence: evidence(), observed_at: reading }\n}\n\nfn borrowed_fixture_route() -> BmcRotationRouteStanding {\n cited_lab_route_managed_user()\n}\n" +data forged_probe_source: String = "module probe_bmc_secure_state_forged\n\nimport std.types { Bool, EpochMs, NonEmptyStr, String }\nimport std.content_hash { content_hash_of_value }\nimport gunbc.clock_read { ObserverClockInstant, ObserverClockModeled, observer_clock_modeled }\nimport gunbc.machine_intake_receipt { EvidenceRef }\nimport gunbc.machine_intake_bmc_rotation_route { BmcRotationRouteStanding }\nimport test.claim.machine_intake_bmc_secure_state_witness { cited_lab_route_managed_user }\nimport gunbc.machine_intake_subject { MachineIntakeSubject }\nimport extdeps.bmc.endpoint { BmcControllerEndpoint }\nimport extdeps.bmc.capability { BmcFirmwareReleaseIdentity }\nimport extdeps.bmc.ipmi_channel { IpmiControllerChannelCensus }\nimport gunbc.machine_intake_bmc_secure {\n ControllerClockReading, ObservedCredentialProbe, ObservedCredentialAccepted,\n ManagedCredentialGenerationStored, ManagedCredentialGenerationFetched, BmcAccountActionPlan,\n BmcAccountApplication, BmcSecurePhaseReceipt, BmcAccountStateObservation,\n ManagedCredentialReference, ObservedPublishedAccount, observed_bmc_account_state,\n ObservedReading, PublishedAccountKind, project_managed_administrator_readback,\n}\nimport std.scoped_authorization { AttemptIdentity }\nimport gunbc.machine_intake_bmc_rotation_route { ManagedAdministratorReadback }\n\nfn evidence() -> EvidenceRef {\n EvidenceRef { label: \"forged\", digest: content_hash_of_value(value: \"forged\" as NonEmptyStr) }\n}\n\nfn forged_instant() -> ObserverClockInstant {\n ObserverClockInstant { millis: 946684800000, source: ObserverClockModeled { realization: \"forged\" } }\n}\n\nfn forged_modeled_instant() -> ObserverClockInstant {\n observer_clock_modeled(millis: 946684800000, realization: \"forged\" as NonEmptyStr)\n}\n\nfn controller_time_as_read_floor(\n subject: MachineIntakeSubject,\n endpoint: BmcControllerEndpoint,\n firmware: BmcFirmwareReleaseIdentity,\n managed: ManagedCredentialReference,\n reading: ControllerClockReading,\n probe: ObservedCredentialProbe,\n census: IpmiControllerChannelCensus,\n instant: ObserverClockInstant,\n account: ObservedPublishedAccount,\n) -> BmcAccountStateObservation {\n observed_bmc_account_state(\n subject: subject,\n endpoint: endpoint,\n firmware: firmware,\n managed: managed,\n managed_user: 3,\n attempt: \"forged\" as AttemptIdentity,\n read_floor: reading,\n managed_probe: probe,\n channel_census: census,\n census_evidence: evidence(),\n census_observed_at: instant,\n published_probes: [],\n published_user: 2,\n published_account: account,\n break_glass: managed,\n break_glass_probe: probe,\n controller_clock: none,\n )\n}\n\nfn readback_through_the_projection(o: BmcAccountStateObservation) -> ManagedAdministratorReadback? {\n project_managed_administrator_readback(observed: o)\n}\n\nfn forged_stored(s: ManagedCredentialGenerationStored) -> ManagedCredentialGenerationStored {\n ManagedCredentialGenerationStored { reference: s.reference, stored_version: s.stored_version, stored_at: s.stored_at }\n}\n\nfn forged_fetched(s: ManagedCredentialGenerationStored) -> ManagedCredentialGenerationFetched {\n ManagedCredentialGenerationFetched { stored: s, fetched_at: s.stored_at }\n}\n\nfn forged_application(p: BmcAccountActionPlan) -> BmcAccountApplication {\n BmcAccountApplication {\n plan: p,\n managed_write_completed: true,\n published_write_completed: true,\n request_receipt: evidence(),\n response_receipt: evidence(),\n applied_at: p.planned_at,\n }\n}\n\nfn forged_receipt(r: BmcSecurePhaseReceipt) -> BmcSecurePhaseReceipt {\n BmcSecurePhaseReceipt { subject: r.subject, phase: r.phase, goal: r.goal, decision: r.decision, held: r.held }\n}\n\nfn forged_plan(p: BmcAccountActionPlan) -> BmcAccountActionPlan {\n BmcAccountActionPlan {\n subject: p.subject,\n endpoint: p.endpoint,\n firmware: p.firmware,\n goal: p.goal,\n diverged: p.diverged,\n due: p.due,\n managed_write: p.managed_write,\n published_write: p.published_write,\n planned_at: p.planned_at,\n }\n}\n\nfn forged_observation(o: BmcAccountStateObservation) -> BmcAccountStateObservation {\n BmcAccountStateObservation {\n subject: o.subject,\n endpoint: o.endpoint,\n managed: o.managed,\n read_floor: o.read_floor,\n managed_probe: o.managed_probe,\n channel_census: o.channel_census,\n census_evidence: o.census_evidence,\n census_observed_at: o.census_observed_at,\n published_probes: o.published_probes,\n published_user: o.published_user,\n published_account: o.published_account,\n controller_clock: o.controller_clock,\n }\n}\n\nfn controller_time_in_a_reading_field(reading: ControllerClockReading) -> ObservedReading {\n ObservedReading { evidence: evidence(), observed_at: reading }\n}\n\nfn controller_time_in_an_account_field(kind: PublishedAccountKind, reading: ControllerClockReading) -> ObservedPublishedAccount {\n ObservedPublishedAccount { kind: kind, evidence: evidence(), observed_at: reading }\n}\n\nfn borrowed_fixture_route() -> BmcRotationRouteStanding {\n cited_lab_route_managed_user()\n}\n" data harness_control_source: String = "module probe_bmc_secure_state_harness_control\nimport gunbc.machine_intake_bmc_secure { BmcSecurePhaseReceipt, bmc_secure_phase_receipt_evidence }\nimport gunbc.machine_intake_receipt { EvidenceRef }\nimport std.types { List }\nfn evidence_of(r: BmcSecurePhaseReceipt) -> List { bmc_secure_phase_receipt_evidence(receipt: r) }\n" @@ -87,6 +87,21 @@ test fn a_controller_clock_reading_in_an_ordering_field_refuses_at_the_seal() -> // ObserverClockInstant RECORD FIELD is accepted today -- gunbc.recurring_failure_mode // record_field_admits_a_distinct_product_value, which carries this specimen -- so the sealed // observation mint is the route this claim covers. +// SINCE cut O1a-2 THE OBSERVATION MINT ADMITS ONLY THE DRY READ. The call above, which hands a +// controller's clock reading to the mint as the read floor, now refuses at the mint's admission, so no +// caller outside the dry realization can choose the read floor at all; the dry read derives it from its +// own modeled observer schedule, and the live read is bmc_secure_state_live_read_frontier. The wall is +// therefore construction-level (who may mint), where it was an argument-type refusal before, and that +// argument-type refusal is no longer emitted because the call no longer reaches argument judgement. test fn a_controller_clock_reading_cannot_be_the_read_floor() -> Bool { - blocking_count_for_class_and_subject(c: probe(), wanted: "DeclaredTypeNotInhabited", subject: "direct call argument for parameter 'read_floor'") >= 1 + blocking_count_for_class_and_subject(c: probe(), wanted: "ConstructorCallAdmissionRefused", subject: "observed_bmc_account_state") >= 1 +} + +// THE PROJECTION IS NOT A CONSTRUCTOR PROXY (side-chat review of 8960bbe511). An outside call to +// project_managed_administrator_readback -- the function that returns the sealed readback -- refuses at +// its admission, as does an outside call to the observation's own mint. +test fn the_readback_projection_and_the_observation_mint_refuse_an_outside_caller() -> Bool { + let c = probe() + blocking_count_for_class_and_subject(c: c, wanted: "ConstructorCallAdmissionRefused", subject: "project_managed_administrator_readback") >= 1 + && blocking_count_for_class_and_subject(c: c, wanted: "ConstructorCallAdmissionRefused", subject: "observed_bmc_account_state") >= 1 } diff --git a/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_witness_test.dag b/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_witness_test.dag index 8fae6df35ac..6bf4e5d10e1 100644 --- a/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_witness_test.dag +++ b/dag/test/claim/machine_intake/machine_intake_bmc_secure_state_witness_test.dag @@ -47,8 +47,12 @@ import extdeps.crypto.mac { MacKeyId } import gunbc.auth.approval_capability { ApprovalCapabilityClaims, ProposeApprove, approval_capability_protocol } import gunbc.auth.approval_broker { Redemption, RedemptionAdmitted } import gunbc.auth.secret_ref_credential { SecretCredentialFetch, SecretCredentialReady, SecretCredentialFetchRefused } -import gunbc.bmc_model { BmcWorld, BmcIpmiUser, BmcPowerOn, bmc_world, bmc_with_ipmi_users } +import gunbc.bmc_model { BmcWorld, BmcIpmiUser, BmcPowerOn, bmc_world, bmc_with_ipmi_users, bmc_with_ipmi_user_access, bmc_ipmi_get_user_access } +import v2.std.algebra { any, filter } import gunbc.machine_intake_bmc_rotation_route { + IpmiSetUserPrivilegeLimit, RotationApplyRouteForAnotherOperation, RotationApplyRouteEffectUnobserved, + RotationApplyWouldLeaveNoAdministrator, rotation_route_candidate, PublicStandardOperation, + ManagedReadbackFromAnotherRun, ManagedAccountNotAdministratorOnChannel, BmcRotationRouteStanding, BmcAccountWriteRequest, IpmiSetUserPassword, @@ -72,6 +76,8 @@ import gunbc.machine_intake_bmc_rotation_route { rotation_route_request_identity, } import gunbc.machine_intake_bmc_secure { + ChannelCloseInput, ChannelCloseRouteNotSupplied, ChannelCloseApprovalAbsent, ChannelWriteNotAdmitted, + PlanPrecedesReading, ManagedUserNotTheAuthenticatedAccount, BmcSecureGoal, BmcAccountActionDue, PublishedGenerationNotGoalBound, @@ -87,7 +93,6 @@ import gunbc.machine_intake_bmc_secure { AccountReadingPrecedesReadFloor, AccountStateConjunctionRefused, PublishedCredentialRetainedNotAdmittedByProdRiskPolicy, - ChannelAccessWrite, PublishedFactoryCredentialRestore, BmcAccountPlanOutcome, BmcSecurePhaseOutcome, @@ -294,7 +299,22 @@ fn read(w: BmcWorld, subject: MachineIntakeSubject, managed: ManagedCredentialRe read_with(w: w, subject: subject, managed: managed, managed_password: managed_password, census_value: census(published_lan_privilege_closed: closed), account: PublishedAccountRetired, at: at) } +// THE WORLD HOLDS THE CHANNEL ACCESS, AND THE READ TAKES IT FROM THERE. seeded adds the supplied census's +// Get User Access rows to the world only for (channel, user) pairs the world does not already hold, so a +// row a channel-access write set is kept, and a read after the write reports the write -- never the +// census the scenario started from. +fn seeded(w: BmcWorld, census_value: IpmiControllerChannelCensus) -> BmcWorld { + bmc_with_ipmi_user_access( + world: w, + rows: concat(w.ipmi_user_access, filter(census_value.user_access, r => !any(w.ipmi_user_access, h => (h.user as Int) == (r.user as Int) && (h.channel as Int) == (r.channel as Int)))), + ) +} + fn read_with(w: BmcWorld, subject: MachineIntakeSubject, managed: ManagedCredentialReference, managed_password: String, census_value: IpmiControllerChannelCensus, account: PublishedAccountKind, at: EpochMs) -> BmcAccountStateObservation { + read_in(w: seeded(w: w, census_value: census_value), subject: subject, managed: managed, managed_password: managed_password, census_value: census_value, account: account, attempt: "attempt-1", at: at) +} + +fn read_in(w: BmcWorld, subject: MachineIntakeSubject, managed: ManagedCredentialReference, managed_password: String, census_value: IpmiControllerChannelCensus, account: PublishedAccountKind, attempt: String, at: EpochMs) -> BmcAccountStateObservation { dry_read_bmc_account_state( world: w, subject: subject, @@ -309,6 +329,7 @@ fn read_with(w: BmcWorld, subject: MachineIntakeSubject, managed: ManagedCredent published_account: account, break_glass: goal_break_glass_ref(), break_glass_password: break_glass_password, + attempt: attempt as AttemptIdentity, read_at_millis: at, ) } @@ -341,7 +362,7 @@ fn rotation_approval(s: BmcRotationRouteStanding, user: IpmiUserId) -> Redemptio // The approval names the route's own request: the operator approves what the route grounds. fn route_user(s: BmcRotationRouteStanding) -> IpmiUserId { match s.grounding { - RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _ } => request_user(r: r) + RouteGroundedByExecutedRequest { request: r, request_receipt: _, response_receipt: _, effect: _ } => request_user(r: r) RouteGroundedByCitedSource { request: r, citation: _ } => request_user(r: r) RouteQualificationCandidate { request: r, evidence: _ } => request_user(r: r) RouteUngrounded => managed_user @@ -351,6 +372,7 @@ fn route_user(s: BmcRotationRouteStanding) -> IpmiUserId { fn request_user(r: BmcAccountWriteRequest) -> IpmiUserId { match r { IpmiSetUserPassword { user: u } => u + IpmiSetUserPrivilegeLimit { access: x } => x.user RedfishAccountPasswordWrite { transport_operation: _, action_shape: _ } => managed_user } } @@ -474,6 +496,14 @@ fn plan_with( plan_full(reading: reading, goal: goal, managed_route: managed_route, managed_generation_value: managed_generation_value, published_generation_value: break_glass_generation(), planned_at: planned_at) } +fn plan_closing(reading: BmcAccountStateObservation, channel_close: ChannelCloseInput?) -> BmcAccountPlanOutcome? { + plan_closing_as(reading: reading, claimed_managed_user: managed_user, channel_close: channel_close) +} + +fn plan_closing_as(reading: BmcAccountStateObservation, claimed_managed_user: IpmiUserId, channel_close: ChannelCloseInput?) -> BmcAccountPlanOutcome? { + plan_full_as(reading: reading, goal: goal_v1(), claimed_managed_user: claimed_managed_user, managed_route: grounded_route(user: managed_user), managed_generation_value: managed_generation(version: "2", fetch_at: t_fetch), published_generation_value: break_glass_generation(), channel_close: channel_close, planned_at: t_plan) +} + fn plan_full( reading: BmcAccountStateObservation, goal: BmcSecureGoal, @@ -481,6 +511,31 @@ fn plan_full( managed_generation_value: ManagedCredentialGenerationFetched?, published_generation_value: ManagedCredentialGenerationFetched?, planned_at: EpochMs, +) -> BmcAccountPlanOutcome? { + plan_full_closing(reading: reading, goal: goal, managed_route: managed_route, managed_generation_value: managed_generation_value, published_generation_value: published_generation_value, channel_close: none, planned_at: planned_at) +} + +fn plan_full_closing( + reading: BmcAccountStateObservation, + goal: BmcSecureGoal, + managed_route: BmcRotationRouteStanding, + managed_generation_value: ManagedCredentialGenerationFetched?, + published_generation_value: ManagedCredentialGenerationFetched?, + channel_close: ChannelCloseInput?, + planned_at: EpochMs, +) -> BmcAccountPlanOutcome? { + plan_full_as(reading: reading, goal: goal, claimed_managed_user: managed_user, managed_route: managed_route, managed_generation_value: managed_generation_value, published_generation_value: published_generation_value, channel_close: channel_close, planned_at: planned_at) +} + +fn plan_full_as( + reading: BmcAccountStateObservation, + goal: BmcSecureGoal, + claimed_managed_user: IpmiUserId, + managed_route: BmcRotationRouteStanding, + managed_generation_value: ManagedCredentialGenerationFetched?, + published_generation_value: ManagedCredentialGenerationFetched?, + channel_close: ChannelCloseInput?, + planned_at: EpochMs, ) -> BmcAccountPlanOutcome? { match managed_generation_value { Absent => none @@ -493,13 +548,14 @@ fn plan_full( subject: lab_subject(), goal: goal, reading: reading, - managed_user: managed_user, + managed_user: claimed_managed_user, managed_route: managed_route, managed_approval: rotation_approval(s: managed_route, user: route_user(s: managed_route)), managed_generation: mg, published_route: grounded_route(user: published_user), published_approval: rotation_approval(s: grounded_route(user: published_user), user: published_user), published_generation: bg, + channel_close: channel_close, planned_at: observer_at(millis: planned_at), ), } @@ -521,6 +577,14 @@ fn admission_label(a: RotationApplyAdmission) -> String { RotationApplyApprovalDenied => "approval-denied" RotationApplyApprovalForAnotherAuthority { authority: _ } => "another-authority" RotationApplyApprovalForAnotherRequest { approved: _, requested: _ } => "another-request" + RotationApplyRouteForAnotherOperation { grounded: _, requested: _ } => "another-operation" + RotationApplyRouteEffectUnobserved { standing: _ } => "effect-unobserved" + RotationApplyWouldLeaveNoAdministrator { channel: _, cause: c } => + match c { + ManagedReadbackFromAnotherRun { readback: _, approved: _ } => "would-leave-no-administrator:another-run" + ManagedAccountNotAdministratorOnChannel { managed_user: _ } => "would-leave-no-administrator:not-administrator-on-channel" + _ => "would-leave-no-administrator" + } } } @@ -558,6 +622,11 @@ fn plan_label(o: BmcAccountPlanOutcome?) -> String { PublishedGenerationNotGoalBound { generation: _, goal: _ } => "published-generation-not-goal-bound" GenerationFetchedAfterPlan { target: _, fetched_at: _, planned_at: _ } => "fetched-after-plan" PlanPrecedesDivergedReading { read_floor: _, planned_at: _ } => "plan-precedes-reading" + PlanPrecedesReading { planned_at: _ } => "plan-precedes-reading" + ManagedUserNotTheAuthenticatedAccount { supplied: _, authenticated: _ } => "managed-user-not-authenticated-account" + ChannelCloseRouteNotSupplied { channels: _ } => "channel-close-route-not-supplied" + ChannelCloseApprovalAbsent { channel: _ } => "channel-close-approval-absent" + ChannelWriteNotAdmitted { channel: _, admission: a } => join(["channel-write-not-admitted:", admission_label(a: a)], "") } } } @@ -574,7 +643,7 @@ fn phase_label(o: BmcSecurePhaseOutcome) -> String { match c { PhaseReadingUnobserved { cause: _ } => "refused:unobserved" PhaseNotHeld { decision: d } => join(["refused:not-held:", decision_label(d: d)], "") - ApplicationIncomplete { managed_write_completed: m, published_write_completed: p, response_receipt: _ } => + ApplicationIncomplete { managed_write_completed: m, published_write_completed: p, channel_writes_completed: _, response_receipt: _ } => join(["refused:incomplete:", if m { "m" } else { "-" }, if p { "p" } else { "-" }], "") PostReadForAnotherController { expected: _, found: _ } => "refused:another-controller" PostReadPrecedesApplication { applied_at: _, read_floor: _ } => "refused:post-read-precedes-application" @@ -731,7 +800,7 @@ test fn the_plan_refuses_a_stale_or_foreign_generation_and_a_foreign_reading() - plan_label(o: plan_with(reading: reading, goal: goal_v1(), managed_route: grounded_route(user: managed_user), managed_generation_value: break_glass_generation(), planned_at: t_plan)) == "generation-another-account" && plan_label(o: plan_with(reading: read(w: world_factory_open(), subject: lab_subject(), managed: managed_ref(version: "2", epoch: 2), managed_password: managed_password_v1, closed: true, at: t_read), goal: stale_goal, managed_route: grounded_route(user: managed_user), managed_generation_value: managed_generation(version: "2", fetch_at: t_fetch), planned_at: t_plan)) == "generation-not-advanced" && plan_label(o: plan_default(reading: foreign)) == "unobserved" - && plan_label(o: plan_with(reading: reading, goal: goal_v1(), managed_route: grounded_route(user: published_user), managed_generation_value: managed_generation(version: "2", fetch_at: t_fetch), planned_at: t_plan)) == "another-user" + && plan_label(o: plan_with(reading: reading, goal: goal_v1(), managed_route: grounded_route(user: published_user), managed_generation_value: managed_generation(version: "2", fetch_at: t_fetch), planned_at: t_plan)) == "not-admitted:another-request" } // ── blocker controls (side-chat review of 07423d29de) ─────────────────────────────────────────── @@ -744,7 +813,6 @@ fn state_refusal_label(c: BmcSecureStateRefusal) -> String { AccountStateConjunctionRefused { cause: _ } => "conjunction-refused" AccountDeviationNeedsUngroundedOperation { cause: _, operation: op } => match op { - ChannelAccessWrite => "needs:channel-access-write" PublishedFactoryCredentialRestore => "needs:factory-credential-restore" } AccountRetentionNotGoalBound { retained: _, goal: _ } => "retention-not-goal-bound" @@ -801,16 +869,57 @@ test fn the_published_replacement_must_be_the_goal_bound_break_glass_generation( && plan_label(o: plan_full(reading: reading, goal: goal_v1(), managed_route: grounded_route(user: managed_user), managed_generation_value: managed_generation(version: "2", fetch_at: t_fetch), published_generation_value: break_glass_generation(), planned_at: t_plan)) == "planned" } -// BLOCKER 3. A channel still open to the published account (an administrator privilege on a serial -// channel, or on an unaddressed LAN channel) is not cleared by a password write, so it refuses naming -// the missing channel-access write and plans nothing. -test fn an_open_channel_refuses_naming_the_missing_channel_access_write() -> Bool { - assessment_on(reading: secured_read(census_value: census_with(serial_privilege_open: true, unaddressed_lan_open: false), account: PublishedAccountRetired)) == "needs:channel-access-write/refuse" - && assessment_on(reading: secured_read(census_value: census_with(serial_privilege_open: false, unaddressed_lan_open: true), account: PublishedAccountRetired)) == "needs:channel-access-write/refuse" - && plan_label(o: plan_default(reading: secured_read(census_value: census_with(serial_privilege_open: true, unaddressed_lan_open: false), account: PublishedAccountRetired))) == "not-due:refuse" +// BLOCKER 3, RECLASSIFIED (cut O1a-2). A channel still open to the published account (an +// administrator privilege on a serial channel, or on an unaddressed LAN channel) is now a DEVIATION: +// the assessment diverges and the decision is Apply. A password write still cannot clear it, so the +// plan refuses unless a channel-access route is supplied -- the missing operation is now a typed plan +// refusal, not an assessment refusal. +test fn an_open_channel_is_a_deviation_and_the_plan_refuses_without_a_channel_access_route() -> Bool { + string_contains(s: assessment_on(reading: secured_read(census_value: census_with(serial_privilege_open: true, unaddressed_lan_open: false), account: PublishedAccountRetired)), pattern: "diverged/apply:") + && string_contains(s: assessment_on(reading: secured_read(census_value: census_with(serial_privilege_open: false, unaddressed_lan_open: true), account: PublishedAccountRetired)), pattern: "diverged/apply:") + && plan_label(o: plan_default(reading: secured_read(census_value: census_with(serial_privilege_open: true, unaddressed_lan_open: false), account: PublishedAccountRetired))) == "channel-close-route-not-supplied" && assessment_on(reading: secured_read(census_value: census_with(serial_privilege_open: false, unaddressed_lan_open: false), account: PublishedAccountRetired)) == "satisfied/noop" } +// THE CHANNEL-ACCESS WRITE IN THE PLAN MINT IS ADMISSIBLE ONLY OVER A GROUNDED CHANNEL-ACCESS ROUTE. +// On a reading with the published account open on serial channel 2 and the managed account read back +// at ADMINISTRATOR on that channel: no route -> refused; an ungrounded candidate route -> not admitted; +// a grounded route with no approval naming the write -> refused; a reading where the managed account is +// NOT administrator on the channel (its row absent) -> not admitted, would leave no administrator; and +// the grounded route with the exact approval -> planned, with exactly that one channel write. +fn census_with_managed_row(managed_on_2: Bool) -> IpmiControllerChannelCensus { + let base = census_with(serial_privilege_open: true, unaddressed_lan_open: false) + ipmi_controller_channel_census( + members: base.members, + user_access: if managed_on_2 { concat(base.user_access, [ipmi_user_channel_access(channel: 2, user: managed_user, privilege: IpmiPrivilegeAdministrator)]) } else { base.user_access }, + ) +} + +fn channel_plan_label(o: BmcAccountPlanOutcome?) -> String { + match o { + Present { value: x } => + match x { + BmcAccountPlanned { plan: p } => join(["planned:", to_string(list_length(items: p.channel_writes))], "") + BmcAccountPlanRefused { cause: _ } => plan_label(o: o) + } + Absent => plan_label(o: o) + } +} + +test fn an_open_channel_is_closed_only_over_a_grounded_channel_access_route() -> Bool { + let close = IpmiSetUserPrivilegeLimit { access: ipmi_user_channel_access(channel: 2, user: published_user, privilege: IpmiPrivilegeNoAccess) } + let route = rotation_route_from_citation(endpoint: lab_endpoint, firmware: lab_firmware(), request: close, citation: lab_route_fixture_citation) + let candidate = rotation_route_candidate(endpoint: lab_endpoint, firmware: lab_firmware(), request: close, evidence: PublicStandardOperation { authority: lab_route_fixture_citation }) + let exact = [approval(authority: rotation_apply_authority, revision: rotation_route_request_identity(standing: route, request: close))] + let with_admin = secured_read(census_value: census_with_managed_row(managed_on_2: true), account: PublishedAccountRetired) + let without_admin = secured_read(census_value: census_with_managed_row(managed_on_2: false), account: PublishedAccountRetired) + channel_plan_label(o: plan_closing(reading: with_admin, channel_close: none)) == "channel-close-route-not-supplied" + && channel_plan_label(o: plan_closing(reading: with_admin, channel_close: Present { value: ChannelCloseInput { route: candidate, approvals: exact } })) == "channel-write-not-admitted:route-not-grounded" + && channel_plan_label(o: plan_closing(reading: with_admin, channel_close: Present { value: ChannelCloseInput { route: route, approvals: [] } })) == "channel-close-approval-absent" + && channel_plan_label(o: plan_closing(reading: without_admin, channel_close: Present { value: ChannelCloseInput { route: route, approvals: exact } })) == "channel-write-not-admitted:would-leave-no-administrator:not-administrator-on-channel" + && channel_plan_label(o: plan_closing(reading: with_admin, channel_close: Present { value: ChannelCloseInput { route: route, approvals: exact } })) == "planned:1" +} + // Retention. A break-glass account retained by policy must be the goal's generation; a factory // credential retained by policy and found not accepted names the missing restore. test fn a_retained_credential_must_be_the_goal_bound_generation() -> Bool { @@ -885,3 +994,75 @@ test fn an_apply_whose_post_read_fails_the_goal_generation_mints_no_receipt() -> readback_at: t_readback, ) == join(["refused:post-read-not-held:", apply_on_finding(finding: BreakGlassGenerationRejected)], "") } + +// ── the projection's inputs come from the observation producer (side-chat review of 8960bbe511) ─── + +fn close_ch2() -> BmcAccountWriteRequest { + IpmiSetUserPrivilegeLimit { access: ipmi_user_channel_access(channel: 2, user: published_user, privilege: IpmiPrivilegeNoAccess) } +} + +fn close_approval_in(route: BmcRotationRouteStanding, attempt: String) -> Redemption { + RedemptionAdmitted { + claims: ApprovalCapabilityClaims { + protocol: approval_capability_protocol, + issuer: "gunbc-approval-broker" as NonEmptyStr, + audience: "srv1" as NonEmptyStr, + authority: rotation_apply_authority, + escalation_id: "o1a2-close" as NonEmptyStr, + request_revision: rotation_route_request_identity(standing: route, request: close_ch2()), + decision: ProposeApprove, + attempt: attempt as AttemptIdentity, + issued_at: "2026-10-05T00:00:00Z", + expires_at: "2026-10-05T00:15:00Z", + key_id: "broker-2026-10" as MacKeyId, + }, + decided_by: "operator" as NonEmptyStr, + } +} + +// On the REAL plan path, with the published account open on channel 2: read A (attempt-1) with an +// approval for run B refuses as another run; A with A plans the one write; a reading in which another +// user (4), not the authenticated managed user, holds ADMINISTRATOR on channel 2 refuses; and a plan +// claiming a managed user other than the one the read authenticated refuses. A read later than the plan +// refuses at PlanPrecedesDivergedReading (the dry read takes every reading at one instant). +test fn the_channel_close_readback_is_bound_to_the_observed_run_and_account() -> Bool { + let route = rotation_route_from_citation(endpoint: lab_endpoint, firmware: lab_firmware(), request: close_ch2(), citation: lab_route_fixture_citation) + let base = census_with(serial_privilege_open: true, unaddressed_lan_open: false) + let other_admin = ipmi_controller_channel_census(members: base.members, user_access: concat(base.user_access, [ipmi_user_channel_access(channel: 2, user: 4, privilege: IpmiPrivilegeAdministrator)])) + let a = secured_read(census_value: census_with_managed_row(managed_on_2: true), account: PublishedAccountRetired) + let later = read_with(w: world_secured(), subject: lab_subject(), managed: managed_ref(version: "1", epoch: 1), managed_password: managed_password_v1, census_value: census_with_managed_row(managed_on_2: true), account: PublishedAccountRetired, at: t_plan + 1) + channel_plan_label(o: plan_closing(reading: a, channel_close: Present { value: ChannelCloseInput { route: route, approvals: [close_approval_in(route: route, attempt: "attempt-2")] } })) == "channel-write-not-admitted:would-leave-no-administrator:another-run" + && channel_plan_label(o: plan_closing(reading: a, channel_close: Present { value: ChannelCloseInput { route: route, approvals: [close_approval_in(route: route, attempt: "attempt-1")] } })) == "planned:1" + && channel_plan_label(o: plan_closing(reading: secured_read(census_value: other_admin, account: PublishedAccountRetired), channel_close: Present { value: ChannelCloseInput { route: route, approvals: [close_approval_in(route: route, attempt: "attempt-1")] } })) == "channel-write-not-admitted:would-leave-no-administrator:not-administrator-on-channel" + && channel_plan_label(o: plan_closing_as(reading: a, claimed_managed_user: 4, channel_close: Present { value: ChannelCloseInput { route: route, approvals: [close_approval_in(route: route, attempt: "attempt-1")] } })) == "managed-user-not-authenticated-account" + && channel_plan_label(o: plan_closing(reading: later, channel_close: Present { value: ChannelCloseInput { route: route, approvals: [close_approval_in(route: route, attempt: "attempt-1")] } })) == "plan-precedes-reading" +} + +// ── one nonempty real plan through the dry application, the post-read and the phase (item 3) ───── + +// The published account open on serial channel 2, the managed account ADMINISTRATOR there. The plan's +// one channel write runs through dry_apply_bmc_account_plan; the post-read takes channel access from +// the RESULTING world (not from the census the scenario started with), and the phase converges. +// The world then holds the published user at NO ACCESS on channel 2 and the managed user still at +// ADMINISTRATOR there. +test fn a_planned_channel_close_is_applied_read_back_and_converges() -> Bool { + let route = rotation_route_from_citation(endpoint: lab_endpoint, firmware: lab_firmware(), request: close_ch2(), citation: lab_route_fixture_citation) + let layout = census_with_managed_row(managed_on_2: true) + let initial = seeded(w: world_secured(), census_value: layout) + let before = read_in(w: initial, subject: lab_subject(), managed: managed_ref(version: "1", epoch: 1), managed_password: managed_password_v1, census_value: layout, account: PublishedAccountRetired, attempt: "attempt-1", at: t_read) + match plan_closing(reading: before, channel_close: Present { value: ChannelCloseInput { route: route, approvals: [close_approval_in(route: route, attempt: "attempt-1")] } }) { + Absent => false + Present { value: o } => + match o { + BmcAccountPlanRefused { cause: _ } => false + BmcAccountPlanned { plan: p } => { + let step = dry_apply_bmc_account_plan(world: initial, plan: p, managed_fetch: managed_v2_fetch(), published_fetch: ready(secret: "bmc-lab-o1b-admin", version: "4", bytes: break_glass_password), applied_at_millis: t_apply) + let after = read_in(w: step.world, subject: lab_subject(), managed: p.goal.managed, managed_password: managed_password_v2, census_value: layout, account: PublishedAccountRetired, attempt: "attempt-1", at: t_readback) + list_length(items: p.channel_writes) == 1 + && phase_label(o: bmc_secure_phase_applied(application: step.application, post_read: after)) == "converged:applied" + && match bmc_ipmi_get_user_access(world: step.world, user: published_user, channel: 2) { Present { value: v } => v == IpmiPrivilegeNoAccess Absent => false } + && match bmc_ipmi_get_user_access(world: step.world, user: managed_user, channel: 2) { Present { value: v } => v == IpmiPrivilegeAdministrator Absent => false } + } + } + } +}