11 KiB
Матрица доверия — реализованный стенд lab7
Identities, CA и leases
Все TLS endpoints проверяются по CA и DNS SAN; TLS ≥1.2. Offline root находится
у оператора вне checkout, OpenBao выдаёт EC P-256 leaf через внутренний intermediate.
URI service identity — spiffe://mtusi/<role>; DNS SANs задаёт
scripts/lab7_environment.py:ROLES. Доверенный CA сам по себе не является ACL.
Default leaf TTL — 1h, максимум PKI role — 1h; host-side make renewer
выпускает новые leaf каждые 30 минут и синхронизирует CRL; исследовательский renewal/expiry
использует 20s. Cert-auth tokens: 60s, max/explicit max300s. KV freshness у Go
приложения — 60s, независимо от срока leaf и token; admission закрывается за1s
до ближайшего deadline (наблюдаемое закрытие при sealed Bao: 60.5–61.7s с учётом
1s cadence watchdog). Backend KV passwords/SigV4 keys статические и живут до
явной ротации — это не динамические60s credentials. Session TTL3600s;
server хранит только SHA-256 token hash.
| Связь | Endpoint / протокол | Проверка identity и права | Lease / reload | Положительная и отрицательная проверка |
|---|---|---|---|---|
| Клиент → ingress/LB | https://localhost:8443, TLS, Bearer |
DNS SANlocalhost; без clientcert. LB заменяет forwarding headers и удаляет X-User-Id | LB leaf; пользовательская session3600s/logout/expiry | make test test-security; public_ca_hostname, http_acl_logout_expiry_bounds, shared_rate_limit |
| LB → все API-реплики | api-replica:8080, native mTLS |
LB проверяет SANapi-replica/CA/CRL; Go server требует точный URIspiffe://mtusi/lb |
Atomic leaf/CRL reload Go; trust changes restart; tickets/cache off | mtls_and_telemetry_acl: lb200; absent/wrongCA/wrongURI TLS拒绝; make test-pki oldLB revoke/retire |
| API/worker/relay → PostgreSQL | postgres:5432, native TLS+SCRAM, verify-full |
Раздельные messenger_api/worker/relay roles; no superuser/DDL. Worker/relay не читают users/sessions/messages | Статический password в ownKV; connection lifetime30s; credentials change → bounded restart | database_privileges: SQLSTATE42501; make integration-test actual nativeTLS DB suites |
| API/worker → S3 | https://seaweedfs:8333, native TLS+SigV4 |
API stagingRead/Write, finalRead; worker managed-prefixRead/Write+bucketList; foreign GET/PUT/DELETE/COPY/bucket 403, worker bucket-level LIST returns managed metadata (documented limitation) | Static keys until explicitrotation; role-specific ownKV. No claim of required clientcert on S3HTTP | s3_prefix_acl: GET/PUT/DELETE/COPY+fullreadback; make test-presign test-queue; workerkeyrotation inPKIstudy |
| Relay/API outbox/worker → broker | broker:5671, native mTLS/EXTERNAL-only |
API commits DBoutbox, relay publishes onlyattachments.jobs; worker consumes onlyattachment.process.v1. First DNS SAN principal, anchored broker ACL | Leaf+broker user permissions; nativeprincipal revoke distinct from serial CRL | broker_external_acl: positive relaypublish/workerconsume; opposite/topology/wrongDNS403, no-cert/wrongCA TLS rejection |
| API/worker/relay → Collector | otel-collector:4318, mTLS gateway → loopback14318 |
Exact CNapi/worker/relay and POST/v1/{traces,metrics,logs}; unknownCN/verb/path denied | Gateway loads CA/CRL atstartup; revoke/rollover restarts gateways; app pools are not claimed drained | mtls_and_telemetry_acl: api200, lb403, missing/wrongCA rejection; full make test-observability |
| Collector → telemetry backends | Lokihttps://loki:3100; TempoGRPCStempo:4437 |
CollectorCN onlylogpush/OTLP; no dataquery. Native hops127.0.0.1:13100/14317 | Distinct collectorleaf; fixedsingletenantfake | mtls_and_telemetry_acl collectorquery403; actual traces/logs in make test-observability |
| Grafana → data sources | Prometheus9090/Loki3100/Tempo3200, HTTPS/mTLS | GrafanaCN query allowlist; push/delete/admin/reload forbidden; CA+hostname verified | Ownleaf in secureJsonData rendered outsideGit; rotation rerenders/restarts | mtls_and_telemetry_acl forbiddenwrite403; Grafana/dataSources/TraceQL correlation intelemetrygate |
| API/worker/relay → OpenBao | https://openbao:8200, verifiedTLS+cert-auth |
Authrole checks CN+URI; ownsecret/data/ and ownpki/issue/ only; no root/defaultpolicy | Token60s/max300s; cert reauth; KVfresh60s; independentleafdeadline | bao_api_policy: ownKV200, foreignKV/issuer/policyadmin403; make test-pki renewal/expiry/recovery |
| Оператор → OpenBao/Grafana/S3 admin | LoopbackHTTPS8200/3000/8333 | Separate operatorcertificate+scopedBaopolicy; Grafana localpassword; SigV4S3operator. No anonymousadmin | Root token revoked afterbootstrap; unseal2-of-3 hoststate; operatorleafrotation | securityctl.py up, audit-summary, S3readinessfullbytes; noappoperatorcredentialmounts inisolation |
| API → Redis | redis:6379, nativeTLS+ACLpassword |
cache user: chat_list:* / lock:chat_list:* onlyGET/SET/DEL/PING/EVAL/scripts; default useroff |
StaticownKVpassword; RedisAOF persists; no requiredclientcert claimed | redis_tls_cache_acl: PONG/allowedcache, foreignkeyNOPERM; nativeTLS integrationDB7 |
| Replication/cluster channels | ExternalreplicationN/A: allstatefulstores single-node | BaoRaftcluster127.0.0.1:8201nativeTLS; S3master/filer/volume oneclosednamespace, internalgRPCmTLSCNs3; telemetrygossiploopback | NoHAclaim forDB/S3/broker/Bao/host | runtime_container_network_isolation; seaweed_auxiliary_mtls; actualpersistence/bothAPIreplicafailures |
Служебные, scrape и health каналы
| Канал | Boundary / identity | Проверка |
|---|---|---|
| Local API/worker/relay health8084/8081/8082 | Namespace loopback, no business API; no hostpublication | Из соседнего defaultnamespaceconnection_refused; Gohealthcloses admission onauthorizationexpiry |
| HAProxy stats8404 | mTLS, CNoperator/prometheus; monitoronly/metrics | Separate healthbackend excluded fromAPI SLI; Prometheus scrape overTLS |
| Collector metrics8888/8889, health13134 | mTLS/CNprometheus oroperator; localhops18888/18889/13133 | Privateportprobes, fulltelemetryscrapes |
| Prometheus/Loki/Tempo selfmetrics | HTTPS/mTLS/CNprometheus GETmetrics/ready only | Wrongqueryrole403; native19090/13100/13200 andgRPC/gossip notnetwork-accessible |
| RabbitMQ management15671, scrape15693 | mTLS HAProxy → loopback15672/15692; operatoradmin Basic onlymanagement, Prometheus onlyscrape | NoAMQP5672 orplaintextmanagement published; brokerACL/scapedata |
| S3 auxiliary18333 | Native mTLS, onlyCNs3; HTTP2 ALPNh2 | api/worker/operator/no-cert denied, s3TLSchannelaccepted; not anadminmethodproof |
| S3 master/filer/volume | HTTP9333/8888/8080 andgRPC19333/18888/18080 onnamespace loopback; gRPC additionallyCNs3 | Neighbor namespaceconnection_refused; Iceberg8181/Lance9101 disabled, not excluded |
| Migrations/S3-init/volume-init | Explicitoperatorjobs; no rootCA/unseal mount | Migrate DBoperator only; S3init operator only; volume-init has no network/socket, CHOWN/DAC_OVERRIDE only |
Native plaintext hops exist only within the shared Linux network namespace
of a backend+its TLS gateway, or S3co-located internal HTTP components. A helper
compares actual /proc/self/ns/net, not just containerIDs. None of these listeners
is a published bypass; only TLS owner joins routable networks. default is used
by apps, observability by telemetry, edge by their TLS owners.
Bootstrap, current-version и отзыв
cp .env.example .env; make up: offlinekeys/backendcredentials/complete role versions are generated locally; init/unseal/provision/migrations follow.- RootCA/privateoperator/unseal state is in
~/.local/share/mtusi-lab7/<project>with0700/0600. Only public CA/intermediate/CRLs and each role's own leaf/key enter role mounts. Operator recovery material never enters app/images/Git. - Native consumers use
currentalias. Every Go snapshot reads one bounded regularcurrent-versionselector and immutableversions/<name>; cert/key/CA/CRL cannot be mixed across a swap. Selector is owner/group-readable before atomic publication. No last-known-invalid fallback, arbitrary path or symlink retry. make pki-renew ROLE=api CERT_TTL=1handrenew-watchuse owncert-auth. Token renewal cannot renew theleaf. Missing/expired/revoked material fails closed.securityctl.py revoke ROLE --serial SERIAL: publishes issuer-signed CRLs, updates BaoauthCRLs, then restarts native CRL-consuming HAProxy gateways. Existing application TLS/DB/S3/broker pools are not claimed to be drained; only fresh/resumption attempts are measured. Go verifies currentCRLs onfreshconnections. Principalcompromise also requires backendcredential/token/authrole disable; RabbitMQ EXTERNAL user/connection revocation is separate and not falsely represented by CRLfileupdate.- Offline rootCRLs are regenerated before their final24h and onoperator sync;
nativegateways are reconciled on
up. StaleCRL verification is never disabled. - CArollover uses prepare(overlapCA/CRLs+authtrust) → issue(newintermediate/leaves)
→ retire(oldCA/issuer/authCRLs). Retire re-publishes every running role identity
with a new-only trust bundle (the leaf is unchanged), so an old certificate is
rejected by trust, not by a missing CRL; a process whose mounted trust differs
from its startup roots fails closed (
restart required). Prepare/retire reload api/worker/relay one replica at a time; issue only reloads native owners and Go re-reads the new leaf on fresh handshakes. Readiness closes on root removal so LB retires a not-yet-restarted replica instead of routing into TLS failures. Study checks oldtrustedleaf during overlap, fresh/resumption attempts after retirement, newpipeline/Redis/Bao/telemetry paths and retained message/filebytes; each phase waits for the full public upload pipeline before asserting contract details.
Обязательные отрицательные наборы
- CA/hostname errors are checked as verification errors, not TCPtimeouts.
- API/broker/Collector: allowedidentitypositive, absentcert, foreignCA andsameCA forbiddenrole negatives. HTTP403 aftertrustedmTLS is distinguished from TLSdenial.
- Foreignchat/attachment access, forgedX-User-Id, logout/DBexpiry, uploadbounds, shared429/Retry-After, nativeDB/S3/broker/Baopolicy allow/deny are runtime-tested.
- Leaf/CArevocation checks freshconnections and explicit resumptionattempts; tickets/cacheoff means no claim of a positively resumedsession.
evidence/lab7/security.json,verification.json,restart-scope.json,failover-scope.json,sequential-failover.jsonandPKIstudy contain sanitized observations; scantriage names residualrisk.