checkId: check.security.encryption plugin: stellaops.doctor.security severity: warn tags: [security, encryption, cryptography]

Encryption Keys

What It Checks

Validates encryption key configuration and algorithms. The check only runs when an encryption configuration section exists (Encryption, DataProtection, or Cryptography). It inspects:

SettingThreshold/ConditionSeverity
AlgorithmContains DES, 3DES, RC4, MD5, or SHA1fail — weak algorithm
KeySizeLess than 128 bitsfail — key too small
KeyRotationDaysGreater than 365warn — infrequent rotation
DataProtection:KeysPathDirectory does not existwarn — keys path missing

When Algorithm is not explicitly configured, it defaults to AES-256.

Evidence collected: configured algorithm, key size, key rotation period, and the data protection keys path.

Why It Matters

Encryption protects data at rest and data protection keys used by ASP.NET Core for cookie encryption, anti-forgery tokens, and TempData. Weak algorithms (DES, 3DES, RC4) have known vulnerabilities and can be broken with modern hardware. Small key sizes reduce the keyspace, making brute-force attacks feasible. Without key rotation, a compromised key provides indefinite access to all encrypted data.

Common Causes

How to Fix

Docker Compose

Set encryption configuration:

environment:
  Encryption__Algorithm: "AES-256"
  Encryption__KeySize: "256"
  Encryption__KeyRotationDays: "90"
  DataProtection__KeysPath: "/app/keys"

volumes:
  - stellaops-keys:/app/keys

Bare Metal / systemd

Edit appsettings.json:

{
  "Encryption": {
    "Algorithm": "AES-256",
    "KeySize": 256,
    "KeyRotationDays": 90
  },
  "DataProtection": {
    "KeysPath": "/var/lib/stellaops/keys"
  }
}

Create the keys directory:

sudo mkdir -p /var/lib/stellaops/keys
sudo chown stellaops:stellaops /var/lib/stellaops/keys
sudo chmod 700 /var/lib/stellaops/keys

Kubernetes / Helm

Set in Helm values and use a PersistentVolume for key storage:

encryption:
  algorithm: "AES-256"
  keySize: 256
  keyRotationDays: 90

dataProtection:
  persistentVolume:
    enabled: true
    size: "100Mi"

Verification

stella doctor run --check check.security.encryption