forked from mtusi2026/mtusi2026lab7
Лабораторная 7
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
# Security boundary
|
||||
|
||||
TLS roots are generated by the operator in `secrets/operator/ca.key` (never mounted
|
||||
in services). Each service receives only its leaf directory plus the public CA.
|
||||
Leaf lifetime: 7 days. Root lifetime: 365 days. Keys are generated, never in Git
|
||||
or images. `scripts/pki.py` is idempotent; it does not silently replace a CA.
|
||||
|
||||
The native backend processes Redis/MinIO/Collector/Prometheus/Loki/Tempo share
|
||||
only their corresponding TLS-sidecar network namespace (`network_mode:
|
||||
service:tls-...`). They bind plaintext listeners to 127.0.0.1 on distinct ports.
|
||||
Only the sidecar binds the network-facing port. No plaintext port is published.
|
||||
The proxy verifies client CA, expiry, DNS SAN allowlist and serial denylist on
|
||||
EVERY new connection. It disables tickets and reloads leaf files per connection.
|
||||
For broker it additionally parses bounded RESP frames, binds AUTH/HELLO username
|
||||
to the certificate SAN, and restricts consumer XADD to the invalid-envelope DLQ;
|
||||
Redis independently enforces producer/consumer command/key ACLs.
|
||||
|
||||
A connection can stay alive until its finite 75s socket timeout; certificate
|
||||
rotation restarts the affected caller to drain its old connections. Denylist
|
||||
checks refer to NEW connections. No claim of revoking already completed actions.
|
||||
|
||||
PostgreSQL uses native TLS and verify-full URLs; separate API/worker/dispatcher/
|
||||
cleanup database roles. Only the operator migration identity owns schema. API
|
||||
must read password hashes to authenticate; worker cannot read users. S3 policies
|
||||
separate API staging writes from worker originals/variants writes. MinIO admin
|
||||
credentials exist only at the server and one-shot operator bootstrap.
|
||||
|
||||
OpenBao uses native TLS, non-dev persistent file storage, cert auth bound to exact
|
||||
leaf certificates and a read-only policy for each KV path. Tokens: TTL60s/max120s.
|
||||
Services reauthenticate every20s; this is renewal by scoped reauthentication,
|
||||
not use of a permanent bootstrap token. Revocation replaces exact cert bindings.
|
||||
If refresh fails, the last granted lease remains valid only until its deadline;
|
||||
API then returns contract 503 (liveness stays up), workers exit75 and restart
|
||||
fail-closed until authority recovery. Secrets are loaded only from Bao; no file
|
||||
or plaintext fallback. Secret rotation restarts only the affected process/pool,
|
||||
without building an image. Bootstrap and renewal remain explicit operator tasks.
|
||||
|
||||
## Operator commands
|
||||
|
||||
```sh
|
||||
sh scripts/start.sh
|
||||
python3 scripts/bao-operator.py seal
|
||||
python3 scripts/bao-operator.py unseal
|
||||
python3 scripts/rotate-db-secret.py
|
||||
python3 scripts/rotate-leaf.py worker
|
||||
```
|
||||
|
||||
The operator owns `secrets/operator/bao-init.json`, root token and unseal share;
|
||||
file mode0600 under mode0700 directory. Neither OpenBao nor apps mount this
|
||||
operator directory. One-share Shamir is a local teaching compromise; production
|
||||
requires separated custodians / protected auto-unseal. Restart hook explicitly
|
||||
runs as operator and unseals using LOCAL operator material; it is not server-side
|
||||
unattended unseal. Keep an offline protected backup; losing it can make Bao data
|
||||
unrecoverable. Never delete volumes to recover a forgotten unseal key.
|
||||
|
||||
App/worker are non-root; read-only root filesystems, no-new-privileges and
|
||||
cap_drop ALL apply to runtime services. Writable volumes contain state, bounded
|
||||
tmpfs contains temporary processing data. One-shot volume ownership init uses
|
||||
only CHOWN, no network; this is the documented exception, not application power.
|
||||
Docker socket/host network/privileged mode are absent. Operator audit is a profile,
|
||||
not a production service, and explicitly mounts audit leaf material read-only.
|
||||
|
||||
Runtime secret bind files have mode0444 inside mounts so non-root Linux UIDs can read them. The enclosing host secrets directory stays0700; operator CA key/root token/unseal file stay0600 and are never runtime mounts. Each container receives only its own named files/leaf directory.
|
||||
|
||||
Redis sessions: отдельный user api ограничен session:*/login:* и GET/SET/DEL/INCR/EXPIRE/EVAL; CONFIG/FLUSHALL/чужие prefixes не разрешены. Operator health/expiry использует отдельную identity.
|
||||
Reference in New Issue
Block a user