5.4 KiB
Security cases, written before implementation
Default research track: original README track1, worker compromise. One isolated disposable stack, no unrelated stores.
| Situation / input class | Example | Expected result | Level |
|---|---|---|---|
| Valid transport | correct CA, hostname, unexpired leaf, matching key | application/query succeeds | real TLS integration |
| Empty/foreign trust | no CA / second independent CA | verification error, never timeout counted as denial | TLS integration |
| Wrong name | same endpoint, requested invalid.example | hostname verification error | TLS integration |
| Invalid lifetime | expired leaf, future notBefore, expired CA | verifier rejects | unit + TLS integration |
| Missing/foreign client | API/broker/Collector without cert or foreign CA | TLS rejection; no upstream effect | TLS integration |
| Same-CA wrong identity | worker cert on API ingress; LB on broker | identity rejection, permitted control succeeds | TLS integration |
| Local bypass | container IP:8080 / raw S3 / raw Collector | no non-loopback listener; connection refused | namespace integration |
| OpenBao roles | API own path, worker own path, other path, policy write | allow own; deny other/admin | real OpenBao integration |
| OpenBao lifecycle | renewable token, expired/revoked token, sealed server | renew works; new forbidden reads fail; no plaintext/root fallback | integration |
| Database privilege | worker pipeline vs users/messages/roles | permitted pipeline query; denied user/session/message and DDL | PostgreSQL integration |
| Object privilege | worker staging-read/variant-write vs forbidden prefix/admin | allowed exact prefixes, denied forbidden prefix and anonymous read | S3 integration |
| Queue privilege | API cache-only, separate XADD publisher, worker consumer vs admin/other keys | allowed actual commands; denied cross-role/unrelated/admin operations | Valkey integration |
| Rotation | new S3 secret, new worker leaf, revoke old identity | old new-connection denied, worker resumes queued tasks | real integration / track1 |
| API ACL | outsider attachment/meta/content/link, forged X-User-Id | 404 / Bearer identity preserved | public smoke + student HTTP |
| Login budget | concurrent Basic through two replicas | shared429/Retry-After, bounded KDF resources, successful control | HTTP integration |
| Persistence / failover | restart stores; stop actual serving instance | same session/data survive; second replica serves | public resilience |
| Secret leakage | git/build context/container logs/telemetry | no generated secret values/private material | artifact + runtime scan |
| Hardening | read-only app; all cap-drop, limits, no socket | effective docker inspect matches topology | runtime audit |
Failures: dependency timeout, malformed certificate/key, unavailable/sealed Bao, agent renewal failure, partial bootstrap, revoked client with existing pool, certificate rotation with stale process, S3/DB/broker outage, stopped worker and durable queued task, migration failure, incomplete teardown. Preserve the primary error privately and report its static stage; never count transport timeout as successful security rejection. Already-open TLS connections require explicit drain/reconnect in revocation tests.
Freshness adapter cases before code
| Situation | Example | Expected result | Level |
|---|---|---|---|
| Exact freshness boundaries | timestamp now, age120s, age120s+1ns | first two valid, last stale | fake-clock unit |
| Malformed/future input | empty, bad date, extra data, now+1ns | explicit invalid/future failure | unit |
| Bounded input | 128bytes or129bytes; reader ignores requested limit | never accept oversized input; read requests129bytes at most | unit + real file integration |
| I/O failure | reader returns permission/unavailable | explicit unreadable failure, no raw path/data in error | fake reader unit |
| Later expiry | advance fake time, deliver tick | Run returns ErrStale and stops ticker | fake ticker unit |
| Later read failure | valid first read then failed second | Run returns ErrUnreadable | fake ticker unit |
| Cancellation | cancel before Check or during Run | context error; ticker closed once | unit |
| Invalid factory/timing | missing port, interval0, interval>5s/maxAge | constructor rejects before reading/ticking | unit |
Production adapter never os.Exit or sends signals. Composition owner maps returned error to graceful shutdown. Timestamp format is RFC3339Nano (UTC preferred); native Bao template uses timestamp only inside a successfully read own-secret block. Temporary default max age120s/poll5s gives stale detection approximately within125s plus shutdown grace under normal localFS/scheduling. The reader checks context before/after its syscall and cannot interrupt a hung filesystem; this is not a universal wall-clock bound.
OpenBao KVv2 response boundary before correction
The native HTTP wrapper returns {status,data:completeHttpJSON}. KVv2 secret fields are therefore under result.data.data.data; metadata is result.data.data.metadata. A200alone or one fewer data level is not a successful secret read.
Cases: correctly nested API and worker payloads accepted; missing nested data, missing required secret, wrong database/cache/S3 role, missing publisher identity for worker, invalid metadata.version and denied HTTP status rejected with fixed safe errors. Tests first reproduce the old flattened reader failure before replacing it.