Security considerations
This library handles sensitive cryptographic material during request and response processing. The following rules apply to implementation, tests, diagnostics, and operations.
Never log sensitive values
Do not log:
- plaintext request bodies,
- plaintext response bodies,
- compact JWE values,
- CEKs,
- private keys,
- decrypted
JWE-Response-Keyvalues, - full JWK key material.
Review traces and test logs must use redacted placeholders:
<compact-jwe length=...>
<redacted 32 bytes>
<redacted>
Public JWKS only
The JWKS endpoint must only publish public keys.
The client rejects invalid JWKS data, including keys with private parameters.
Supported algorithms
Request body JWE and JWE-Response-Key use:
alg: RSA-OAEP-256
enc: A256GCM
Encrypted backend responses use:
alg: dir
enc: A256GCM
Unsupported algorithms are rejected.
Request-local response CEK
The response CEK is generated per protected request.
It must not be:
- reused across requests,
- stored in local storage or session storage,
- cached globally,
- logged,
- exposed to application code.
Trusting the backend switch
With enabled left unset the client follows the backend's published enabled
(Configuration), so the metadata endpoint can turn
encryption off. Two properties keep that safe:
- It adds no new trust. The metadata is already the source of truth for which paths the client
encrypts, so anyone able to forge that response can publish empty
includedPathsand disable encryption for every path today. Both rest on the same assumption: the metadata is fetched over HTTPS from the configured origin — which the client enforces, refusing a non-secure or cross-origin configuration endpoint. - Only an explicit
falsedisables the client. A failed load keeps failing closed withJWE_CONFIG_LOAD_FAILEDrather than falling back to plaintext, so a mistypedjweConfigPathor an unreachable backend cannot silently downgrade requests.
An application that must never send plaintext regardless of what the backend says pins enabled: true
— an explicit local value wins over the published one. Against a backend that actually has JWE off,
that makes every included request fail rather than succeed unencrypted: there is no JWKS to encrypt
with. Fail-closed is the point, but it is not a configuration the two sides can run in.
Transport content type
Protected payloads use:
Content-Type: application/jose
Protected responses use:
Content-Type: application/jose
The original content type is carried in the JWE cty protected header.