After completing this chapter, you will understand:
Capability-Based Access Control: Fine-grained permissions beyond simple role hierarchies
Capability Flags: Using bit operations for efficient permission checking
User Profiles and Resource Definitions: Structuring access control data
Session and Token Structures: Managing time-limited access credentials
Attribute-Based Decisions: Access decisions based on context (time, location, device state)
For Beginners: Capability-Based Access Control
Access control determines what each user or device is allowed to do in an IoT system. Think of a hospital where doctors, nurses, and visitors each have different access levels – doctors can prescribe medication, nurses can administer it, and visitors can only visit patients. Similarly, IoT access control ensures each device and user can only perform actions appropriate to their role.
Sensor Squad: The Permission Puzzle!
“Regular roles like Admin and User are good, but sometimes we need finer control,” Max the Microcontroller explained. “Capability-based access control is like giving each person a custom key ring instead of just a badge. One key opens the temperature data door, another key opens the actuator control door, and another opens the settings door.”
Sammy the Sensor demonstrated. “Instead of saying ‘Sammy is a User and can do everything Users do,’ we say ‘Sammy can READ temperature data, WRITE to the alarm system, but CANNOT modify settings or add new devices.’ Each permission is a separate capability flag – either on or off, like tiny light switches.”
“These capability flags are stored as bits,” Lila the LED added. “Bit 0 might mean READ_SENSOR, bit 1 means WRITE_ACTUATOR, bit 2 means ADMIN_SETTINGS. We can check permissions super fast by looking at individual bits – perfect for tiny microcontrollers that need to decide in microseconds whether to allow an action.”
“Tokens have expiration times too, like a movie ticket that is only valid for one showing,” Bella the Battery explained. “Your access token might be valid for one hour. When it expires, you need to refresh it. And if something goes wrong – like a device gets stolen – the administrator can revoke that specific token immediately without affecting anyone else!”
13.2 Introduction to Capability-Based Access Control
Traditional role-based access control (RBAC) assigns users to roles like “admin” or “user” with predefined permissions. Capability-based access control (CBAC) provides finer granularity by treating permissions as individual capabilities that can be combined.
13.2.1 Why Capabilities Matter in IoT
IoT systems often need nuanced permission models:
Scenario
RBAC Limitation
CBAC Solution
Operator can read all sensors but write only temperature config
Need separate roles for each sensor type
Single user with READ + WRITE_TEMP capabilities
Maintenance window allows firmware updates only 2-6 AM
Hard to express in static roles
Time-restricted FIRMWARE_UPDATE capability
Emergency override needs dual authorization
Roles don’t support multi-user approval
EMERGENCY capability requires separation of duties
13.3 Capability Flags System
Capabilities are implemented as bit flags, enabling efficient bitwise operations for permission checking.
Use this interactive tool to experiment with capability bit flags. Toggle individual capabilities for a user, then set the required capabilities for a resource, and see whether access is granted or denied.
Tokens encapsulate granted capabilities with lifecycle metadata:
// ============== ACCESS TOKEN STRUCTURE ==============struct AccessToken {uint32_t tokenId;// Unique token identifierchar userId[16];// Associated user IDuint16_t capabilities;// Granted capabilities (bit flags)unsignedlong issuedAt;// Token creation timestampunsignedlong expiresAt;// Token expiration timestampunsignedlong lastActivity;// Last use timestampuint8_t refreshCount;// Number of times refreshedbool isRevoked;// Revocation statusuint32_t sessionId;// Associated sessionchar issuedBy[16];// Who issued this token};
13.4.2 User Profile Structure
User profiles define base and maximum capabilities:
// ============== USER PROFILE STRUCTURE ==============struct UserProfile {constchar* userId;constchar* userName;uint16_t baseCapabilities;// Default capabilitiesuint16_t maxCapabilities;// Maximum allowed capabilitiesbool canElevate;// Can request elevated privilegesuint8_t maxConcurrentSessions;uint32_t maxSessionDuration;// Maximum session length (ms)bool requiresMFA;// Multi-factor auth required};
Key fields: - baseCapabilities: Capabilities granted on login - maxCapabilities: Maximum capabilities user can ever have (even with elevation) - canElevate: Whether user can request temporary elevated privileges
Notice how: - Firmware Update requires multiple capabilities AND time restriction (2-6 AM maintenance window) - System Logs are restricted to business hours (8 AM - 6 PM) - Emergency Override is always available but requires special capability
Try It: User-to-Resource Access Matrix
Select a user profile from the database above and a simulated hour of day to see which protected resources they can access. The matrix shows how capability flags and time restrictions combine to determine access.
Show code
viewof selectedUser = Inputs.select( ["SU001 - SuperAdmin","AD001 - Alice Admin","OP001 - Bob Operator","US001 - Charlie User","GU001 - Diana Guest","SV001 - ServiceAccount"], {value:"OP001 - Bob Operator",label:"User Profile"})
Security timing is critical for session management. These constants balance security against usability: shorter lifetimes reduce the window for token theft exploitation, while longer timeouts reduce user friction. In resource-constrained IoT environments, these values are typically configured more aggressively (shorter) than in web applications because compromised devices may operate unattended.
Adjust the timing constants to see how token lifetime, session idle timeout, and elevation duration interact in a visual timeline. Observe how shorter lifetimes improve security but increase refresh overhead.
13.8 Case Study: Tesla Vehicle Access Control Evolution (2012-2023)
Tesla’s approach to vehicle access control illustrates how capability-based systems evolve in response to real-world attacks, and why fine-grained permissions matter more than simple role hierarchies.
Phase 1: Simple Key Fob (2012-2017)
Tesla Model S launched with a traditional key fob using 40-bit encryption. Access was binary: have the fob, control the car.
Attack
Year
Method
Impact
Relay attack
2016
Amplify fob signal from inside house to car in driveway
Full vehicle access in 10 seconds
Key cloning
2018
Crack 40-bit encryption in 2 seconds using $600 equipment
Tesla service: SERVICE | CLIMATE | CHARGE = 0x26 (diagnostics, no driving)
Teen driver: DRIVE | CLIMATE | CHARGE | SPEED_LIMIT = 0x47 (drive with speed limit)
Security Metrics:
Relay attacks reduced 93% after switching from RF fob to BLE phone key with ranging
Unauthorized access incidents dropped from 112 per month (2017) to 8 per month (2022) across the fleet
Amazon Key delivery integration: 4.2 million secure trunk deliveries in 2022 with zero reported vehicle thefts
Valet mode prevented 340+ reported speed-limit violations per month
Key Lesson: Binary access (have key = full control) creates a single point of failure. Capability-based access control enables use cases that are impossible with role-based systems: a delivery driver who can open the trunk but cannot drive the car, or a teenager who can drive but not exceed 70 mph. Each capability is independently grantable and revocable, and compromising one capability (e.g., the TRUNK token) does not expose others.
Try It: Tesla Capability Composer
Build custom capability profiles for Tesla vehicle access. Toggle individual capabilities on and off to see the resulting hex value and compare it against predefined profiles like Owner, Valet, and Delivery.
Worked Example: Industrial SCADA System Capability Assignment
A water treatment plant uses capability-based access control for 150 operators across 3 shifts. Each operator needs different access depending on their certification level and current shift responsibilities.
Production Benefit: When Alice transferred to night shift, IT updated her base capabilities to exclude PUMP_CONTROL (night shift policy) without creating a new role. Traditional RBAC would have required “DayShiftLevel3” and “NightShiftLevel3” roles.
Decision Framework: RBAC vs Capability-Based Access vs ABAC
Scenario
RBAC (Roles)
Capability Flags
ABAC (Attributes)
Best Choice
10 users, 3 roles, static permissions
Simple (Admin, User, Guest)
Overkill
Overkill
RBAC
100 users, many permission combinations
Role explosion (50+ roles)
Custom per-user capability sets
Policy rules
Capability-based
Time/location restrictions
Can’t express
Can express with time-restricted tokens
Native support
ABAC
Temporary privilege elevation
Role switching (messy audit)
Elevate specific capabilities
Policy with context
Capability-based
Compliance requirements (SOX, HIPAA)
Adequate if roles map to compliance needs
Better granularity for audit
Best (policy as code)
ABAC
Quick Decision:
<20 permission types + role hierarchy works → RBAC (simplest)
Need per-user customization without role explosion → Capability-based
Need context-aware decisions (time/location/device state) → ABAC
Embedded systems with RAM constraints → Capability-based (bit flags = minimal memory)
Common Mistake: Storing Capability Flags in Client Tokens
What practitioners do wrong: They embed capability bit flags directly in JWT tokens or session cookies sent to clients, assuming encryption/signing protects them.
Why it fails: While HMAC signatures prevent modification, capability flags in tokens reveal your permission model. Attackers can: 1. Enumerate permissions by analyzing token structure across users 2. Attempt privilege escalation by crafting tokens if the signing key leaks 3. Exploit token expiration gaps — if a user’s capabilities are revoked server-side, their client token remains valid until expiration
Correct approach:
Server-side session storage: Token contains only a session ID; actual capabilities stored in server memory/database
Session validation: Every request looks up current capabilities from server (not token)
Short token lifetimes: 5-15 minutes max, forcing frequent refresh that checks current permissions
Token revocation list: Ability to instantly invalidate specific tokens server-side
Real-world consequence: In 2020, an enterprise IoT platform stored capability flags in JWTs with 24-hour expiration. When an admin account was compromised, it took 24 hours to revoke admin access because the attacker’s stolen token remained valid. Post-incident fix: session IDs in tokens (opaque to client), server-side capability lookup, 5-minute token expiration.
Try It: Token Revocation Delay Simulator
Explore the real-world impact of token lifetime on security incidents. Set the token expiration time and see how long an attacker retains access after their token is stolen, comparing server-side vs client-side capability storage.
Key Insight: Capability-based access extends RBAC by treating permissions as composable units rather than monolithic roles, enabling precise “least privilege” enforcement.
Putting Numbers to It: Capability Bit Flags and Permission Spaces
A capability-based access control system with \(n\) distinct permissions creates a permission space of \(2^n\) unique capability combinations, where each combination is a subset of the power set \(\mathcal{P}(\text{Permissions})\).
\[|\text{Capability Space}| = 2^n\]
Working through an example:
Given: An IoT system with 12 capability flags (as shown in this chapter)
Step 1: Calculate total possible capability combinations
Result: With 12 permission bits, 100 users have a 70.5% chance of sharing at least one identical capability set, demonstrating why capability systems need sufficient bit width for unique per-user assignments.
In practice: Each additional permission bit doubles the capability space. Moving from 8 bits (256 combinations) to 16 bits (65,536 combinations) dramatically reduces collision probability while requiring only 1 extra byte of storage. For large IoT deployments (10,000+ devices), 16-bit or 32-bit capability flags prevent accidental permission overlaps and enable fine-grained per-device customization.
13.9.1 Try It: Capability Space & Collision Probability Calculator
Adjust the number of permission bits and users to see how the capability space grows and how collision probability changes.
Show code
viewof numBits = Inputs.range([4,32], {value:12,step:1,label:"Number of permission bits (n)"})
Show code
viewof numUsers = Inputs.range([10,10000], {value:100,step:10,label:"Number of users/devices (k)"})
AWS IAM Policies use attribute-based access control similar to capability flags
Linux capabilities (CAP_NET_ADMIN, CAP_SYS_ADMIN) use bit-flag permissions
Kubernetes RBAC combines role bindings with resource-level permissions
Key Concepts
Capability: An unforgeable, transferable token that grants specific rights to perform an action on a specific object; more fine-grained than role-based access
Least Privilege: The principle that every component should have only the minimum permissions required to perform its function; fundamental to IoT security
Linux Capabilities: A POSIX mechanism that splits superuser privileges into ~40 distinct capabilities (CAP_NET_ADMIN, CAP_SYS_ADMIN) that can be independently granted or dropped
Kubernetes RBAC: Role-Based Access Control in Kubernetes using Roles, ClusterRoles, RoleBindings, and ClusterRoleBindings to control which service accounts can access which API resources
Ambient Capabilities: Linux capabilities that are automatically inherited by child processes without explicit privilege; must be carefully managed in container environments
Capability Delegation: The ability to pass a capability (or a subset of it) to another principal; enables decentralized access control without a central authority
Confused Deputy Problem: A security vulnerability where a privileged program is tricked by a less-privileged client into misusing its authority on the client’s behalf
In 60 Seconds
Capability-based access control grants fine-grained permissions (read file X, send on port Y) as portable tokens rather than per-user ACLs, enabling least-privilege IoT device permissions where each device can only perform exactly the actions required for its specific function.
13.12 Knowledge Check
Quiz: Capability-Based Access Control
Common Pitfalls
1. Granting CAP_SYS_ADMIN to Containers
CAP_SYS_ADMIN is effectively equivalent to root — it allows mounting filesystems, modifying kernel settings, and bypassing many security mechanisms. Containers needing specific capabilities (e.g., network configuration) should request only the specific capability (CAP_NET_ADMIN), never CAP_SYS_ADMIN.
2. Implementing Capabilities as Simple Strings Without Cryptographic Binding
Storing capability tokens as plain strings (e.g., “device:001:read:temp”) that clients can forge or modify breaks the security model. Capability tokens must be cryptographically signed (JWT or HMAC) so the server can verify they were issued by an authorized party.
3. Not Implementing Capability Revocation
Capability systems are weaker than ACL systems if there is no revocation mechanism. A compromised IoT device holding valid capability tokens can continue operating even after compromise is detected. Always maintain a revocation list or use short-lived tokens with expiry.
4. Over-Scoping Kubernetes RBAC Roles with Wildcards
Kubernetes RBAC roles with wildcard resources (“”) or verbs (””) grant broad access that defeats least-privilege. Define specific resource names and verb lists ([“get”, “list”] not [“*”]) for each role, and audit role bindings regularly.