|
| 1 | +# Security Policy |
| 2 | + |
| 3 | +The Private Key Agent keeps private keys out of the applications that use them. To stay small, it |
| 4 | +deliberately leaves transport encryption, secret lifecycle and abuse protection to the environment it |
| 5 | +runs in. On its own, the agent is not safe to expose to an untrusted network. This document lists |
| 6 | +what your environment must provide, the design decisions behind that, and how to report a |
| 7 | +vulnerability. |
| 8 | + |
| 9 | +A bearer token is as powerful as the private keys it unlocks: whoever holds a client's token can sign |
| 10 | +and decrypt with every key that client may use, for as long as the token is configured. Most of the |
| 11 | +requirements below exist to keep tokens from leaking. |
| 12 | + |
| 13 | +## Required deployment environment |
| 14 | + |
| 15 | +Do not run the agent outside local development until your environment provides all of the following. |
| 16 | + |
| 17 | +1. **A private network path.** Only the services that consume the agent can reach its port: the same |
| 18 | + host (loopback), a private network, or a network policy that allows nothing else. |
| 19 | +2. **TLS whenever traffic leaves the host.** Terminate TLS in a reverse proxy, ingress or service-mesh |
| 20 | + sidecar in front of the agent, and keep the hop from proxy to agent on the same host or a private |
| 21 | + network. Mutual TLS between consumer and proxy adds a second factor on top of the bearer token. |
| 22 | +3. **Strong, separate tokens.** At least 256 bits of randomness (for example `openssl rand -hex 32`), |
| 23 | + one token per consuming service, never reused across environments. |
| 24 | +4. **Protected configuration and key files.** The configuration file holds tokens in plaintext and the |
| 25 | + key files hold unencrypted private keys. Make both readable only by the agent's service user, and |
| 26 | + deliver them through a secrets manager (Docker or Kubernetes secrets, Vault) rather than baking them |
| 27 | + into images or committing them. |
| 28 | +5. **A token rotation procedure.** Rotate on a fixed schedule, and immediately when a token may have |
| 29 | + leaked or a consuming service is retired. See [Rotating a token](#rotating-a-token). |
| 30 | +6. **Rate limiting and request size limits** in the proxy, WAF or ingress in front of the agent. |
| 31 | +7. **Restricted health endpoints.** Expose `/v1/health` and `/v1/health/key/{key_name}` only to your |
| 32 | + monitoring and orchestration. |
| 33 | +8. **Up-to-date dependencies.** Rebuild the image regularly so Symfony and base-image security fixes |
| 34 | + are picked up. `composer audit` lists known advisories. |
| 35 | +9. **Log monitoring.** Alert on repeated invalid-token and access-denied warnings; they point to token |
| 36 | + guessing or a misconfigured consumer. |
| 37 | + |
| 38 | +## Design decisions and known limitations |
| 39 | + |
| 40 | +These are deliberate choices to keep the agent small. Each one moves a responsibility to the |
| 41 | +environment described above. |
| 42 | + |
| 43 | +### Plain HTTP, no TLS |
| 44 | + |
| 45 | +The Docker image serves the API over plain HTTP on port 80, and `compose.yaml` publishes that port on |
| 46 | +all host interfaces for local development. Bearer tokens travel in the `Authorization` header and |
| 47 | +decrypted session keys travel in the response body. Anyone who can observe this traffic can steal a |
| 48 | +token, and can read the session keys that protect encrypted SAML assertions. |
| 49 | + |
| 50 | +TLS is left out of the agent because the proxy, ingress or mesh in front of a service already manages |
| 51 | +certificates, renewal and cipher policy, and does it better than a per-application setup would. |
| 52 | + |
| 53 | +The Private Key Agent backends for `simplesamlphp/xml-security` require `https://` and allow plain |
| 54 | +HTTP only to a loopback address, and only when explicitly enabled. Other clients, including `curl`, |
| 55 | +the scripts in `tools/` and custom integrations, have no such guard. |
| 56 | + |
| 57 | +Covered by requirements 1 and 2. |
| 58 | + |
| 59 | +### Static bearer tokens |
| 60 | + |
| 61 | +Clients authenticate with a pre-shared token from the configuration file. Tokens: |
| 62 | + |
| 63 | +- never expire and are not rotated automatically; |
| 64 | +- stay valid until they are removed from the configuration and the agent is restarted; |
| 65 | +- are stored in plaintext in the configuration file; |
| 66 | +- are checked for a minimum length of 32 characters, not for randomness. |
| 67 | + |
| 68 | +A leaked token therefore lets an attacker sign and decrypt with that client's keys until an operator |
| 69 | +replaces it. The agent has no token endpoint, expiry or revocation list, because each would add state, |
| 70 | +dependencies and attack surface to a service whose only job is to guard keys. Tokens are compared in |
| 71 | +constant time and are never logged. |
| 72 | + |
| 73 | +Covered by requirements 3, 4, 5 and 9. |
| 74 | + |
| 75 | +#### Rotating a token |
| 76 | + |
| 77 | +Each client entry has exactly one token, so rotate by running the old and new token side by side: |
| 78 | + |
| 79 | +1. Add a second client entry with a new `name`, a new `token` and the same `allowed_keys`. |
| 80 | +2. Restart the agent so it loads the new configuration. |
| 81 | +3. Switch the consuming service to the new token. |
| 82 | +4. Remove the old client entry and restart the agent again. |
| 83 | + |
| 84 | +To revoke a token immediately, remove its client entry and restart the agent. |
| 85 | + |
| 86 | +### No rate limiting or request size limits in the application |
| 87 | + |
| 88 | +The agent answers every request: an invalid token always gets `401`, never `429`. With 256-bit tokens, |
| 89 | +brute force is infeasible at any request rate, and throttling belongs in the layer that already sees |
| 90 | +all traffic. The bundled Apache configuration limits request bodies to 64 KB. |
| 91 | + |
| 92 | +Covered by requirement 6. |
| 93 | + |
| 94 | +### Unauthenticated health endpoints |
| 95 | + |
| 96 | +`/v1/health` and `/v1/health/key/{key_name}` need no token, so orchestrators and load balancers can |
| 97 | +probe them. They reveal which key names exist and whether each key is healthy. |
| 98 | + |
| 99 | +Covered by requirement 7. |
| 100 | + |
| 101 | +### Descriptive validation errors |
| 102 | + |
| 103 | +When an authenticated request is malformed, the `400` response says what is wrong, for example that |
| 104 | +the hash length does not match the algorithm or that the ciphertext length does not match the key |
| 105 | +size. This helps integrators, and none of it is secret: expected hash lengths are public, and the key |
| 106 | +size follows from the public key. Only callers with a valid token see these messages. |
| 107 | + |
| 108 | +Decryption failures are the exception: every failure of the RSA operation returns the same generic |
| 109 | +`400`, so error messages cannot be used as a padding oracle. Backend and internal errors return a |
| 110 | +generic `500`; the details go to the log only. |
| 111 | + |
| 112 | +### Legacy algorithms for SAML interoperability |
| 113 | + |
| 114 | +The agent accepts `rsa-pkcs1-v1_5` decryption and `rsa-pkcs1-v1_5-sha1` signing because existing SAML |
| 115 | +partners still use them. PKCS#1 v1.5 encryption is inherently exposed to Bleichenbacher-style |
| 116 | +padding-oracle attacks. Configure consumers to use OAEP (`rsa-pkcs1-oaep-mgf1-sha256` or stronger) and |
| 117 | +SHA-256 or stronger signatures wherever partners allow it. |
| 118 | + |
| 119 | +### Unencrypted key files |
| 120 | + |
| 121 | +The agent loads private keys from PEM files without a passphrase. Their protection comes from file |
| 122 | +permissions and from the secrets manager that delivers them. |
| 123 | + |
| 124 | +Covered by requirement 4. |
| 125 | + |
| 126 | +## What the agent protects |
| 127 | + |
| 128 | +In an environment that meets the requirements above, the agent guarantees that: |
| 129 | + |
| 130 | +- private keys never leave the agent process: only hashes and ciphertext go in, only signatures and |
| 131 | + decrypted session keys come out; |
| 132 | +- a client can use only the keys in its `allowed_keys`, and a key only for the operations in its |
| 133 | + `operations`; |
| 134 | +- tokens are compared in constant time; |
| 135 | +- tokens, key material, hashes and decrypted values are never logged; |
| 136 | +- an invalid or incomplete configuration stops the agent from starting. |
| 137 | + |
| 138 | +## Related documents |
| 139 | + |
| 140 | +- [README](README.md): setup and the development-to-production mapping |
| 141 | +- [Design specification](docs/DESIGN-SPECIFICATION.md): architecture and configuration reference |
| 142 | +- [API reference](docs/api.md): endpoints and error responses |
| 143 | +- [OWASP ASVS Level 1 audit (2026-05-15)](docs/openconext-private-key-agent-ASVS-L1-audit-2026-05-15.md) |
0 commit comments