System

Keychain Metadata

Overview

The macOS Keychain is the system credential manager, storing passwords, certificates, encryption keys, and secure notes. Modern macOS systems use SQLite-based keychain databases that contain both encrypted secret material and unencrypted metadata about each stored item.

Forensic analysis of keychain metadata (without decrypting secrets) provides substantial investigative value: it reveals what services a user has credentials for, which servers and accounts they access, when credentials were created or modified, and how security is configured through Data Protection classes.

macfor extracts only metadata from keychain databases. It never reads, exports, or decrypts the data column containing actual passwords, private keys, or other secret material. This approach provides forensic value while maintaining responsible handling of sensitive data.

Forensic Significance

Evidence TypeForensic Value
Service names and accountsMaps the user's credential landscape -- email, VPN, Wi-Fi, web services
Server hostnames and protocolsNetwork services accessed, including internal corporate systems
Creation/modification timestampsTimeline of when accounts were established or passwords changed
iCloud sync statusWhether credentials are synced across devices
Tombstone markersSoft-deleted credentials that may still exist in the database
Certificate metadataIdentity certificates, code signing, enterprise trust relationships
Key capabilitiesCryptographic key usage (signing, encryption, Secure Enclave backing)
Protection classesSecurity posture -- when credentials are accessible (device locked vs. unlocked)

Important Note on Secret Values

macfor deliberately excludes the data column from all keychain queries. This column contains the actual encrypted password, key material, or certificate data. The tool extracts labels, account names, service identifiers, timestamps, and configuration metadata only.

File Locations

Per-User Keychains

KeychainPathFormatDescription
Data Protection keychain~/Library/Keychains/{UUID}/keychain-2.dbSQLite + WALPrimary modern keychain (macOS 10.12+)
Login keychain~/Library/Keychains/login.keychain-dbSQLiteTraditional login keychain
iCloud status~/Library/Keychains/accountStatus.plistBinary plistiCloud Keychain enablement state

The {UUID} directory under ~/Library/Keychains/ is a UUID-named subdirectory that contains the Data Protection keychain. Multiple UUID directories may exist; each should be enumerated and collected.

System Keychain

KeychainPathFormatRequires
System keychain/Library/Keychains/System.keychainSQLiteRoot access

The System keychain stores Wi-Fi passwords, VPN credentials, and certificates used by system-level services.

Database Schema

All keychain SQLite databases share the same core table structure.

Tables

TableContentsKey Evidence
genpGeneric passwordsApplication passwords, Wi-Fi, VPN, authentication tokens
inetInternet passwordsWeb credentials with server, protocol, port, path
certCertificatesX.509 certificates with subject, issuer, serial number
keysCryptographic keysKey metadata with class, size, capabilities
tversionSchema versionDatabase version tracking

Generic Passwords (genp table)

ColumnField NameTypeDescription
rowidrowidintRow identifier
cdatcreatedtimeCreation timestamp (Core Data)
mdatmodifiedtimeModification timestamp
labllabelBLOB/stringUser-visible display name
acctaccountBLOB/stringAccount name / username
svceserviceBLOB/stringService name (e.g., "AirPort", app bundle ID)
agrpaccess_groupBLOB/stringApplication entitlement group
pdmnprotection_domainstringData Protection class code
descdescriptionBLOB/stringItem description
icmtcommentBLOB/stringUser comment
crtrcreatorintCreator application code
typeitem_typeintItem type code
inviinvisibleboolHidden from Keychain Access UI
syncsyncbooliCloud Keychain sync enabled
tombtombstoneboolSoft-deleted marker
UUIDuuidstringUnique identifier

The data column (containing the actual password) is never extracted.

Internet Passwords (inet table)

Extends generic passwords with network-specific columns:

ColumnField NameTypeDescription
srvrserverBLOB/stringServer hostname
sdmnsecurity_domainBLOB/stringHTTP authentication realm
ptclprotocol / protocol_rawstring/intProtocol identifier (see Protocol Mapping)
portportintPort number
pathpathBLOB/stringURL path component
atypauth_typeBLOB/stringAuthentication type

Certificates (cert table)

ColumnField NameTypeDescription
ctypcert_typeintCertificate type code
cenccert_encodingintCertificate encoding format
subjsubject_hashBLOBDER-encoded subject (base64 in output)
issrissuer_hashBLOBDER-encoded issuer (base64 in output)
slnrserial_numberBLOBSerial number (base64 in output)
skidsubject_key_idBLOBSubject key identifier
pkhhpublic_key_hashBLOBPublic key hash

Keys (keys table)

ColumnField NameTypeDescription
kclskey_class / key_class_rawstring/intKey class (public=0, private=1, symmetric=2)
typekey_typeintKey algorithm type
bsizkey_size_bitsintKey size in bits
esizeffective_size_bitsintEffective key size
sdatstart_datetimeValidity start date
edatend_datetimeValidity end date
senssensitiveboolSensitive flag
extrextractableboolWhether key can be exported
encrcan_encryptboolEncrypt capability
decrcan_decryptboolDecrypt capability
signcan_signboolSign capability
vrfycan_verifyboolVerify capability
wrapcan_wrapboolWrap (key encryption) capability
unwpcan_unwrapboolUnwrap capability
tkidtoken_idstringSecure Enclave key reference (e.g., com.apple.setoken)

Key Fields for Analysis

BLOB Decoding

Many metadata columns in keychain-2.db are stored as BLOBs containing UTF-8 strings rather than as TEXT values. The decoding strategy is:

  1. Read column as raw bytes.
  2. If utf8.Valid(), convert directly to string.
  3. If not valid UTF-8, encode as base64 for safe representation.

Columns requiring BLOB decoding include: labl, acct, svce, srvr, desc, icmt, sdmn, path, alis, atyp, gena, subj, issr, slnr, skid, pkhh, klbl, atag.

Protocol Mapping

The ptcl column in the inet table stores protocol identifiers as big-endian 4-byte ASCII codes packed into an integer:

ValueASCIIProtocol
0x66747020ftp FTP
0x68747470httpHTTP
0x68747073htpsHTTPS
0x696D6170imapIMAP
0x736D7470smtpSMTP
0x706F7033pop3POP3
0x6C646170ldapLDAP
0x73736820ssh SSH

Unknown protocol codes are represented as hex-formatted strings (e.g., 0x12345678).

Protection Domain Mapping

The pdmn column uses two- or three-letter codes indicating when the item is accessible:

CodeConstantHuman-ReadableWhen Accessible
akkSecAttrAccessibleWhenUnlockedWhenUnlockedOnly when device is unlocked
ckkSecAttrAccessibleAfterFirstUnlockAfterFirstUnlockAfter first unlock until restart
dkkSecAttrAccessibleAlways (deprecated)AlwaysAlways accessible
akukSecAttrAccessibleWhenUnlockedThisDeviceOnlyWhenUnlockedThisDeviceOnlyWhen unlocked, no sync
ckukSecAttrAccessibleAfterFirstUnlockThisDeviceOnlyAfterFirstUnlockThisDeviceOnlyAfter first unlock, no sync
dkukSecAttrAccessibleAlwaysThisDeviceOnly (deprecated)AlwaysThisDeviceOnlyAlways, no sync

Items with ThisDeviceOnly variants are excluded from iCloud Keychain synchronisation.

Key Class Mapping

ValueClassDescription
0publicPublic key (can be freely shared)
1privatePrivate key (should never leave the device)
2symmetricSymmetric encryption key

Timestamps

Keychain timestamps (cdat, mdat, sdat, edat) use Core Data timestamps: seconds since 2001-01-01 00:00:00 UTC.

To convert to Unix epoch:

unix_timestamp = core_data_timestamp + 978307200

Where 978307200 is the number of seconds between 1970-01-01 and 2001-01-01.

Analysis Notes

Credential Landscape Mapping

Generic passwords reveal the applications and services a user has stored credentials for. Common patterns:

Service PatternIndicates
AirPortWi-Fi network credentials
com.apple.*Apple system services
Bundle IDs (e.g., com.example.app)Third-party application credentials
Chrome Safe StorageChrome browser encryption key
application-password:*Application-specific passwords (e.g., Google app passwords)

Internet passwords provide a detailed view of web service access:

PatternIndicates
Corporate domainsEnterprise system access
VPN endpointsRemote access infrastructure
Mail servers (IMAP/SMTP)Email account configuration
SSH serversRemote shell access history

Tombstone Analysis

Soft-deleted items (tomb = 1) remain in the database until they are purged. These represent credentials that the user explicitly deleted but whose metadata persists. The presence of tombstoned credentials for specific services can indicate:

  • Credential rotation (old password deleted, new one created)
  • Account closure
  • Deliberate cleanup of credential evidence

iCloud Keychain Sync

The sync column indicates whether an item is synchronised via iCloud Keychain. Items with sync = 1 exist on all of the user's Apple devices. This is relevant when:

  • Establishing that credentials were accessible from multiple devices
  • Identifying items that are device-specific (ThisDeviceOnly protection class)
  • Understanding the scope of a potential credential compromise

The accountStatus.plist file contains a simple boolean indicating whether iCloud Keychain is enabled for the user account.

Secure Enclave Keys

Keys with a tkid (token ID) value of com.apple.setoken are backed by the Secure Enclave. These keys cannot be exported from the device and include:

  • Passkey credentials (FIDO2/WebAuthn)
  • Touch ID / Face ID authentication keys
  • Apple Pay keys
  • Device attestation keys

Permission Requirements

  • User keychains require the file owner's permissions or root access.
  • System.keychain requires root access.
  • WAL and SHM files should be collected alongside the main database for transaction recovery.
  • On a live system, the keychain database may be locked by securityd.

Version Differences

macOS VersionDifferences
10.15 (Catalina)Baseline. APFS volume split, keychains on Data volume.
11 (Big Sur)Data Protection keychain syncs all content with iCloud Keychain.
12 (Monterey)Passkey support added. sysb column added to tables.
13 (Ventura)pcss, pcsk, pcsi, persistref columns added.
14 (Sonoma)clip, ggrp columns added.
15 (Sequoia)Standalone Passwords app introduced. No schema changes.

The collector handles missing columns gracefully -- newer columns are optional in queries and their absence does not cause errors.

Legacy Keychain Format

Pre-Sierra macOS used a binary .keychain format (not SQLite). These legacy files are out of scope for macfor. If encountered, tools like chainbreaker can parse the legacy binary format.

Tool Support

ToolSupport
macforFull metadata extraction from genp, inet, cert, keys tables; BLOB decoding; protocol/protection mapping; iCloud status
Keychain Access (macOS built-in)GUI keychain viewer (requires user password to view secrets)
security (macOS built-in)Command-line keychain operations
chainbreakerLegacy binary keychain parser and decryptor
DB Browser for SQLiteManual database inspection
AXIOM (Magnet)Commercial keychain analysis
Elcomsoft Phone BreakerCommercial keychain decryption

References

Previous
Unified Logs