Authentication -------------- Most API interactions are secured using mTLS connections. By default there are two CAs involved, but the components can be configured to accommodate more complex setups. (The revocation process also uses a CA, but this is different to those CAs) In push mode, the PoP (Proof of Possession) authentication is mandatory for requests by agents for attestation operations. **Security Note**: Never distribute client certificates signed by the verifier's trusted CA to agents. In push-attestation, agents should only authenticate using PoP tokens. In pull-model, agent should use its self-signed server certificate. If an agent had a valid client certificate AND didn't send an Authorization header, they would be identified as an admin by the verifier. Server Components CA ~~~~~~~~~~~~~~~~~~~~ This CA is created by verifier on startup. It contains the server certificates and keys used by the verifier and registrar for their respective HTTPS interfaces. Then it also contains the client certificates and keys that are used by the tenant to connect to the registrar, verifier and agent. Also the verifier uses that certificate to authenticate itself against the agent. Agent Keylime CA ~~~~~~~~~~~~~~~~ The agent runs an HTTPS server and provides its certificate to the registrar (:code:`mtls_cert`). The server component CA certificate is also required on the agent to authenticate connections from the tenant and verifier. By default :code:`/var/lib/keylime/cv_ca/cacert.crt` is used. Authorization Framework ----------------------- Starting from version 7.14.0 (API version 2.5), Keylime implements a pluggable authorization framework to control access to API operations. The framework separates authentication (proving identity) from authorization (permission to perform actions). Overview ~~~~~~~~ Keylime's authorization framework is pluggable, allowing different authorization providers to implement various access control policies. Each provider can define its own rules for determining which identities can perform which operations. Authorization Providers ~~~~~~~~~~~~~~~~~~~~~~~ The authorization provider is configured separately for each component: **Verifier Configuration** .. code-block:: ini [verifier] authorization_provider = simple **Registrar Configuration** .. code-block:: ini [registrar] authorization_provider = simple **Available Providers** * ``simple`` (default): Role-based access control with strict separation between agent and admin authentication methods Future providers may include LDAP, OPA (Open Policy Agent), or custom implementations for enterprise deployments requiring fine-grained RBAC. SimpleAuthProvider ~~~~~~~~~~~~~~~~~~ The ``simple`` provider is the default authorization provider. It classifies operations into four categories: * **Public operations**: No authentication required * Version information (``GET /versions``) * Server information (``GET /``) * Identity verification (``GET /verify/identity``) * Evidence verification (``POST /verify/evidence``) * Session creation for push attestation (``POST /sessions``) * Session update/extend (``PATCH /sessions/:session_id``) * **Agent-only operations**: Requires PoP bearer token authentication * Agents can only access their own resources (identity must match resource) * Submit attestations (``POST /agents/:agent_id/attestations``) * **Agent-or-admin operations**: Accessible by both roles with different scopes * ``GET /agents/:agent_id`` - Agents can read own status only, admins can read any agent * **Admin operations**: Requires mTLS client certificate authentication * Full access to all management operations * Create/delete/update agents * Manage IMA and UEFI policies * View attestation results for any agent The ``simple`` provider implements strict separation between agent and admin authentication methods: **Authentication Method Separation** .. list-table:: :header-rows: 1 :widths: 30 35 35 * - Authorization Header - Authentication Path - Identity Type * - Present (Bearer token) - Agent path - ``agent`` or ``anonymous`` * - Absent - Admin path (mTLS) - ``admin`` or ``anonymous`` **Critical Security Rule**: If an ``Authorization`` header is present in a request, the request is **always** treated as an agent authentication attempt. There is **no fallback** to mTLS authentication. This prevents privilege escalation attacks where an attacker might send an invalid bearer token while having a valid mTLS certificate. **Authorization Rules** 1. **Public actions**: Always allowed regardless of identity 2. **Agent-only actions**: Requires ``identity_type == "agent"`` AND ``identity == resource`` 3. **Agent-or-admin actions**: Agent with ``identity == resource`` OR admin 4. **Admin actions**: Requires ``identity_type == "admin"`` Certificate Requirements ~~~~~~~~~~~~~~~~~~~~~~~~ The security model relies on proper certificate management: .. list-table:: :header-rows: 1 :widths: 25 25 50 * - Role - Authentication - Certificate Requirements * - Agent (pull mode) - N/A (agent is server) - Self-signed server cert acceptable. If CA-issued, must have Server Auth EKU only. * - Agent (push mode) - PoP bearer token - No client certs from trusted CA. Use PoP tokens only. * - Admin/Tenant - mTLS client cert - Signed by verifier's trusted CA with Client Auth EKU. **Security Note**: Never distribute client certificates signed by the verifier's trusted CA to agents. Agents should only authenticate using PoP tokens. If an agent had a valid client certificate AND didn't send an Authorization header, they would be identified as an admin. **Pull Mode Agent Certificates** Pull mode agents act as servers (the verifier connects to them). Their certificates have no security relevance for authorization because: 1. Trust is established via TPM quote, not the certificate 2. The agent's certificate is added to the verifier's client-side trust store only for that specific connection 3. The agent never connects to the verifier as a client Self-signed certificates are acceptable for pull mode agents. If the pull mode agent certificate is issued by the trusted CA (instead of self-signed), it **must have the Server Authentication EKU** (OID 1.3.6.1.5.5.7.3.1). This prevents the certificate from being used for client authentication, which would grant admin access. Default Configuration (Development/Testing) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When the verifier is configured with ``tls_dir = generate``, it automatically creates: * A Certificate Authority (CA) * Server certificates for the verifier * **Client certificates for admin operations** The automatically generated client certificate has: * **Common Name (CN)**: ``client`` * **Location**: ``/var/lib/keylime/cv_ca/client-cert.crt`` * **Private Key**: ``/var/lib/keylime/cv_ca/client-private.pem`` The tenant tool (used for admin operations) is configured to use this certificate by default: .. code-block:: ini [tenant] tls_dir = default client_cert = default # Uses /var/lib/keylime/cv_ca/client-cert.crt client_key = default # Uses /var/lib/keylime/cv_ca/client-private.pem **What This Means** With default configuration: * The verifier automatically generates all necessary certificates on startup * The tenant tool automatically uses the generated client certificate * Admin operations work **out-of-the-box** without manual certificate management * This setup is suitable for **development, testing, and single-admin deployments** Production Configuration (Multi-Admin Deployments) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For production deployments with multiple administrators, you should generate unique certificates for each administrator. Step 1: Generate Admin Certificates ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For each administrator, generate a unique certificate: .. code-block:: bash # Generate certificate for admin1 keylime_ca -d /var/lib/keylime/cv_ca create -n admin1.example.com # Generate certificate for admin2 keylime_ca -d /var/lib/keylime/cv_ca create -n admin2.example.com Step 2: Package and Distribute Certificates ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Create certificate packages for distribution: .. code-block:: bash # Create package for admin1 keylime_ca -d /var/lib/keylime/cv_ca pkg -n admin1.example.com # This creates: admin1.example.com-pkg.zip Distribute the certificate package securely to each administrator (encrypted email, secure file transfer, etc.). Step 3: Configure Tenant Tool ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Each administrator should extract their certificate package and configure the tenant tool: .. code-block:: bash # Extract certificate package unzip admin1.example.com-pkg.zip -d ~/keylime-certs/ # Configure tenant tool cat > ~/.keylime/tenant.conf <