Files
ZitPlane/notes/P05-OIDC-10.md
T

16 KiB

P05-OIDC-10 — CI-Only Imported Login OCI Provenance & Reproducible Build Gate

Date: 2026-11-23 Asia/Dhaka; approved baseline: f06773b39322f14b7bae48850574c1243420e7ec, independently matched Gitea main; starting tracked inventory: 793, full tree not truncated.

EXACT PRE-SOURCE SCOPE LOCK — MUST COMMIT THIS NOTE FIRST

SOURCE WRITE ONLY:

  • NEW tests/ci/login_image/provenance.py — stdlib-only read-only git/input provenance checks, image metadata/SBOM materials, fail-closed mutation negatives;
  • NEW tests/ci/login_image/provenance-lock.json — finite immutable upstream-source and base index digest pins;
  • NARROW existing tests/ci/login_image/build.sh — opt-in provenance mode for pinned builder/runtime base image and temporary Dockerfile ONLY; existing Run #99 default path must remain unchanged;
  • NEW .gitea/workflows/p05-login-provenance.yml — manually dispatched single disposable CI job, owned-only teardown, no registry/production.

ASSOCIATED DOCUMENTATION WRITE: tests/ci/login_image/{README.md,MINIFEST.md}, .gitea/workflows/{README.md,MINIFEST.md}, notes/**, relevant project/**, docs/**, and necessary root README/MINIFEST. All other paths READ ONLY.

STRICT READ-ONLY: auth/** (imported upstream Login source, Dockerfile, entrypoint and lock unchanged), users/**, core/**, all deployment/**, all preexisting .gitea/workflows/*.yml including Run #99 and Run #105 workflows, all other tests/** including tests/ci/login_image/cleanup.sh, all package manifests/lockfiles, runner config, external VPS/Coolify/Cloudflare/DNS/SSL/production infrastructure/secrets, unrelated files and untracked AI_INSTRUCTIONS.md (never inspect or touch).

NO: source vendor modifications, production/live user or secret access, infrastructure deployment, public TLS/DNS, release or tag, registry push, private signing key, protected runner configuration; no local app build/test. Exactly ONE new Gitea manual disposable CI run after one focused source/security/diff audit, no rerun/post-dispatch code edit if failed. CI may pull specifically pinned public base images and temporarily build/run an isolated nonnetwork probe; existing run-owned cleanup must execute with always() after success/failure. No previous accepted workflow CI rerun.

Read-only facts and immutable input references

  • Prior accepted Run #99, Job #214 COMPLETED SUCCESS on 7d6b6d0704b9e39bcb6e74257dadf0b64a19fc0f: original imported custom Login image built in run-owned Node22/bookworm builder, original next standalone, entrypoint copied 644→755 in temporary context, real Chromium OIDC/PKCE/Auth.js acceptance, owned cleanup; temporary image removed. Existing tests/ci/login_image/{build.sh,cleanup.sh} must not alter its prior mode.
  • Accepted Run #105 48/48 synthetic-only security negatives PASS. Neither CI establishes public production release.
  • Gitea Git tree auth/ui/v2 76683086acb5d4ccf3b2094f894e19a8aa0fafa9; pnpm-lock.yaml blob d37471c041f45aad4c1403c628d175b7ca984032; original apps/login/Dockerfile c737bef057035882a0ca959bc641ead6ffb9cc5b with FROM node:24-alpine mutable tag; apps/login/scripts/entrypoint.sh blob 2da2aca45348afeb7480323e02cf98902d479db3 mode 100644; root package.json blob f9a180ba5ee73b126f668537d4695da6dd7c2e70 (pnpm@10.30.3). Imported upstream source revision from auth/ui/v2/README.md: 384bb9ec96b501ad39dc232ee2061a40fe180bbd, tag v4.20.4. This is source-attested import metadata, not independently re-fetched upstream in this phase.
  • External public Docker Hub metadata read-only on 2026-11-23: library/node:22-bookworm OCI index digest sha256:e13726ca604184d7a91fcacab1fc09eefd642dc28e79ac34e85540dd93b78cfb (linux/amd64 child sha256:69c6e263db01e9946c7743bbbe9f7b1ba0df384d27ec09e08e5832d6acd3daf3); library/node:24-alpine OCI index digest sha256:116b800c3754b440ee0aa3ed2f20f5bf3d99a554bfd9adeea09ea8017f6e85f5 (amd64 child sha256:d8d97e479cdc64f052f81f129362168717c59783ade8dcc1abd22e1cca8dbd7c). These are manifest-index identities observed externally, not Gitea Docker runtime confirmations, and must be fetched/checked by the newly approved disposable CI. Pin linux/amd64; fail closed if architecture, digest or runtime contents disagree.

Implementation and acceptance plan

  1. Add a strict normalized JSON lock whose exact keys pin source tree/blob, public OCI index+amd64 child identity, platform, package manager, upstream tag/revision. Fail on substituted/unknown inputs or mismatched Git tree/lock/Dockerfile blobs; record exact source checkout SHA in attestation. New workflow runner itself uses a pinned, public node:24-alpine index (no secret access), builder uses node:22-bookworm@sha256:....
  2. Existing build.sh must remain unchanged in default Run #99 mode. Under ZITPLANE_PROVENANCE_CI=1 only: verify preflight and digests; pull/create pinned builder, pinned temporary Dockerfile FROM node:24-alpine@sha256:... without editing original Dockerfile, build frozen workspace pnpm@10.30.3, emit no credential values, temporary entrypoint 0755 only, check built image ID/platform/nonroot/labels/entrypoint, generate source/base/dependency-material SPDX-lite SBOM and sanitized JSON attestation inside run-owned temporary build context (no upload or publish). Explicitly label SBOM metadata is partial material inventory, NOT comprehensive package/OS SCA; later release requires full scanner and signed artifacts.
  3. Focused negative fixture scenarios: altered source SHA/lock blob/base digest, unexpected Dockerfile bytes, wrong platform and unauthorized image attributes or invalid grant of build credentials (all local in-memory fail closed). Ensure stage markers and final job status contain no tokens/env dumps.
  4. New workflow workflow_dispatch only, read-only contents permission, one job, no production secrets/registry credentials, one disposable build plus a nonnetwork nonroot probe, same run-owned cleanup.sh inside always(), safe exact cleanup verification and no background/image retention. No real browser/OIDC rerun or production runtime; Run #99 remains separate accepted evidence.
  5. Before CI: ONE focused source/security/exact-diff audit. Commit/push tested source SHA, dispatch ONE newly approved manual run. Verify frozen lock build, immutable source/index identities, nonroot/entrypoint, SPDX-lite materials/attestation and fail-closed negatives, known cleanup. If CI fails, record FAIL/NOT EXECUTED, no repeat or source patch.
  6. Synchronize notes/project/docs, source inventory, workflow/image helper README/MINIFEST, final cumulative scope/security audit, docs commit/push and exact remote HEAD SHA. Distinguish CI source SHA from documentation-closure SHA.

P05-OIDC-10 does NOT certify production deployment, signed registry image, public DNS/TLS, master key/backup, Console/MFA/passkeys or multi-app SSO. Next independent Account OCI/production security work requires a new approval.

Terminal one-run forensic acceptance — P05-OIDC-10

Scope-first commit: 539c7d019d6b238e2214afcbfb59423ed7294175 BEFORE source edits. Only the originally approved five phase paths changed before dispatch: notes/P05-OIDC-10.md, new tests/ci/login_image/{provenance.py,provenance-lock.json}, narrowly opt-in updated tests/ci/login_image/build.sh, new .gitea/workflows/p05-login-provenance.yml. All imported auth/**, Account, core, deployment, existing workflows, existing cleanup.sh, package locks/manifests, runner and live infrastructure read-only. Pre-run exact file/security diff check PASS, no unauthorized path.

Exactly ONE CI dispatch: Gitea Run #106 / Job #222, source 6ba004808ef47c8856c1a7906faaf7ee807d15a6, 2026-11-23T17:40:18Z through 17:45:16Z. Terminal COMPLETED / FAILURE. Steps: #0 tooling SUCCESS, #1 immutable checkout 6ba004808ef47c8856c1a7906faaf7ee807d15a6 SUCCESS, #2 source pin/12 negative fixtures SUCCESS, #3 pinned OCI build + attestation FAILURE, #4 always() exact owned cleanup SUCCESS. No second run or post-CI source patch.

Terminal gate ledger

Exact gate Verified result
Approved Git source checkout 6ba004808ef47c8856c1a7906faaf7ee807d15a6 and immutable imported source-tree/PNPM lock/Dockerfile/entrypoint Git object identities PASS ZITPLANE_P10_SOURCE_TREE_GIT_AND_LOCK_PIN_PASS
Public OCI base index pin in CI job node:24-alpine@sha256:116b800c… and source lock builder node:22-bookworm@sha256:e13726ca… PASS actual runner/runtime pull and pinned builder source check
Git/OCI provenance negative in-memory fixtures 12/12 PASS ZITPLANE_P10_ALL_12_PROVENANCE_NEGATIVES_PASS
Root PNPM lock installation pnpm@10.30.3 on 4 workspace projects, 1121 packages, resolution skipped PASS ZITPLANE_CUSTOM_LOGIN_FROZEN_INSTALL_PASS
Nested Login build toolchain OBSERVED: Corepack also fetched nested Login-package hash-qualified pnpm@10.28.2 during Nx @zitadel/login:build; distinct from root pnpm@10.30.3. Exact frozen graph unchanged; reconcile future release toolchain evidence, don't claim one version for every invocation
Proto generate, JS client build and Next.js 16.4.6 standalone optimized production Login build/Server Actions allowlist PASS ZITPLANE_CUSTOM_LOGIN_STANDALONE_BUILD_PASS
Upstream Edge instrumentation WARNING only: imported server module imports Node crypto/fs in Edge compile traces; build still PASS, runtime compatibility requires independent review before release
Entry point copied mode 644, owner 0:0, temporary copy fixed to 0755 PASS ZITPLANE_CUSTOM_LOGIN_TEMP_ENTRYPOINT_MODE_FIXED_PASS, ZITPLANE_CUSTOM_LOGIN_ENTRYPOINT_COPY_EXECUTABLE_PASS
Original Dockerfile temporary-copy immutable runtime FROM node:24-alpine@sha256:116b800c… PASS ZITPLANE_P10_DISPOSABLE_DOCKERFILE_BASE_DIGEST_PIN_PASS, Docker daemon recorded exact index digest during OCI build
Source-labeled local OCI build PASS ZITPLANE_CUSTOM_LOGIN_LOCAL_IMAGE_BUILT_PASS; image ID sha256:9ddaccf7f6e60e6d72d580de6b285df697d1404cc8f48e5d2719953a4ea69078, strictly disposable
No-network temporary nonroot image entrypoint probe PASS ZITPLANE_CUSTOM_LOGIN_BUILT_IMAGE_ENTRYPOINT_EXECUTABLE_PASS; no Login service or real user was started
Pinned builder OS/architecture/index match PASS ZITPLANE_P10_PINNED_BUILDER_OS_ARCH_INDEX_PASS
Final OCI image environment-key policy FAIL ZITPLANE_P10_FAIL_CLOSED_IMAGE_SECRET_ENV_KEY — exact rejected env key NOT LOGGED/UNKNOWN
Final image source-label/entrypoint/nonroot validation Partial: validator traversed earlier checks before env fail but did not complete the full image-provenance gate; no ZITPLANE_P10_IMAGE_ID_NONROOT_ENTRYPOINT_PROVENANCE_PASS marker
materials.spdx.json partial source/base-material SBOM and unsigned provenance.json NOT EXECUTED / NOT EMITTED — verifier aborted at env policy before file generation; workflow file-presence gate not reached
Final workflow ZITPLANE_P10_NO_REGISTRY_PUBLISH_OR_APPLICATION_SERVICE_CONFIGURED_PASS marker NOT EXECUTED (after failed build step); read-only workflow audit verifies no docker push, docker login, production service up/registry secrets
Existing cleanup.sh run-owned builder/image/context exact teardown PASS ZITPLANE_CUSTOM_LOGIN_ALL_BUILD_RESOURCES_CLEANED_PASS, always() job step SUCCESS
Gitea runner ephemeral job container/2 volumes/job network cleanup PASS as runner job-log evidence; independent of local application image cleanup, does not prove Docker base-cache absence
Signed/released registry image, full transitive/OS SBOM, runtime real OIDC, TLS/DNS/MFA/Admin Console/multiapp SSO, production deployment NOT EXECUTED / OUT OF SCOPE

Root-cause precision / stop condition

A fail-closed environment-key policy blocked an otherwise successfully built and probe-executable image at IMAGE_SECRET_ENV_KEY. The Python code's denied = re.compile(r"(SECRET|PASSWORD|TOKEN|PAT|MASTERKEY|DATABASE|AUTH_|PRIVATE_KEY)", re.I) checks unanchored substrings in image environment variable names. An ordinary OCI PATH starts with substring PAT, so it is a strong plausible false positive (standard Node images contain PATH); however the validator intentionally did not log the exact key, so the actual failing env key is UNKNOWN. Do NOT assert PATH is confirmed without an allowlisted safe key-type diagnostic in another separately approved run. No env values, credentials or full image-inspect JSON were exposed.

P05-OIDC-10 terminal verdict: PARTIAL CI PASS / FULL OCI PROVENANCE ACCEPTANCE FAILED. Immutable imported source tree, pinned builder and runtime OCI index use, frozen workspace build, temporary entrypoint and local image ID VERIFIED, 12 security-negative fixtures PASS; final environment-policy, partial SBOM and unsigned provenance artifact gates BLOCKED / NOT EXECUTED. No registry push, production services, tag, release, production TLS or secrets. Accepted separate Run #99 custom Login disposable real OIDC and Run #105 48/48 static contract remain SUCCESS and unchanged.

Proposed separately approved next exact Scope Lock — P05-OIDC-10-A01

Title: Safe OCI Environment-Key Boundary RCA & Existing Run #106 Provenance Acceptance.

Baseline: final P05-OIDC-10 documentation closure Gitea main SHA (verify at closure); tested source 6ba004808ef47c8856c1a7906faaf7ee807d15a6; prior Run #106 / Job #222 COMPLETED FAILURE.

  1. Commit notes/P05-OIDC-10-A01.md FIRST, explicit approved exact Scope Lock before any new source edits. Explain baseline Run #106 and uncertain exact env key; do not assume PATH.
  2. SOURCE WRITE ONLY: tests/ci/login_image/provenance.py. Do NOT alter provenance-lock.json, build.sh, cleanup.sh, new or old .gitea/workflows/*.yml, imported source, Dockerfile, package lock/manifests, runner or any other source.
  3. DOCS WRITE: notes/**, relevant project/**, docs/**, necessary associated tests/ci/login_image/{README,MINIFEST}.md, .gitea/workflows/{README,MINIFEST}.md and root README/MINIFEST as needed. All auth/**, users/**, core/**, deployment/**, other tests/workflows/manifests/locks, runner/production DNS/VPS/Coolify/SSL/secrets STRICT READ ONLY; untracked AI_INSTRUCTIONS.md untouched.
  4. Evidence-first safe diagnosis: print only fixed allowlisted OCI environment key names such as PATH, NODE_VERSION, YARN_VERSION, NODE_ENV, HOSTNAME, PORT, NODE_OPTIONS, SSL_CERT_FILE, ZITADEL_TLS_ENABLED, OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_PROTOCOL, and fixed UNKNOWN_KEY_PRESENT/known-sensitive-class flags for others. Never print values, arbitrary keys, Docker inspect JSON or credentials. Diagnose actual key flagged by current matcher.
  5. If justified, replace overly broad substring matching with strict token/segment boundaries, retaining fail-closed detection for AUTH_SECRET, ZITADEL_MASTERKEY, ZITADEL_SERVICE_USER_TOKEN, LOGIN_CLIENT_PAT, DB passwords, private keys, unknown secret material, dangerous environment injection. Retain all previous 12 security-negative assertions and add focused innocuous PATH acceptance + true-secret positive rejection fixtures with exact expected failure codes.
  6. One focused pre-run source/security/diff audit, source commit/push tested SHA, exactly one separately approved manual run of unchanged p05-login-provenance.yml (no rerun Run #106). Check pinned source/OCI digests, frozen PNPM/Next standalone build, entrypoint, nonroot labels/env, 12+ negatives, partial SPDX materials + unsigned attestation, exact owned cleanup and no registry/deployment; log PASS/FAIL/NOT EXECUTED. On failure stop; no second CI/post-run patch.
  7. Sync docs/manifests/inventory, exact final cumulative audit and Gitea main SHA. No image publishing, signing keys, actual DNS/TLS/users/secrets, production, release/tag, local app tests, or user-visible data exposure.

No A01 execution without new user approval.