Repository navigation
fix(mdm): provider MDM read-only + close webhook trust-injection (T-021/SEC-004) - #270
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR partially mitigates the unauthenticated MDM webhook (T-021/SEC-004) by introducing an optional shared-secret gate, but the mitigation is advisory-only and leaves the critical path open if the secret is not configured. Trust Boundaries Touched
Threat AnalysisT-021 — Unauthenticated MDM webhook injection manipulates provider trust state
T-038 — Missing The T-032 — Solana wallet mnemonic exfiltration New Attack Surface / Uncovered Issues
Open Findings Status
🔐 Threat model: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d908fbd9a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if webhookSecret := os.Getenv("EIGENINFERENCE_MDM_WEBHOOK_SECRET"); webhookSecret != "" { | ||
| srv.SetMDMWebhookSecret(webhookSecret) |
There was a problem hiding this comment.
Wire the webhook secret into MicroMDM's callback URL
When EIGENINFERENCE_MDM_WEBHOOK_SECRET is set here, the server starts rejecting webhook calls that lack the token, but the repo's MicroMDM launch path still uses coordinator/deploy/start.sh with -command-webhook-url http://localhost:8080/v1/mdm/webhook and does not append ?token=... or set the X-Webhook-Token header. In deployments that follow that script and enable the new recommended secret, every legitimate SecurityInfo/MDA callback will get 403 before the MDM client sees it, so provider hardware trust verification will time out.
Useful? React with 👍 / 👎.
| // matching a webhook response. Comfortably longer than the 90s SecurityInfo | ||
| // wait to allow for late (Power Nap / APN) delivery, short enough to bound the | ||
| // forge window if a UUID ever leaked. | ||
| const outstandingCommandTTL = 10 * time.Minute |
There was a problem hiding this comment.
Extend the command TTL past APN sleep delays
For providers whose Mac is asleep and APN delivery follows the Power Nap cadence called out in main.go (~15 minutes), this 10-minute window expires before a genuine SecurityInfo response can arrive. consumeCommand then treats that response as stale before dispatching to the late-arrival callback, so the recovery path for timed-out verifications never fires and the provider remains self_signed despite a valid MDM response.
Useful? React with 👍 / 👎.
…injection
Hardens the coordinator↔MicroMDM boundary so (a) the coordinator can only ever
READ a provider's security posture, never act on the machine, and (b) the
unauthenticated webhook can no longer be used to forge a hardware-trust upgrade
(threat-model T-021 / SEC-004).
Read-only enforcement:
- assertReadOnlyCommand is a single chokepoint with an exhaustive allowlist
{SecurityInfo, DeviceInformation}. Both command senders go through it, so any
attempt to issue a mutating command (DeviceLock, EraseDevice, InstallProfile,
RestartDevice, …) fails closed before reaching the device. Enrolling a
provider grants visibility, never control.
Solicited-response gate (the real anti-forgery fix):
- Every issued command UUID is tracked (TTL-bounded, one-shot). HandleWebhook
now parses the response's CommandUUID and drops any webhook whose UUID was not
issued by the coordinator, before any waiter or trust-upgrade callback runs.
Command UUIDs are random and never exposed, so an attacker who reaches the
webhook cannot match an in-flight command — closing the path that let a forged
"SIP=true" SecurityInfo promote a self_signed provider to hardware. Also
rejects a solicited UUID replayed against a different device's UDID.
HTTP layer:
- Body cap (1 MiB MaxBytesReader) stops the unbounded-body memory DoS.
- Optional shared secret (EIGENINFERENCE_MDM_WEBHOOK_SECRET, via ?token= or
X-Webhook-Token, constant-time) rejects unauthorized callers before the body
is read. MicroMDM is co-located, so the secret never crosses the public net.
Tests: read-only allowlist (reads pass / mutating blocked), CommandUUID parse,
track→consume lifecycle (one-shot + TTL), webhook drops unsolicited &
UDID-mismatched responses, and the HTTP secret gate. go test ./... green (12 pkgs).
The solicited-command gate's security rests on CommandUUID secrecy. The verbose plist preview echoed the device response (incl. the CommandUUID) at Info level — a side-channel for anyone with log access. Demote the raw preview to Debug; keep the structured (size/has_*) summary at Info.
…-up) Threat-model review flagged that the shared-secret check is opt-in. The CommandUUID gate is the mandatory protection, but emit a startup Warn when MDM is enabled without EIGENINFERENCE_MDM_WEBHOOK_SECRET so a misconfigured deployment is visible rather than silent.
…Power Nap Two review follow-ups: - start.sh now appends ?token=$EIGENINFERENCE_MDM_WEBHOOK_SECRET to MicroMDM's -command-webhook-url when the secret is set. Without this, enabling the coordinator's recommended webhook secret would 403 every legitimate SecurityInfo/MDA callback (MicroMDM can't set a header on the command webhook), stalling provider hardware-trust verification. The coordinator accepts the token via ?token= or X-Webhook-Token (HandleMDMWebhook). - outstandingCommandTTL 10m -> 30m. A sleeping Mac delivers its SecurityInfo response on a ~15-minute Power Nap cadence; at 10m the issued command UUID expired first, so consumeCommand dropped the genuine response as stale and the self_signed->hardware late-recovery path never fired. 30m covers the delay while still bounding the forge window for a random, localhost-only UUID.
d908fbd to
b2ba83d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2ba83d290
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # SecurityInfo/MDA callback and stall provider hardware-trust verification. | ||
| MDM_WEBHOOK_URL="http://localhost:8080/v1/mdm/webhook" | ||
| if [ -n "${EIGENINFERENCE_MDM_WEBHOOK_SECRET:-}" ]; then | ||
| MDM_WEBHOOK_URL="${MDM_WEBHOOK_URL}?token=${EIGENINFERENCE_MDM_WEBHOOK_SECRET}" |
There was a problem hiding this comment.
URL-encode the webhook token parameter
When EIGENINFERENCE_MDM_WEBHOOK_SECRET contains query-significant characters (for example a standard base64 secret with + or &), this constructs a callback URL whose token value is not the same string the coordinator later compares: r.URL.Query().Get("token") decodes + as space and treats & as a separator before the constant-time comparison. In deployments that generate random/base64 secrets, legitimate MicroMDM callbacks can therefore be rejected with 403; encode the value before appending it or require a URL-safe secret alphabet.
Useful? React with 👍 / 👎.
Summary
Closes the MicroMDM webhook trust-injection gap (threat-model T-021 / SEC-004) and adds a hard guarantee that the coordinator's MDM capability over a provider's Mac is read-only.
The MDM
SecurityInfocallback is the coordinator's independent check that a provider isn't lying about SIP/Secure Boot. That callback arrived overPOST /v1/mdm/webhookwith no auth, no body cap, and no check that the coordinator asked for it — and the late-arrival path (main.go) upgraded aself_signedprovider straight to hardware trust from attacker-controlled SIP/SecureBoot values. A malicious-but-enrolled operator could disable SIP (to read plaintext prompts / run a modified binary / serve manipulated models), then POST a forgedSIP=truewebhook for their own UDID and be promoted to hardware trust — defeating the core attestation guarantee.What changed
1. Read-only MDM (you can't do anything to a provider's machine)
assertReadOnlyCommand— a single chokepoint with an exhaustive allowlist{SecurityInfo, DeviceInformation}(both pure queries). Both command senders route through it, so any mutating command (DeviceLock,EraseDevice,InstallProfile,RestartDevice,ShutDownDevice, …) fails closed before reaching MicroMDM. Adding a command type now requires an explicit, reviewable allowlist change.2. Solicited-response gate (the real anti-forgery fix)
HandleWebhookparses the response'sCommandUUIDand drops any webhook whose UUID the coordinator didn't issue, before any waiter or trust-upgrade callback runs. UUIDs are random and never exposed, so a reachable attacker can't match an in-flight command. Also rejects a solicited UUID replayed against a different device's UDID. This closes both the waiter path and the late-callback path.3. HTTP hardening
MaxBytesReaderbody cap — kills the unbounded-body memory DoS.EIGENINFERENCE_MDM_WEBHOOK_SECRET, via?token=orX-Webhook-Token, constant-time) — rejects unauthorized callers before the body is read. MicroMDM is co-located, so the secret never crosses the public network.Defense-in-depth, layered
Testing
go test ./...green (12 packages). New tests:TestAssertReadOnlyCommand— reads allowed, every mutating command blocked.TestParseCommandUUID,TestCommandTrackingLifecycle— parse + track→consume (one-shot, TTL, unknown-UUID).TestWebhookDropsUnsolicitedSecurityInfo— forged SIP=true is dropped; solicited is honored.TestWebhookDropsUUIDForDifferentDevice— UUID/UDID replay dropped.TestMDMWebhookSecretGate/...NoSecretConfigured— HTTP secret layer.Deployment notes (not code)
localhost:9002(coordinator-only); keep it bound to loopback.EIGENINFERENCE_MDM_WEBHOOK_SECRETon the coordinator and append?token=<same>to MicroMDM's command-webhook-url. Safe to roll out without it — the CommandUUID gate is the mandatory protection.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.