Files
minerops/agents/windows/MinerOpsControl.ps1
T
lussierj e898f283ab security: contain physical miner commands in Stage A
Disable physical control through legacy HTTP/M30 producers, typed admission,
queue dispatch and upgraded Windows executors. Restrict diagnostic transports
to exact read-only operations, with ordinal PowerShell validation before sockets.

Retire unsupported pending/claimed work with atomic, idempotent security audits.
Preserve prior delivery evidence and report unknown outcomes after a prior claim,
including explicitly repaired pending rows. Include containment, cancellation,
concurrency and malformed-payload regressions and the old-Agent cutover runbook.

Validation: independent final application-security revalidation PASS. Two unchanged
baseline source-assertion failures are documented as exceptions. Production release
still requires native Windows validation and verified fencing/stop/drain/upgrade;
server cancellation alone cannot revoke a cached command held by an old Agent.
2026-10-15 20:39:45 +00:00

101 lines
3.4 KiB
PowerShell

# Typed MinerOps miner-control execution. Loaded by MinerOpsAgentService.ps1.
function Get-MinerOpsAgentVersion {
$versionPath = Join-Path $PSScriptRoot "VERSION"
if (Test-Path $versionPath) {
return ([string](Get-Content $versionPath -Raw)).Trim()
}
return "unknown"
}
function Get-MinerOpsControlCredentials {
$config = Read-AgentConfig
$account = ([string]$config.api3_account).Trim()
$password = [string]$config.api3_password
$port = 4433
if ($config.api3_port) {
try { $port = [int]$config.api3_port } catch { $port = 4433 }
}
return @{
available = (-not [string]::IsNullOrWhiteSpace($account)) -and
(-not [string]::IsNullOrWhiteSpace($password))
account = $account
password = $password
port = $port
}
}
function Invoke-MinerOpsControlApi3Command {
param([string]$IpAddress, [string]$Command, [object]$Param = $null)
throw "physical_control_disabled_stage_a"
}
function New-MinerOpsControlResult {
param(
[bool]$Accepted,
[bool]$VerificationAttempted,
[string]$VerificationStatus,
[string]$ObservedMode = "",
[string]$FailureCode = "",
[string]$QueueStatus = "completed"
)
return [ordered]@{
schema_version = 1
command_accepted = $Accepted
verification_attempted = $VerificationAttempted
verification_status = $VerificationStatus
observed_service_state = $null
observed_performance_mode = if ($ObservedMode) { $ObservedMode } else { $null }
failure_code = if ($FailureCode) { $FailureCode } else { $null }
_queue_status = $QueueStatus
}
}
function Run-MinerControlCommand {
param([Parameter(Mandatory=$true)][object]$Payload)
# No current request schema binds authorization to physical identity.
# Do not parse, normalize, reinterpret, or transmit an old queued payload.
return New-MinerOpsControlResult -Accepted $false `
-VerificationAttempted $false -VerificationStatus "unavailable" `
-FailureCode "physical_control_disabled_stage_a" -QueueStatus "failed"
}
function Send-AgentCommandResult {
param(
[string]$CommandId,
[string]$Status,
[object]$ResultPayload = $null,
[string]$ErrorMessage = $null
)
if ($ResultPayload -and $ResultPayload._queue_status) {
$Status = [string]$ResultPayload._queue_status
$ResultPayload.Remove("_queue_status")
$ErrorMessage = if ($ResultPayload.failure_code) {
[string]$ResultPayload.failure_code
} else { $null }
}
$body = [ordered]@{
command_id = $CommandId
status = $Status
result_payload = $ResultPayload
error_message = $ErrorMessage
}
return Invoke-AgentApi -Method "POST" -Path "/api/agent/commands/result" -Body $body
}
function Send-AgentCheckin {
$config = Read-AgentConfig
$body = [ordered]@{
agent_id = [string]$config.agent_id
site_id = [string]$config.site_id
site_name = [string]$config.site_name
hostname = $env:COMPUTERNAME
version = Get-MinerOpsAgentVersion
ip_address = ""
control_available = $false
control_unavailable_reason = "physical_control_disabled_stage_a"
local_time = (Get-Date).ToString("o")
}
return Invoke-AgentApi -Method "POST" -Path "/api/agent/checkin" -Body $body
}