Recovery Lock Rotation for Apple Silicon Macs at Scale
A production-safe workflow for rotating and auditing macOS Recovery Lock passwords via Jamf Pro APIs to stop manual unlock escalations.

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.
The old way of handling Recovery Lock on Apple Silicon Macs looks like this: a technician receives a repair or troubleshooting ticket, the Mac boots to macOS Recovery, and it demands a firmware-level passcode nobody in the room has memorised.
Someone opens a shared spreadsheet or a ticket comment thread from eighteen months ago, hunts for a serial number match, and reads a static passcode out loud over a call.
That passcode has often never been rotated since imaging day, it is frequently pasted into multiple tickets in plain text, and it grants firmware-level control of the machine to anyone who ever read that ticket. It is slow, it is an audit failure waiting to happen, and it does not scale past a handful of devices a week.
The new way treats the Recovery Lock passcode the same way modern identity teams treat any privileged credential: short-lived, rotated on a schedule, retrievable only through an audited path, and never static long enough to matter if it leaks. Apple’s MDM protocol already gives us the primitive we need with the SetRecoveryLock command.
That primitive can be wired into a rotation schedule, a scoped retrieval workflow, and a compliance evidence trail, so the technician gets an unlock code in seconds through an approved channel instead of digging through old tickets.
#Prerequisites and Permissions
Confirm the following before enabling scheduled rotation on any Smart Group or dynamic collection:
- Fleet is Apple Silicon (M-series). Apple silicon Macs use Recovery Lock where Intel-based Macs use a firmware password; this workflow does not apply to Intel Macs.
- Apple’s SetRecoveryLock command reference lists the requirements: a Mac with Apple silicon running macOS 11.5 or later (the release that introduced the command), addressed on the device channel, and supervised; the command is not available in User Enrollment, and the MDM needs the DeviceLockAndRemovePasscode access right. In this fleet, supervision comes from Automated Device Enrollment through Apple Business Manager.
- Macs whose Recovery Lock was set by another tool or person: the device requires the current passcode before it accepts a new one, so Jamf Pro can rotate the lock only if it holds that value. Keep such Macs out of scope until the current passcode is known and escrowed (check Jamf’s Recovery Lock documentation for how your Jamf Pro version takes an existing passcode), then prove the first rotation on one of them before adding the rest.
- Jamf Pro (or another MDM with equivalent API support) with a dedicated API service account scoped to only sending the Set Recovery Lock command, viewing the Recovery Lock password and reading MDM command information (privilege names vary by Jamf Pro version). Do not attach this role to a general helpdesk account.
- Short-lived OAuth client credentials for the service account, token lifetime 30 minutes or less, rotated independently of the Recovery Lock passcodes themselves.
- A secrets store (HashiCorp Vault, Azure Key Vault, or equivalent) for the break-glass path used when a device cannot reach the MDM to report status.
- A SIEM or logging pipeline able to accept a webhook so every retrieval of a live passcode is recorded with ticket number, technician identity, and device serial.
Minimum blast radius for a rotation run is one device. Batch rotations should be capped at fifty devices per run with a health check between batches. Monitoring signal is the MDM command history status field; rollback trigger is any batch showing more than five percent command failures or devices dropping off MDM check-in mid-run.
#Implementation Steps
Scope the fleet. Action: build a Smart Group (or equivalent Intune-side compliance filter) matching Apple Silicon, Supervised = true, Recovery Lock Enabled = true. Devices that have never had a lock set fall outside this filter; set their first passcode in a separate batch. Expected result: a discrete, countable device list, not the entire fleet at once. Evidence to capture: exported group membership count and timestamp, stored with the rotation ticket.
Generate a fresh passcode per device. Action: run the generator script below inside the rotation job, never reuse a passcode across devices. Expected result: one cryptographically random alphanumeric string per serial number, excluding ambiguous characters. Evidence to capture: the script’s log line showing serial number mapped to a passcode hash (not the plaintext) for later reconciliation.
Push the SetRecoveryLock command. Action: call the MDM command against each device’s management ID using the API pattern in the code sample below. Apple’s SetRecoveryLock reference documents two keys: NewPassword, and CurrentPassword, which the device requires whenever a lock is already set.
The Jamf Pro API’s SET_RECOVERY_LOCK command takes only
newPassword; Jamf Pro supplies the current value from the Recovery Lock password it stores for the device. If Jamf Pro does not hold the current password (for example, one set by another MDM), the device rejects the command, so never set or change a passcode outside Jamf Pro.Before any scheduled run, rotate one Mac that already has a lock and confirm the command reaches Acknowledged and that View Recovery Lock Password returns the new value. Expected result: command status of Acknowledged within one check-in cycle. Evidence to capture: command UUID, timestamp, and status returned by the API, logged to the audit trail.
Mirror the new passcode to the secrets vault. Action: before sending the command, write the new passcode to a separate pending path keyed by serial number; only when the command reaches Acknowledged, copy it to the current path, which in KV version 2 adds a new version and keeps the earlier ones for rollback.
While the command is still Pending, keep the pending entry, because the Mac may yet apply it at its next check-in.
Delete the pending entry only after the command reports an Error status (the Mac kept its old passcode) or after the promoted value has been read back and confirmed, and log each deletion; on failure leave the current path untouched, so the vault never runs ahead of the Mac. Do not set a TTL shorter than the rotation interval.
Expected result: vault entry exists and is retrievable by the break-glass role only. Evidence to capture: vault write confirmation and access policy attached to the entry.
Schedule recurring rotation. Action: run the rotation once a quarter (the schedule below starts a dry run on the first day of every third month, so runs are up to 92 days apart; an approver reviews its device list, then dispatches the live run the same day).
After a technician retrieves a passcode, rotate that one Mac out of cycle: dispatch the workflow below with its serial number in the
serialinput, so the wrapper sends a single command to that serial only, never the fleet batch, and the run still waits for the environment’s approver.Expected result: no passcode remains valid for more than one retrieval event or one quarter (at most 92 days), whichever is shorter. Evidence to capture: scheduler run history and the retrieval-triggered rotation log entry.
Build the scoped retrieval path for L1 technicians. Action: expose a single lookup action in the service desk tool (ServiceNow, Jira Service Management, or similar) that calls the View Recovery Lock Password endpoint using the service account, gated behind a ticket number field and asset tag confirmation. Expected result: technician receives the current passcode only after the ticket reference is logged. Evidence to capture: the webhook payload sent to the SIEM, shown in the sample below.
Confirm command completion before closing the rotation cycle. Action: query command history for any device still Pending after 24 hours; do not mark that device compliant. Expected result: a residual queue of offline devices that rotate on next check-in rather than being silently skipped. Evidence to capture: exception report listing serials, last check-in timestamp, and pending command age.
Following along? Tap a step’s number to tick it off.
#Code: Rotation and Retrieval
Obtain a short-lived bearer token, then issue the SetRecoveryLock command through the Jamf Pro API:
1JAMF_URL="https://yourinstance.jamfcloud.com"
2TOKEN=$(curl -s -X POST "${JAMF_URL}/api/oauth/token" \
3 -H "Content-Type: application/x-www-form-urlencoded" \
4 -d "client_id=${JAMF_CLIENT_ID}&grant_type=client_credentials&client_secret=${JAMF_CLIENT_SECRET}" \
5 | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
6
7MANAGEMENT_ID="REPLACE_WITH_MANAGEMENT_ID" # from the computer's inventory record, not its Jamf Pro ID
8NEW_PASSCODE=$(python3 - <<'PY'
9import secrets, string
10alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits
11alphabet = alphabet.replace('l','').replace('I','').replace('O','').replace('0','')
12print(''.join(secrets.choice(alphabet) for _ in range(14)))
13PY
14)
15
16# jq reads the passcode from the environment, so it never appears in a URL or on a command line.
17export NEW_PASSCODE MANAGEMENT_ID
18jq -n '{clientData:[{managementId:env.MANAGEMENT_ID,clientType:"COMPUTER"}],commandData:{commandType:"SET_RECOVERY_LOCK",newPassword:env.NEW_PASSCODE}}' \
19| curl -s -X POST "${JAMF_URL}/api/v2/mdm/commands" \
20 -H "Content-Type: application/json" --data-binary @- \
21 -H "Authorization: Bearer ${TOKEN}" \
22 -H "Accept: application/json"This is the body the Jamf Pro API reference documents for POST /api/v2/mdm/commands: a clientData array of management IDs with clientType COMPUTER, and a commandData object with commandType SET_RECOVERY_LOCK and newPassword. Expected result on success: an HTTP 201 response identifying the queued command; record its ID in the audit trail. Send it to one test Mac first, and at scale only through the batched, approved wrapper below.
Mirror the passcode to the vault and record a hash-only audit line, so the plaintext never sits in a rotation log:
1import hashlib
2import hvac
3
4def stage_pending(client, serial, new_passcode):
5 # Called before the SetRecoveryLock command is sent.
6 client.secrets.kv.v2.create_or_update_secret(
7 path=f"recovery-lock-pending/{serial}",
8 secret={"passcode": new_passcode},
9 )
10
11def promote_on_ack(client, serial, new_passcode):
12 # Called only after the command status is Acknowledged.
13 client.secrets.kv.v2.create_or_update_secret(
14 path=f"recovery-lock/{serial}",
15 secret={"passcode": new_passcode},
16 )
17 stored = client.secrets.kv.v2.read_secret_version(path=f"recovery-lock/{serial}")
18 if stored["data"]["data"]["passcode"] != new_passcode:
19 raise RuntimeError(f"promotion not confirmed for {serial}; pending entry kept")
20 # Promotion confirmed: only now remove this serial's pending entry.
21 client.secrets.kv.v2.delete_metadata_and_all_versions(
22 path=f"recovery-lock-pending/{serial}"
23 )
24 fingerprint = hashlib.sha256(new_passcode.encode()).hexdigest()[:12]
25 print(f"ROTATED serial={serial} fingerprint={fingerprint} pending=deleted")
26
27def discard_on_error(client, serial):
28 # Called only when the command status is Error, never while it is Pending.
29 client.secrets.kv.v2.delete_metadata_and_all_versions(
30 path=f"recovery-lock-pending/{serial}"
31 )
32 print(f"PENDING_DISCARDED serial={serial} reason=command_error")Every retrieval by a technician emits a webhook to the SIEM so the access is auditable end to end:
1{
2 "event": "recovery_lock_retrieved",
3 "serial_number": "C02XXXXXXXX",
4 "ticket_number": "INC0045213",
5 "technician": "j.osei",
6 "requested_at": "2024-05-14T09:12:31Z",
7 "jamf_computer_id": 1013,
8 "approval_source": "service-desk-portal"
9}Schedule the rotation job and the out-of-cycle trigger with a CI workflow. The job runs in a protected environment with required reviewers, so every run, scheduled or manual, waits for a named approver.
Scheduled runs are always dry runs: a scheduled event carries no workflow inputs, so the workflow forces --dry-run for it rather than trusting an empty dry_run value, and only a manual dispatch with dry_run cleared sends commands. rotate_recovery_lock.py is your own wrapper around the two samples above. Its acceptance criteria:
- With
--dry-run, it lists the devices it would rotate and sends no commands. - With
--serial, it acts on exactly that one Mac, and exits non-zero without sending anything if the serial matches no device or more than one. - Otherwise it sends at most one batch of
--batch-sizedevices at a time and waits for command status before the next batch. - It exits non-zero and sends nothing further once failures in a batch pass
--max-failure-rate. - It follows the vault order above (stage, send, promote only on Acknowledged) and never prints or logs a plaintext passcode.
The runner signs in to Vault with its own short-lived OpenID Connect token through Vault’s JWT auth method, with the Vault role bound to this repository and environment, so no long-lived Vault token is stored as a secret:
1name: recovery-lock-rotation
2on:
3 schedule:
4 - cron: '0 3 1 */3 *'
5 workflow_dispatch:
6 inputs:
7 reason:
8 description: 'Out-of-cycle trigger reason'
9 required: true
10 serial:
11 description: 'Rotate only this serial (after a retrieval)'
12 required: false
13 default: ''
14 dry_run:
15 description: 'List devices only, send no commands'
16 type: boolean
17 default: true
18jobs:
19 rotate:
20 runs-on: ubuntu-latest
21 environment: recovery-lock-production
22 permissions:
23 contents: read
24 id-token: write
25 steps:
26 - name: Checkout
27 uses: actions/checkout@v4
28 - name: Sign in to Vault with the runner OIDC token
29 uses: hashicorp/vault-action@v3
30 with:
31 url: ${{ vars.VAULT_ADDR }}
32 method: jwt
33 role: recovery-lock-rotation
34 exportToken: true
35 - name: Run rotation script
36 env:
37 JAMF_CLIENT_ID: ${{ secrets.JAMF_CLIENT_ID }}
38 JAMF_CLIENT_SECRET: ${{ secrets.JAMF_CLIENT_SECRET }}
39 SERIAL: ${{ inputs.serial }}
40 # A scheduled run has no inputs, so it is always a dry run.
41 run: python3 rotate_recovery_lock.py --batch-size 50 --max-failure-rate 0.05 ${SERIAL:+--serial "$SERIAL"} ${{ (github.event_name == 'schedule' || inputs.dry_run != false) && '--dry-run' || '' }}#Verification and Expected Evidence
- Jamf Pro computer inventory record shows Recovery Lock Enabled = true and a command status of Acknowledged with a timestamp inside the current rotation window.
- Vault entry for the serial number exists, its current version matches the last acknowledged command, and its access log shows only the break-glass role touched it.
- SIEM contains one retrieval event per unlock, each tied to a ticket number; a retrieval with no matching ticket number is itself an alertable finding.
- An extension attribute or custom field reporting days-since-last-rotation stays at or under 92 for every in-scope device; anything higher flags in the compliance dashboard.
- Command history exception report is empty, or every entry on it corresponds to a device confirmed offline for a known reason (loaner in storage, decommissioned, awaiting repair).
#Rollback
If a rotation run causes downstream failures, for example a repair vendor was mid-service and needs the prior passcode reissued, the rollback path is another SetRecoveryLock command, not a manual firmware reset. Reissue the last known-good value stored in the vault’s version history using the same request:
1NEW_PASSCODE="${PREVIOUS_PASSCODE}"
2export NEW_PASSCODE MANAGEMENT_ID
3jq -n '{clientData:[{managementId:env.MANAGEMENT_ID,clientType:"COMPUTER"}],commandData:{commandType:"SET_RECOVERY_LOCK",newPassword:env.NEW_PASSCODE}}' \
4| curl -s -X POST "${JAMF_URL}/api/v2/mdm/commands" \
5 -H "Content-Type: application/json" --data-binary @- \
6 -H "Authorization: Bearer ${TOKEN}" \
7 -H "Accept: application/json"Apple’s SetRecoveryLock reference documents that an empty NewPassword clears Recovery Lock and that the device requires the current password whenever a lock is set.
Jamf’s API reference does not document newPassword accepting an empty string, so do not assume the request above clears the lock: use the clearing option of Jamf Pro’s own Recovery Lock management action as Jamf documents it for your version, or, if you must use the API, prove an empty newPassword on one test Mac first.
Clearing removes firmware-level protection, so treat it as a change, not a fallback: send it to one named device at a time (for example one leaving the fleet or going to a repair provider that requires it), never from the scheduled job, and only with security approval on the ticket.
First confirm the vault holds the device’s current passcode, afterwards check that the inventory record shows Recovery Lock as not enabled, and record the clearance against the serial number in the vault.
#Failure and Escalation Conditions
- A batch shows more than five percent command failures: pause the scheduler, do not proceed to the next batch, and open an L2 investigation into whether the failure is network-side (device offline) or authorisation-side (token or scope issue).
- Recovery Lock reports Enabled = true on a device with no corresponding vault entry: treat this as a security incident, not a sync bug. It indicates the passcode was set outside this pipeline, possibly at the firmware level directly, and should wake an on-call security engineer immediately.
- A retrieval webhook fires without a matching, open ticket number in the service desk system: escalate to L3 security operations for identity review of the technician account used.
- Command status remains Pending for the same device across two consecutive rotation cycles (up to 184 days): escalate to asset management to confirm the device has not been lost, stolen, or silently decommissioned.
#Measuring Ticket Deflection
Baseline the volume of tickets categorised as Recovery Lock unlock request or firmware passcode request for the 90 days before rollout.
After rollout, track three numbers: the count of the same ticket category, the average handle time from ticket open to passcode delivered, and the percentage resolved entirely through the self-service retrieval path versus escalated to a human for manual lookup.
A successful rollout should show the manual lookup path approaching zero, handle time dropping from minutes of ticket archaeology to under a minute of scoped API lookup, and a parallel rise in audit completeness, since every remaining retrieval now carries a ticket number and technician identity rather than a shared spreadsheet lookup.
#References
For the underlying Apple platform behaviour, see Apple’s own deployment guidance on Recovery Lock for Mac computers with Apple silicon and the command reference for the SetRecoveryLock MDM command. For the MDM-side implementation used in this playbook, see Jamf’s documentation on managing Recovery Lock in Jamf Pro.
#Related reading
Evidence trail
Sources and verification
Primary documentation and external technical references used in this article.
About this page
Credited to
Dates
Published
Found this useful? Follow KBY for more like it.
Recommended reading
More from KBY that goes with this article.
Related articles
macOS
Restart FileVault Macs Remotely Without Leaving Them Stuck at the Unlock Screen
Stop FileVault Macs waiting at the unlock screen after a remote restart: use fdesetup authrestart, or SSH unlock on Apple silicon with macOS 26, safely.
ReadmacOS
Replacing Manual Compliance Work with a Verifiable FileVault Workflow
Replace ad hoc FileVault checks with an auditable macOS workflow: personal recovery key rotation with MDM escrow, validation steps and compliance outcomes.
ReadSoftware Architecture
Preventing Lost Updates in REST APIs with ETags, If-Match and 412 Precondition Failed
Use ETags and If-Match to stop concurrent PUT and PATCH requests overwriting each other, make the check atomic, and roll out 412 and 428 in stages.
ReadSecurity
NCSC Says AI Has Taken a Step Change in Offensive Cyber Capability
AISI says two AI models solved its hardest hacking range with no planted flaw. The NCSC wants IT teams to shrink internet exposure and patch in hours.
ReadWas this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Operate smarter, with fewer recurring tickets.
Receive new operational playbooks, incident-prevention guidance, automation scripts and recovery runbooks.


Comments
Add a thoughtful note on Recovery Lock Rotation for Apple Silicon Macs at Scale. Comments are checked for spam and held for moderation before appearing.