From BFU to AFU: How iOS Keychain Controls Credential Access

From BFU to AFU How iOS Keychain Controls Credential Access

In mobile forensics, timing is everything.

Not just when a device was seized, but in what state it was seized. Locked. Unlocked once. Actively in use. Recently rebooted. Each of these states fundamentally changes what data is accessible and what remains cryptographically unreachable.

After understanding iOS Data Protection at the file-system level, the next critical layer to master is iOS Keychain — Apple’s secure credential storage system. For investigators, incident responders, and security professionals, the Keychain often holds the most valuable artifacts: passwords, authentication tokens, encryption keys, and identity material.

But unlike a simple database, the iOS Keychain is governed by a strict class-based accessibility model that directly ties cryptographic access to the device’s lock state and the Secure Enclave.

This blog breaks down how iOS Keychain works from a BFU (Before First Unlock) to AFU (After First Unlock) perspective, why certain credentials are accessible while others are not, and how this knowledge impacts real-world forensic acquisitions.

Why iOS Keychain Matters in Mobile Forensics

Modern iOS devices do not store credentials in plain text. Apple designed the Keychain to protect secrets even if an attacker gains physical access to the device or extracts raw storage.

From a forensic standpoint, this means:

  • You may acquire the entire filesystem, yet still be unable to decrypt critical credentials.
  • Two acquisitions of the same device can yield dramatically different results depending on lock state.
  • Some secrets are never recoverable, even with full backups or iCloud access.

Keychain artifacts often include:

  • Wi-Fi passwords
  • Email and Exchange credentials
  • VPN secrets
  • Social media access tokens
  • Safari passwords
  • iMessage encryption keys
  • iCloud authentication material
  • System identity certificates

Understanding when these secrets become available is more important than understanding where they are stored.

Keychain vs File Data Protection: Similar but Not Identical

Apple uses class-based protection for both files and Keychain items, but the two systems behave differently.

File Data Protection controls access to files stored on disk. Once a device transitions from BFU to AFU, many file classes become readable.

Keychain, however, is more granular and more restrictive.

Key differences include:

  • Keychain items are individually encrypted.
  • Accessibility is defined per credential, not per directory.
  • Some items are device-bound and non-migratory.
  • Some items are deliberately excluded from backups and escrow mechanisms.

Most importantly, Keychain access is enforced by the Secure Enclave, not the operating system kernel.

This makes Keychain protections significantly harder to bypass.

The Role of the Secure Enclave

At the core of iOS credential security is the Secure Enclave Processor (SEP).

The Secure Enclave:

  • Manages passcode verification
  • Derives encryption keys
  • Enforces Keychain access rules
  • Prevents brute-force attempts
  • Is isolated from iOS itself

Even if an attacker or forensic tool gains kernel-level access, the Secure Enclave still controls whether a Keychain item can be decrypted.

This architecture ensures that cryptographic access is state-aware, not privilege-aware.

In simple terms:

Having full system access does not guarantee access to secrets.

Understanding BFU and AFU States

Before diving into Keychain classes, it is essential to understand device states.

BFU — Before First Unlock

  • Device has been powered on or rebooted.
  • User has not entered the passcode.
  • Secure Enclave has not released class keys tied to the passcode.

This is the most restrictive state.

AFU — After First Unlock

  • User has entered the passcode at least once.
  • Class keys derived from the passcode are now available.
  • Some data remains inaccessible until the device is actively unlocked.

Most forensic extractions aim to reach or preserve AFU state because it unlocks significantly more data.

Keychain Accessibility Classes Explained

Each Keychain item is assigned an accessibility class that dictates when it can be decrypted.

These classes define the real boundary between accessible evidence and cryptographic dead ends.

1. Always Accessible Keychain Items

What This Class Means

Items in this class are available even in BFU state, immediately after boot.

They do not require the device to be unlocked.

Why Apple Allows This

Some system services must function before user interaction:

  • Cellular connectivity
  • Push notifications
  • Bluetooth pairing
  • Device tracking

Without these items, core iOS functionality would break.

Typical Artifacts in This Class

  • Bluetooth pairing keys
  • APNs (Apple Push Notification Service) tokens
  • iCloud identity certificates
  • Private system keys
  • SIM PIN
  • Find My tokens
  • Voicemail credentials

Forensic Implications

  • These are often the only credentials available in BFU.
  • Many are non-migratory, meaning they cannot be restored to another device.
  • Useful for device attribution, service linkage, and system behavior analysis.
  • Rarely useful for direct account takeover.

This class offers context, not control.

2. After First Unlock (AFU) Keychain Items

What This Class Means

Items become accessible once the user unlocks the device after boot.

After that, they remain accessible — even if the device is later locked.

This is the most valuable class for forensic investigations.

Common Artifacts

  • Wi-Fi passwords
  • Mail and Exchange credentials
  • VPN secrets
  • LDAP, CardDAV, and CalDAV credentials
  • Social media access tokens
  • Handoff encryption keys
  • iCloud authentication tokens
  • iMessage encryption keys
  • VPN certificates (often non-migratory)

Why This Class Exists

Apple balances usability and security here. Users should not need to re-enter passwords every time the screen locks, but credentials should still be protected after a reboot.

Forensic Implications

  • AFU acquisition is critical to access these items.
  • Tokens may allow:
  • Session hijacking
  • Cloud data access
  • Account correlation
  • iMessage keys can be particularly valuable in timeline reconstruction.
  • Loss of AFU state (battery drain or reboot) can permanently eliminate access.

For investigators, this class often determines whether an extraction is useful or useless.

3. When Unlocked Keychain Items

What This Class Means

Items are accessible only while the device is actively unlocked.

Once the screen locks, access is revoked immediately.

Common Artifacts

  • Safari saved passwords
  • Safari bookmarks
  • Home Sharing credentials
  • Finder / iTunes backup passwords

Security Rationale

These items protect highly sensitive personal data and financial credentials. Apple intentionally restricts background access.

Forensic Implications

  • Requires live device interaction.
  • Automated extraction tools may fail if the device locks mid-process.
  • Screen timeout settings can impact success.
  • Often missed in unattended acquisitions.

This class rewards operational discipline during seizures.

4. Passcode Enabled — Device Only (ThisDeviceOnly)

What This Class Means

These items behave like When Unlocked but with additional restrictions:

  • Not included in backups
  • Not synced to iCloud
  • Not escrowed
  • Permanently destroyed if the passcode is removed

Typical Use Cases

  • Banking credentials
  • Enterprise secrets
  • Highly sensitive application data
  • Corporate MDM-protected items

Forensic Implications

  • Cannot be recovered from backups.
  • Cannot be migrated to another device.
  • Once lost, cryptographically unrecoverable.
  • Strong indicator of high-security application usage.

This class represents Apple’s strongest consumer-grade data protection.

Non-Migratory Keychain Items Explained

Some Keychain items are marked as non-migratory, meaning:

  • They cannot be restored to another device.
  • They are bound to the Secure Enclave of that specific device.
  • Even iCloud backups may exclude them.

From a forensic standpoint, this means:

  • Device seizure is mandatory.
  • Cloud-only investigations may fail.
  • Hardware loss equals evidence loss.

Why Forensic Tools Cannot “Just Decrypt Everything”

A common misconception is that advanced forensic tools can bypass iOS security.

In reality:

  • Keychain decryption keys are derived inside the Secure Enclave.
  • SEP enforces lock-state conditions.
  • No software exploit can override cryptographic policy without SEP cooperation.
  • Apple’s design intentionally limits post-compromise access.

Forensic success depends less on tooling and more on timing, state preservation, and operational handling.

Practical Acquisition Strategy for Investigators

To maximize Keychain access:

  1. Avoid rebooting the device
  2. Maintain AFU state
  3. Prevent battery drain
  4. Disable auto-lock where legally permitted
  5. Use Faraday protection carefully to avoid power loss
  6. Prioritize live logical acquisition when unlocked
  7. Document lock state precisely

The difference between BFU and AFU can be the difference between metadata only and full credential visibility.

Why This Knowledge Matters Beyond Forensics

Understanding iOS Keychain is not only valuable for investigators.

It also informs:

  • Mobile app security design
  • Red-team mobile attack simulations
  • Incident response scoping
  • Lawful access policy debates
  • Privacy engineering

Apple’s Keychain model demonstrates how cryptography can enforce policy, not just confidentiality.

Conclusion: Access Is a State, Not a Permission

iOS Keychain is not about who you are or what privileges you have.
It is about when you access the device.

From BFU to AFU, from locked to unlocked, each transition unlocks — or permanently seals — entire categories of credentials.

For mobile forensics professionals, this means:

  • Understanding the Keychain model is non-negotiable.
  • Timing and handling matter more than exploits.
  • Some secrets are designed to remain secret forever.

In Apple’s ecosystem, cryptography does not negotiate.

And in modern investigations, knowing what will never be accessible is just as important as knowing what is.

About the Author

You may also like these