security(ci): require functional Forgejo checks and isolate executable build caches #1400

Closed
opened 2026-10-04 12:39:00 +00:00 by PlasticDigits · 3 comments
Owner

Summary and severity

High conditional supply-chain impact; Medium missing regression enforcement. Actual protected-branch checks must enforce functional security regressions and prevent untrusted executable build inputs from crossing into releases.

Internal review references: KIMIK3 SEC-06/07/08/12, TST-02; chains B/I/R. Investigated against source revision 748579ab718026efad54afcef4b2a5186fe82662 on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published.

Current codebase and evidence

The protected Forgejo Woodpecker context currently executes gitleaks only; header explicitly leaves contracts/frontend/indexer local. GitLab has functional jobs but branch-fixed cache keys and floating base tags. Contract optimizer selects workspace-optimizer:0.16.1 without a digest; Docker build bases also have tag-only references. Existing Woodpecker Alpine image and downloaded gitleaks checksum are pinned and must remain so.

An untrusted MR can influence shared writable executable/cache inputs under applicable runner settings; exact exploitability depends on protected-cache separation and fork permission policy. A green secret scan is not proof of functional correctness. No poisoned CI image/cache or agent compromise was attempted.

Why a new implementation is needed

Actual protected-branch checks must enforce functional security regressions and prevent untrusted executable build inputs from crossing into releases.

Constraints and guardrails

  • Keep gitleaks/checksums, no force_merge or manually fabricated successful status, no credentials on untrusted PR jobs.
  • Do not run root Cargo against bind-mounted repository targets; preserve optimizer named target volume and runtime identity.
  • Bound E2E resource costs and distinguish source tests from production migration; no requirement for new human approvals.

Relevant files

  • Add bounded contract/frontend/indexer functional jobs to the actual required Forgejo workflow, including an isolated Postgres integration subset and security-critical LocalTerra E2E policy.
  • Scope caches by trust boundary/revision/lockfile/toolchain, use read-only untrusted PR cache access or isolated caches, and avoid reusing untrusted executable target artifacts for releases.
  • Digest-pin reviewed optimizer/build images and verify release artifact provenance independently of cache outputs.
  • Verify remote branch requirements and actual CI-generated statuses; fix broken policy links and document what jobs are mandatory versus scheduled.

Acceptance criteria

  • A deliberately failing security-critical contract/frontend/indexer assertion prevents merge through the actual configured Forgejo required context.
  • Untrusted PR cannot write executable caches used by trusted main/release; same lockfile across different trust levels stays isolated.
  • Optimizer/build inputs are immutable reviewed digests and release bytecode receipts identify source/toolchain.
  • At least documented critical LocalTerra signing/rollback E2E runs as a required or explicit scheduled policy with failure ownership; no claim that existing 70 specs already run in CI.

Test plan: supported and failure paths

  • Run green and deliberate-red draft PRs with source changes, docs-only changes and missing/skipped jobs; inspect real status provenance and branch protection readback.
  • Validate fork/trusted-main cache configuration and lockfile/toolchain cache changes; cold/warm builds must match expected behavior.
  • Run hermetic contract/frontend/indexer suites, dedicated Postgres tests and synthetic LocalTerra funding/rollback E2E; verify all public logs are scrubbed.

Test plan: attack, hack and abuse vectors

  • Use synthetic cache markers/corrupted target artifacts in isolated CI, never real malicious code; trusted builds must refuse/rebuild them.
  • Try deleting functional steps/statuses in PR YAML, reusing a shared cache key and missing-job-success semantics; required trusted policy must block acceptance.
  • Verify untrusted issue text/PR content cannot cause release commands or secret disclosure, and unauthorized image substitutions fail integrity checks.

Verification criteria

  • Current workflow/cache/image declarations were source-checked; serial lib tests pass but the independently reproduced cache-test flake must also be repaired.
  • Require real failing-PR merge-block receipts, cache trust-boundary tests and pinned artifact provenance, not local tests or hand-written commit statuses.
    Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets.

Closed #1247 explicitly accepted gitleaks-only and deferred functional porting; closed #421/#696 target GitLab and do not prove current Forgejo functional enforcement. This bundles the missing Forgejo follow-up and executable-input trust controls.

1394: discovery-cache, 1396: database-isolation. Each report owns its stated acceptance scope.

## Summary and severity High conditional supply-chain impact; Medium missing regression enforcement. Actual protected-branch checks must enforce functional security regressions and prevent untrusted executable build inputs from crossing into releases. Internal review references: KIMIK3 SEC-06/07/08/12, TST-02; chains B/I/R. Investigated against source revision `748579ab718026efad54afcef4b2a5186fe82662` on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published. ## Current codebase and evidence The protected Forgejo Woodpecker context currently executes gitleaks only; header explicitly leaves contracts/frontend/indexer local. GitLab has functional jobs but branch-fixed cache keys and floating base tags. Contract optimizer selects workspace-optimizer:0.16.1 without a digest; Docker build bases also have tag-only references. Existing Woodpecker Alpine image and downloaded gitleaks checksum are pinned and must remain so. An untrusted MR can influence shared writable executable/cache inputs under applicable runner settings; exact exploitability depends on protected-cache separation and fork permission policy. A green secret scan is not proof of functional correctness. No poisoned CI image/cache or agent compromise was attempted. ## Why a new implementation is needed Actual protected-branch checks must enforce functional security regressions and prevent untrusted executable build inputs from crossing into releases. ## Constraints and guardrails - Keep gitleaks/checksums, no force_merge or manually fabricated successful status, no credentials on untrusted PR jobs. - Do not run root Cargo against bind-mounted repository targets; preserve optimizer named target volume and runtime identity. - Bound E2E resource costs and distinguish source tests from production migration; no requirement for new human approvals. ## Relevant files - [.woodpecker.yaml](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/.woodpecker.yaml) - [.gitlab-ci.yml](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/.gitlab-ci.yml) - [smartcontracts/scripts/optimize.sh](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/smartcontracts/scripts/optimize.sh) - [docker/indexer/Dockerfile](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/docker/indexer/Dockerfile) - [docs/supply-chain-security.md](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/docs/supply-chain-security.md) - [docs/runbooks/forgejo-pr-merge.md](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/docs/runbooks/forgejo-pr-merge.md) - [docs/testing.md](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/docs/testing.md) ## Recommended direction - Add bounded contract/frontend/indexer functional jobs to the actual required Forgejo workflow, including an isolated Postgres integration subset and security-critical LocalTerra E2E policy. - Scope caches by trust boundary/revision/lockfile/toolchain, use read-only untrusted PR cache access or isolated caches, and avoid reusing untrusted executable target artifacts for releases. - Digest-pin reviewed optimizer/build images and verify release artifact provenance independently of cache outputs. - Verify remote branch requirements and actual CI-generated statuses; fix broken policy links and document what jobs are mandatory versus scheduled. ## Acceptance criteria - [ ] A deliberately failing security-critical contract/frontend/indexer assertion prevents merge through the actual configured Forgejo required context. - [ ] Untrusted PR cannot write executable caches used by trusted main/release; same lockfile across different trust levels stays isolated. - [ ] Optimizer/build inputs are immutable reviewed digests and release bytecode receipts identify source/toolchain. - [ ] At least documented critical LocalTerra signing/rollback E2E runs as a required or explicit scheduled policy with failure ownership; no claim that existing 70 specs already run in CI. ## Test plan: supported and failure paths - Run green and deliberate-red draft PRs with source changes, docs-only changes and missing/skipped jobs; inspect real status provenance and branch protection readback. - Validate fork/trusted-main cache configuration and lockfile/toolchain cache changes; cold/warm builds must match expected behavior. - Run hermetic contract/frontend/indexer suites, dedicated Postgres tests and synthetic LocalTerra funding/rollback E2E; verify all public logs are scrubbed. ## Test plan: attack, hack and abuse vectors - Use synthetic cache markers/corrupted target artifacts in isolated CI, never real malicious code; trusted builds must refuse/rebuild them. - Try deleting functional steps/statuses in PR YAML, reusing a shared cache key and missing-job-success semantics; required trusted policy must block acceptance. - Verify untrusted issue text/PR content cannot cause release commands or secret disclosure, and unauthorized image substitutions fail integrity checks. ## Verification criteria - Current workflow/cache/image declarations were source-checked; serial lib tests pass but the independently reproduced cache-test flake must also be repaired. - Require real failing-PR merge-block receipts, cache trust-boundary tests and pinned artifact provenance, not local tests or hand-written commit statuses. Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets. ## Related work and duplicate check Closed #1247 explicitly accepted gitleaks-only and deferred functional porting; closed #421/#696 target GitLab and do not prove current Forgejo functional enforcement. This bundles the missing Forgejo follow-up and executable-input trust controls. ## Related remediation reports [1394: discovery-cache](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1394), [1396: database-isolation](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1396). Each report owns its stated acceptance scope.
Author
Owner

Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation.

Remaining implementation: Implement functional Forgejo checks and isolate executable build caches. CI is explicitly skipped for this user-requested merge sweep; no fabricated status or CI PASS is claimed. This issue stays open for that substantive work, not merely a verification hold.

Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation. Remaining implementation: Implement functional Forgejo checks and isolate executable build caches. CI is explicitly skipped for this user-requested merge sweep; no fabricated status or CI PASS is claimed. This issue stays open for that substantive work, not merely a verification hold.
Author
Owner

PR #1414 and the final integration PR #1423 are merged into main. Source acceptance: 944 contract tests + strict all-target Clippy, 858 indexer tests across 29 suites, and 3,093 frontend tests + lint/build. Fresh pinned optimizer verification passed. Full receipt.

The bounded client-owned discovery implementation supersedes the older global-cache patch from this PR. Functional runner (10) and build-input (8) checks plus 13 immutable declarations pass. Hosted CI was explicitly skipped; original protection settings were restored. Daily/release operations remain #1421.

CI was skipped by explicit operator instruction. Native wrap-stack and production execution remain explicitly unverified. Deployment/history/release work is transferred to #1421 and existing #1384/#1385/#1386; the default query-gas repair is #1422. The source issue is complete and carries no verification-only hold; closure does not claim production deployment.

PR #1414 and the final integration PR #1423 are merged into main. Source acceptance: 944 contract tests + strict all-target Clippy, 858 indexer tests across 29 suites, and 3,093 frontend tests + lint/build. Fresh pinned optimizer verification passed. [Full receipt](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-06/README.md). The bounded client-owned discovery implementation supersedes the older global-cache patch from this PR. Functional runner (10) and build-input (8) checks plus 13 immutable declarations pass. Hosted CI was explicitly skipped; original protection settings were restored. Daily/release operations remain #1421. CI was skipped by explicit operator instruction. Native wrap-stack and production execution remain explicitly unverified. Deployment/history/release work is transferred to #1421 and existing #1384/#1385/#1386; the default query-gas repair is #1422. The source issue is complete and carries no verification-only hold; closure does not claim production deployment.
Author
Owner

Cleanup after the October 8 merge sweep: the four obsolete deliberate-red probe branches/worktrees associated with already closed PRs #1415–#1418 were removed locally and remotely. Their failing assertions and deleted CI policy files were not merged. Existing evidence and PR history remain available. CI was explicitly skipped for this sweep, and original main protection settings were restored after the narrowly scoped stale-branch override for #1448. This completed issue remains closed.

Cleanup after the October 8 merge sweep: the four obsolete deliberate-red probe branches/worktrees associated with already closed PRs #1415–#1418 were removed locally and remotely. Their failing assertions and deleted CI policy files were not merged. Existing evidence and PR history remain available. CI was explicitly skipped for this sweep, and original main protection settings were restored after the narrowly scoped stale-branch override for #1448. This completed issue remains closed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/cl8y-dex-terraclassic#1400
No description provided.