Files
ZitPlane/notes/P05-OIDC-08-A04.md
T

88 lines
15 KiB
Markdown

# P05-OIDC-08-A04 — Normalized Service-Secret Grants RCA & Full Static Contract Acceptance
**Date:** 2026-11-23 Asia/Dhaka.
**User-approved baseline:** `fb5d6c5690b030608ddb393dc2cacb68605a9b07`, verified exact Gitea main before any edits.
**Previous CI:** [Run #104](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/104), Job #220 `COMPLETED FAILURE`, tested source `7954938fcee4d11c0b27751c7cf7abdcc64cd243`. Source fixture and static Compose PASS; 5 `deploy.replicas` int zero, `resources: {}`, `placement: {}`, `command:null` and `entrypoint:null` VERIFIED in normalized output. Earlier strict `DEPLOY_DISABLED` blocker passed along reached path, followed by `ZITPLANE_P08_FAIL_CLOSED_SERVICE_SECRET_REFS`; exact secret grant format UNKNOWN. All 25 original + 4 runtime + 3 replica + 8 deploy negative fixtures **NOT EXECUTED**. Manual-only/no Docker-lifecycle workflow safety PASS and runner-owned task cleanup observed.
**Earlier independent login:** Run #99 real imported custom Login V2/Chromium/PKCE/Auth.js *disposable localhost CI* success remains accepted; not real public HTTPS.
## Exact Scope Lock — COMMIT THIS NOTE FIRST, BEFORE ANY SOURCE MODIFICATION
**SOURCE WRITE EXACT (one file only):** `tests/ci/production_contract/validate.py`.
**DOCUMENTATION WRITE:** `notes/**`, relevant `project/**`, relevant `docs/**`, necessary associated existing `README.md` and `MINIFEST.md` only.
**STRICT READ ONLY:** all `auth/**`, `users/**`, `core/**`, **all `deployment/**`** including immutable `deployment/production-contract/compose.ci.yaml` and `routing-policy.json`, all existing `.gitea/workflows/**`, all other `tests/**` (outside validator/related existing README or MINIFEST), package manifests/locks, Gitea runner config, VPS/Coolify/Cloudflare/SSL/DNS/production infrastructure/secret stores, unrelated files. Preserve untracked `AI_INSTRUCTIONS.md`: do NOT modify/add/remove or inspect its private contents.
**NEVER:** local app tests/build, `docker compose up/run/build/pull`, real service startup, production DNS/TLS lookup, live users/secrets, publish image, production deployment, tag or release. Existing manual workflow only and **exactly ONE newly approved CI dispatch** after pre-CI focused security/diff audit. If it fails, record exact results and do NOT edit source after dispatch or run second CI.
## Read-only evidence and safe diagnosis strategy
- Original synthetic YAML has 5 undeployable services, internal-only network, `replicas: 0`, reserved synthetic image refs, six external **symbolic name-only** placeholders. Per-service expected: ingress **none**; `zitadel-api` masterkey+postgres; `zitadel-login` PAT+cookie; `account` client+auth; `postgres` postgres password. Existing policy exact trusted issuer/callback, Host/forwarded, h2c paths, no ports.
- Existing `service_secret_refs()` accepts strings or restricted `{"source","target","uid","gid","mode"}` dictionaries but requires `target == source`, and exact per-service ordered refs. Normalized output **NOT logged** in prior CI; plausible safe normalization variants include dictionary grants whose target is the canonical `/run/secrets/<source>` mount path, or reordered entries, but **neither is yet verified**. Do NOT assert actual cause until this phase's single CI.
- Source edit **only validator**: Add safe grant diagnostics for **known service IDs and expected symbolic placeholders**. Print only static field/class markers (list/entry string vs dict, whether source is approved and authorized to this service, whether target is exact source or the canonical `/run/secrets/<source>` vs unexpected, whether uid/gid remain root and mode remains canonical read-only, missing/duplicate/extra/unknown key flag). Never print raw source/target strings, arbitrary keys, env values, credential data, full JSON, paths of user files or secret values.
- Permit only genuinely safe Compose grant normalization proven by exact normalized category in CI (string names, or dictionary with authorized source and either same-name or exact canonical `/run/secrets/<source>` target, default root-owned/read-only metadata). Compare exact **set+count** of grants per service; reject duplicates, omission, wrong-service grants, extra unauthorized sources, wrong target, expanded mount privilege, unknown keys or abnormal type. The symbolic six-secret registry must still exactly match unchanged external placeholder policy. Never weaken other exact checks (canonical HTTPS OIDC callback, Host/Forwarded TLS, private network, 0 replicas and inert empty metadata, non-deployable image, no public ports/privilege/socket/build/command).
- Preserve 25 original + 4 runtime + 3 replica + 8 deploy targeted negatives and add focused missing/duplicate/extra/wrong-service/wrong-target/unsafe-permission grant negative fixtures with exact expected `SERVICE_SECRET_REFS` class. Never claim these ran prior to Gitea evidence.
- Once focused pre-CI source/security/diff audit confirms **only this source and this scope note**, commit/push tested source SHA. Dispatch unchanged `p05-production-contract-dry-run.yml` **exactly once**. Record actual positive markers, each fixture marker, manual-only `always()` guard, runner-owned cleanup and terminal status. No rerun or post-run source patch on failure.
- Documentation closure: append truthful PASS/FAIL/NOT EXECUTED to this note and new `docs/P05-OIDC-08-A04.md`, sync relevant `project/**`, `docs/**`, README/MINIFEST and exact tracked inventory. Perform cumulative path/secret/security audit and verify final Gitea main SHA. Distinguish **CI-tested SHA** from **later docs-only SHA**.
**Production remains not deployed/unverified:** no real HTTPS, DNS, SSL, production user, issuer, Console, MFA/passkeys/SSO, secure secret vault, master key custody or encrypted backup/restore acceptance in this phase.
## A04 terminal evidence — one-run full synthetic contract acceptance
**Scope-first note SHA:** `64d8c0830e5dac5417db2c8de2363b1d472f11c4`; this document was committed before any code modification. **Only source modified:** `tests/ci/production_contract/validate.py`. Source-tested Git SHA `daaa8b259a519ae0290ba28936ef2279b3a9172c`. Unchanged original `deployment/production-contract/compose.ci.yaml` pinned Git blob `930c0b0fbfb518555436acd6f0b4bb3bdd421937`; original policy/workflow/auth/Account/backend/deployment source strictly read-only. Pre-run source/security/diff audit PASS (exact scope note and one source file, no unauthorized path). **No local app tests/build or live DNS/TLS/secret inspection.**
**Exactly ONE approved manual CI:** [Gitea Run #105](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/105) / Job #221 `COMPLETED / SUCCESS`, branch `main`, tested SHA `daaa8b259a519ae0290ba28936ef2279b3a9172c`, started 2026-11-23T16:36:21Z, completed 16:36:38Z. Step #0 Alpine CI tooling **SUCCESS**, #1 checkout **SUCCESS**, #2 only static Compose config and Python normalized security validator **SUCCESS**, #3 `always()` manual-only/no Docker resource action configuration check **SUCCESS**. **No rerun** and no source edit after CI.
### Exact verified RCA
Seven normalized symbolic service secret grants (two for `zitadel-api`, two for `zitadel-login`, two for `account`, one for `postgres`; `ingress-policy` has none) were emitted as **object** entries using their approved symbolic source references and the canonical **`/run/secrets/<source>` mount target**. The old `service_secret_refs()` demanded `target == source`, creating a false positive. Run #105 emitted **seven** `*_ITEM_*_OBJECT`, `*_TARGET_CANONICAL_MOUNT`, `*_SOURCE_EXPECTED` markers; no `*_SOURCE_UNKNOWN` / `*_TARGET_UNEXPECTED` / `*_UNKNOWN_METADATA_PRESENT` diagnostic markers. The corrected validation only allows exact same-name or canonical target mapping, root-owned/read-only `uid/gid/mode` if present, exact approved references by service irrespective of normalization order, and **explicitly rejects duplicates, unknown grant fields, wrong targets, unsafe owners/modes and unauthorized extra sources**. No actual secret contents, raw entry values or arbitrary input keys were printed.
### Terminal acceptance table — PASS/FAIL/NOT EXECUTED
| Gate | Verified terminal result |
| --- | --- |
| `docker compose config --quiet`, undeployable synthetic source | **PASS** `ZITPLANE_P08_COMPOSE_STATIC_CONFIG_PASS` |
| Exact source fixture immutable SHA and original five `deploy.replicas: 0` | **PASS** `ZITPLANE_P08_SOURCE_ALL_FIVE_REPLICAS_ZERO_PASS` |
| Original Compose runtime inert null `command` and `entrypoint` on five services | **VERIFIED** ten known-field/null diagnostic markers |
| Private zero replica, inert normalized `resources: {}` and `placement: {}` | **PASS**, `ZITPLANE_P08_NORMALIZED_DEPLOY_METADATA_POLICY_PASS`, `ZITPLANE_P08_NORMALIZED_ZERO_REPLICA_POLICY_PASS` |
| Exact service secret grant source/target, grant defaults, registry and per-service authorization | **PASS**, `ZITPLANE_P08_NORMALIZED_SECRET_GRANT_POLICY_PASS` |
| Canonical HTTPS design issuer, separate Account origin and exact callback; PKCE, state, nonce policy | **PASS as STATIC POLICY**, `ZITPLANE_P08_CANONICAL_HTTPS_ISSUER_AND_CALLBACK_PASS` |
| Login V2 `/ui/v2/login`, Console `/ui/console`, API h2c and private service routes | **PASS as STATIC POLICY**, `ZITPLANE_P08_LOGIN_CONSOLE_API_H2C_PRIVATE_ROUTING_PASS` |
| Host rejection, Forwarded/header replacement and TLS-required policy | **PASS as STATIC POLICY**, `ZITPLANE_P08_HOST_FORWARDED_HEADER_TLS_POLICY_PASS` |
| No public backend/DB ports, plaintext inline credentials, Docker socket, privileged/unsafe runtime configuration | **PASS as STATIC POLICY**, `ZITPLANE_P08_NO_PUBLIC_PORT_INLINE_SECRET_SOCKET_OR_RUNTIME_PASS` |
| Original 25 malformed security cases | **25/25 PASS**, 25 distinct `ZITPLANE_P08_NEGATIVE_*_REJECTED_PASS` + `ZITPLANE_P08_ALL_25_NEGATIVE_CASES_PASS` |
| Nonempty runtime command/entrypoint/build/config | **4/4 PASS**, `ZITPLANE_P08_ALL_4_RUNTIME_NEGATIVE_CASES_PASS` |
| Nonzero/invalid replica and extra deploy settings | **3/3 PASS**, `ZITPLANE_P08_ALL_3_REPLICA_NEGATIVE_CASES_PASS` |
| Populated/unknown deploy metadata | **8/8 PASS**, `ZITPLANE_P08_ALL_8_DEPLOY_NEGATIVE_CASES_PASS` |
| Missing, duplicate, wrong-service, unknown, wrong target, unexpected metadata/owner/write mode grants | **8/8 PASS**, `ZITPLANE_P08_ALL_8_SECRET_NEGATIVE_CASES_PASS` |
| Positive inert normalized defaults/deploy metadata and canonical secret mount representation | **PASS**, `ZITPLANE_P08_INERT_NORMALIZED_DEFAULTS_ACCEPTED_PASS`, `ZITPLANE_P08_INERT_DEPLOY_METADATA_ACCEPTED_PASS`, `ZITPLANE_P08_CANONICAL_SECRET_MOUNTS_ACCEPTED_PASS` |
| Full synthetic contract static validation | **PASS**, `ZITPLANE_P08_STATIC_DRY_RUN_ACCEPTANCE_PASS` |
| Manual only, no configured Docker resource lifecycle steps | **PASS** `ZITPLANE_P08_MANUAL_ONLY_NO_RESOURCE_ACTIONS_CONFIGURED_PASS` (during validation and `always()` step) |
| CI runner-owned disposable resource cleanup | **PASS from terminal job log**: Gitea runner removed its job task container and two task volumes; job network cleanup logged. Not a Docker-daemon-wide production resource inspection |
| Live production HTTPS/DNS/TLS/issuer, signed release images, production secrets/DB, real MFA/passkeys, Admin Console, multi-app SSO, backup/restore or deployment | **NOT EXECUTED / OUT OF SCOPE** |
**Verified 48 / 48 intentionally invalid synthetic cases PASS**, each with exact expected error-class rejection (25+4+3+8+8). **No negative case remained unexecuted in this synthetic contract test.** No actual application service startup, no production deployment and no real credentials were used. The workflow's runner created a temporary CI task container by design and cleaned it up: do not misstate this as "no CI containers".
### A04 terminal decision
**P05-OIDC-08-A04 ACCEPTED: full synthetic static production configuration security contract PASS** on `daaa8b259a519ae0290ba28936ef2279b3a9172c`. Previous Run #101 runtime-field false positive, #102 replica shape, #103 inert deploy keys and #104 normalized grant path have all been resolved for this fixed synthetic fixture in **this one successful Run #105**. Previously accepted [Run #99](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/99) real disposable imported custom Login V2 browser OIDC SUCCESS is a separate CI acceptance, not evidence of a production site.
This phase does **NOT** certify deploying this `synthetic.invalid` fixture, public HTTPS certificate validity, current real ZITADEL sessions, production secrets, images, backup/restore or MFA/SSO. Phase-close documentation SHA differs from source-tested `daaa8b259a519ae0290ba28936ef2279b3a9172c`.
### Remaining blockers and proposed next exact Scope Lock — P05-OIDC-09 (SEPARATE APPROVAL REQUIRED)
**Title:** Production Release Preflight & Source-Verified Deployment Scope (documentation-only forensic audit).
**Baseline:** use verified final A04 Gitea main SHA after documentation closure. Accepted source `daaa8b259a519ae0290ba28936ef2279b3a9172c` / [Run #105](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/105), [Run #99](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/99).
**Exact write scope:** `notes/P05-OIDC-09.md` (commit Scope Lock FIRST), relevant existing `notes/**`, `docs/**`, `project/**`, necessary associated README/MINIFEST. **No source or workflow edits**.
**Strict read-only:** all `auth/**`, `users/**`, `core/**`, `deployment/**`, `tests/**`, `.gitea/workflows/**`, package manifests/lockfiles, actual Docker/runner config, cloud providers, domains/DNS/SSL/VPS/Coolify, production credentials/files/secrets, untracked `AI_INSTRUCTIONS.md` and unrelated files.
**Read-only goals:** inventory and threat-model production release dependencies and blockers from existing source/docs/accepted CI evidence: pinned reproducible source-built ZITADEL/Login/Account image provenance + SBOM/signing/version/advisory evidence; secure vaulted 32-byte master key/PAT/client/auth cookie secret custody, rotation and IAM_OWNER break-glass separation; encrypted PG backup+verified isolated restore/rollback; canonical `https://auth.vib.tools` HTTPS issuer and distinct `https://account.vib.tools`, precise Auth.js callback/cookies, trusted edge Host/Forwarded and API/Console h2c routing; private networking and TLS termination; first-admin Console/MFA/passkey recovery; deterministic post-deploy live OIDC and multi-app SSO acceptance; operator stop conditions, non-destructive rollback and exact further independent phase Scope Locks. Mark **SOURCE VERIFIED vs CI VERIFIED vs LIVE NOT VERIFIED**, no guess about production availability or actual DNS. Do not retrieve real credentials or run DNS/TLS checks.
**Evidence:** one focused repo/source security/documentation diff audit and exact inventory; no new CI dispatch, no local test, no image build/pull/publish, no service startup, no production edit, no tag or release. Commit/push notes/project/docs only; final Gitea main SHA verification. Provide next implementation phase order and ready-to-copy exact approval for separately authorized production work.
**No P05-OIDC-09 execution without new user approval.**