lab7: безопасность, mTLS, OpenBao и PKI lifecycle
This commit is contained in:
+129
-4
@@ -1,7 +1,132 @@
|
||||
# OpenBao — реализовать конфигурацию и политики
|
||||
# OpenBao: bootstrap, policies и PKI lifecycle
|
||||
|
||||
Добавьте non-dev конфигурацию listener/storage/TLS, API/worker policies, bootstrap и rotation scripts. Credentials и unseal material создаются локально; здесь нет готового root token или private key.
|
||||
Pinned OpenBao2.7.2 runs as UID100:1000, **not dev-mode**. NativeHTTPS8200,
|
||||
Raftvolume `/openbao/file`, auditvolume `/openbao/audit`; clusterlistener8201
|
||||
is loopback. `server.hcl` declares TLS1.2+, clientCA and persistentHMAC audit
|
||||
with `log_raw=false`. Browser/operator endpoint is loopbackHTTPS, not publicadmin.
|
||||
|
||||
Решение должно показать реальную сервисную аутентификацию и получение нужного secret по ограниченной policy; просто работающий контейнер OpenBao не засчитывается. На 3 статический KV secret допустим. На 4 покажите expiry/renewal/rotation и allow/deny. Путь KV v2 data/metadata и ACL должен соответствовать фактическому mount; не копируйте широкое `path "*"` для приложения.
|
||||
## Запуск и custody
|
||||
|
||||
Документируйте шаги оператора init/unseal и восстановление после restart. Скрипт не должен печатать tokens/shares или хранить их в Git. См. contracts/trust-matrix.md и REPORT.md.
|
||||
```sh
|
||||
cp .env.example .env
|
||||
make prepare
|
||||
make up
|
||||
make test test-security test-lab7
|
||||
```
|
||||
|
||||
`make up` builds the application, preparesrolefiles, runsvolumeownershipjob,
|
||||
startsBao, performs firstinit (3shares, threshold2), operatorunseal and scoped
|
||||
provisioning, createsDB/S3roles/bucket, runsmigrations, startsapps andwaits for
|
||||
CA/hostname-verifiedHTTPS **and full64KiBS3bodyreadiness**. RunningAPI restart does
|
||||
not requireunseal. AfterBao restart:
|
||||
|
||||
```sh
|
||||
make bao-unseal
|
||||
# Or complete namespace-aware storage/application restart:
|
||||
python3 scripts/securityctl.py restart
|
||||
```
|
||||
|
||||
Offline rootCA/privatekey and `operator-unseal.json` are outsidecheckout:
|
||||
`~/.local/share/mtusi-lab7/<COMPOSE_PROJECT_NAME>` (0700directory,0600files),
|
||||
optionally overridden by `LAB7_OPERATOR_STATE`. They are never mounted into
|
||||
containers. Operatorhost/Dockeraccess is trusted. Protect and back up this state;
|
||||
losingunsealshares cannot be repaired by readingBao'sencryptedRaftvolume.
|
||||
|
||||
Initialroot token is used only for provisioning. After verifyingseparate
|
||||
operatorcert-auth, bootstraprevokesit, confirms403 and removesit fromstate.
|
||||
App/worker/relay receive only ownleaf+ownconfidentialKVconfiguration, notroot,
|
||||
unsealshares, sharedBAO_TOKEN or a staticbootstrapsecret.
|
||||
|
||||
## Identity и policies
|
||||
|
||||
`securityctl.py` applies KVv2 at `secret/`, `cert/` auth and `pki/`intermediate.
|
||||
Operator signs anintermediateCSR withoffline root; itsprivatekey remains inside
|
||||
BaoRaft, not at thehost. Serviceauth binds bothCN and URI`spiffe://mtusi/<role>`.
|
||||
|
||||
| Role | ReadableKV | Issuance | Othercapabilities |
|
||||
| --- | --- | --- | --- |
|
||||
| api | secret/data/api | pki/issue/api | tokenlookup/renew/revoke-self |
|
||||
| worker | secret/data/worker | pki/issue/worker | tokenlookup/renew/revoke-self |
|
||||
| relay | secret/data/relay | pki/issue/relay | tokenlookup/renew/revoke-self |
|
||||
| Othernative service | None | Itsownpki/issue/<role> | tokenlookup/renew/revoke-self |
|
||||
| operator | ManagedKVandPKI | Managedroles/issuers | Restrictedlab7policies/certauth/seal/auditinspection; no permanentroot token |
|
||||
|
||||
Servicepolicy cannot readforeignKV, issueforeignrole or writepolicy. Live
|
||||
`make test-lab7` returns ownKV200 andforeignKV/issuer/policyadmin403. KVbackend
|
||||
passwords/keys remain static until explicitrotation; tokenTTL is not theirTTL.
|
||||
|
||||
Cert-auth tokenTTL60s/max300s. Go admission is bounded independently by
|
||||
actualtokenlease, KVfreshness60s and currentleafNotAfter, with a1s safetymargin.
|
||||
Renewal/reauth must succeed beforedeadlines; sealed/unavailableBao cannot widen
|
||||
a cachedlease. A firstcancellation fixes one30s shutdownbudget for allcleanup.
|
||||
|
||||
## Leaf publication и renewal
|
||||
|
||||
```sh
|
||||
make pki-issue ROLE=api CERT_TTL=1h
|
||||
make pki-renew ROLE=api CERT_TTL=1h
|
||||
make renew-watch ROLE=api CERT_TTL=1h
|
||||
```
|
||||
|
||||
NormalleafTTL1h/max24h. Watcher uses ownservicecert-auth and renews at half of
|
||||
remaininglifetime. Allcertificate/key/CA/CRL files are prepared in immutable
|
||||
`pki/<role>/versions/<name>` with runtime-readableownership. Nativeconsumers
|
||||
use `current`; Go uses one atomicregular `current-version` selector. TLSfile
|
||||
settings still namecurrentbasenames; `TLS_VERSION_FILE` identifies theselector.
|
||||
Go cannot mixfiles or fail because a hot-swap traversed thesymlink. Invalid,
|
||||
missing, stale or revokedmaterial remains fail-closed; no insecure/cachefallback.
|
||||
|
||||
Go hotloadsleaf/CRL; CAtrustchanges restartprocesses. NativeHAProxy, PostgreSQL,
|
||||
S3, RabbitMQ, Collector/Grafana clients use explicitreload/recreate paths. A shared
|
||||
namespaceconsumer is recreated against actualowner afterownerrestart. `up`
|
||||
also reappliesnativegateways whenownercontainers are reused.
|
||||
|
||||
## Отзыв, staticsecret и CArollover
|
||||
|
||||
```sh
|
||||
# Issue/reload the replacement before revoking itsoldserial:
|
||||
python3 scripts/securityctl.py revoke lb --serial OLD_SERIAL
|
||||
python3 scripts/securityctl.py rotate-secret worker
|
||||
|
||||
python3 scripts/securityctl.py ca-rollover --phase prepare
|
||||
python3 scripts/securityctl.py ca-rollover --phase issue
|
||||
python3 scripts/securityctl.py ca-rollover --phase retire
|
||||
python3 scripts/securityctl.py audit-summary
|
||||
```
|
||||
|
||||
Revocation publishesissuerCRLs toallroles/Baoauth, then reloads anddrains native
|
||||
HAProxy consumers. Go validates CRLissuer/signature/ThisUpdate/NextUpdate/serial
|
||||
for everyissuer, includingroot-issuedintermediateCRL. Offline rootCRLs refresh
|
||||
before their final24h. This does not claim revocation of RabbitMQprincipal from
|
||||
CRL alone: compromise requires user/connection closure and token/credential/auth
|
||||
role disable as documented inthreatmodel.
|
||||
|
||||
WorkerS3rotation changesonlyitskey, updatesownKV, restartsS3+worker withoutimage
|
||||
build andchecksnewqueuedattachmentprocessing. Oldkey must return403.
|
||||
|
||||
CAprepare retainsold/newCA+CRLtrust; issue switchesissuer andallmanagedleaves;
|
||||
retire removesoldCA/issuer/authCRLs. Nativeconsumers reload/drain at eachphase.
|
||||
No statement of zero-downtimeCArollover: errors/recovery are measured underload.
|
||||
|
||||
## Recovery и безопасная остановка
|
||||
|
||||
```sh
|
||||
python3 scripts/securityctl.py recover openbao
|
||||
python3 scripts/securityctl.py recover api
|
||||
make up
|
||||
make down
|
||||
```
|
||||
|
||||
ExpiredBao/operatortransport can be replaced byofflineoperatorleaf for verified
|
||||
restart/unseal, then a restrictedBao-issuedleaf. Never disableCAverification.
|
||||
`make down` preservesRaft/applicationvolumes andoperatorstate. Intentional deletion
|
||||
of **your syntheticstand data**: `docker compose --env-file .env down --volumes`;
|
||||
it does not deleteofflineoperatorstate, which must be managed separately and
|
||||
never reused accidentally with unrelatedvolumes.
|
||||
|
||||
`make test-pki` executes3freshisolatedprojects with20s APIleaves, renewal/expiry,
|
||||
oldleafrevoke, workerkeyrotation, CAprepare/issue/retire, telemetry/nativeTLS checks
|
||||
and retaineddata. Cleanup is restricted to itsgeneratedproject/volumes/operator
|
||||
state; existinglab6volumes are not removed. Fullresults/limitations belong in
|
||||
[REPORT](../../REPORT.md), [trustmatrix](../../contracts/trust-matrix.md) and
|
||||
`evidence/lab7/track2.json`.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
ui = true
|
||||
api_addr = "https://openbao:8200"
|
||||
cluster_addr = "https://127.0.0.1:8201"
|
||||
|
||||
storage "raft" {
|
||||
path = "/openbao/file"
|
||||
node_id = "mtusi-lab7"
|
||||
performance_multiplier = 1
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
cluster_address = "127.0.0.1:8201"
|
||||
tls_cert_file = "/run/identity/current/tls.crt"
|
||||
tls_key_file = "/run/identity/current/tls.key"
|
||||
tls_client_ca_file = "/run/identity/current/ca.crt"
|
||||
tls_min_version = "tls12"
|
||||
tls_disable_client_certs = false
|
||||
tls_require_client_cert = true
|
||||
}
|
||||
|
||||
audit "file" "file" {
|
||||
description = "Persistent protected lab7 operator and service audit"
|
||||
options {
|
||||
file_path = "/openbao/audit/audit.log"
|
||||
log_raw = "false"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user