Skip to content

ci(security): require committed lockfile for source-mode action builds #893

Closed

Description

@EffortlessSteven

Parent

#876 — ci(security): add a hostile-head-safe review action mode.

Problem

The composite action's source install path regenerates Cargo.lock immediately before a locked build. That allows dependency resolution to drift from the committed source tree and means the action SHA does not freeze the source-build dependency graph.

Target seam

action.yml, function build_from_source() only.

Change source mode to:

  • copy the action source as today;
  • require a committed Cargo.lock;
  • fail closed if the lockfile is missing or stale relative to the copied manifest/workspace;
  • invoke cargo build --locked without any preceding lock regeneration.

Release and path modes must remain behaviorally unchanged.

Acceptance criteria

  • Source mode contains no cargo generate-lockfile or equivalent resolver mutation.
  • Source mode validates that $workdir/Cargo.lock exists and is a regular file before build.
  • Source mode uses cargo build --manifest-path "$workdir/Cargo.toml" --locked ....
  • A missing lockfile fails before Cargo build with an actionable error.
  • A stale lockfile fails closed through Cargo's --locked behavior; proof covers this contract.
  • Release and path branches remain unchanged.
  • Focused tests/static checks cover command ordering and source-only scope.
  • actionlint action.yml, relevant Rust tests, cargo fmt --check, and cargo xtask policy-check pass.
  • Any controlled action metadata change is covered by the existing policy/allow.toml action metadata receipt; no broad policy or threshold changes.

Proof commands

  • Focused action source-mode fixture/static test, including missing and stale lock negative cases.
  • actionlint action.yml (or repo-local equivalent if unavailable).
  • cargo test --locked --test cli focused action assertions.
  • cargo fmt --all -- --check.
  • cargo xtask policy-check.

Non-goals

  • No trusted-base admission, diff ingestion, environment allowlisting, sensor/tool pinning, release/path changes, or broader ci(security): add a hostile-head-safe review action mode #876 implementation.
  • No lockfile regeneration or dependency updates.
  • No workflow, toolchain, gate policy, or threshold changes.

Rollback

Revert the one-file action change. The prior source build remains available, but the security contract is not considered complete until immutable lock admission is restored.

Activity

  1. coderabbitai commented on Aug 20, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #845 - fix(init): validate the first-run smoke path [merged]
    #879 - fix(security): quarantine sensor child environments [merged]
    #883 - ci(security): trusted-base explicit diff admission [open]
    #884 - fix(security): admit trusted-base explicit diffs [open]
    #890 - fix(security): validate trusted explicit diff admission [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. added
    epic
    on Aug 20, 2026
  3. EffortlessSteven commented on Aug 20, 2026

    @EffortlessSteven
    MemberAuthor

    Read-only refresh 2026-08-20: issue remains open; no PR #893 exists (GitHub 404), and no remote codex/893-source-lockfile branch is published. Dedicated worktree E:\Code\Rust3\ub-review-893 remains dirty with uncommitted changes in action.yml and tests/cli.rs atop cad918b05fa98095be4da01e88615b9fc8aca2c1 (current main). Owner work is not safe to hand off or race. Current draft covers lock guard / --locked ordering, but acceptance still needs exact-head commit/PR plus proof of regular-file/stale-lock behavior and required actionlint/policy/test evidence.

  4. EffortlessSteven commented on Aug 20, 2026

    @EffortlessSteven
    MemberAuthor

    Read-only refresh 2026-08-20 09:45 EDT: worktree remains dirty and owner-held; no PR or remote branch. Changes are action.yml + tests/cli.rs atop cad918b. Recent file writes 06:47/06:49 EDT; no owner release. Current draft adds missing-lock guard and --locked ordering, but acceptance still needs regular-file/stale-lock proof and exact-head hosted evidence.

  5. EffortlessSteven commented on Aug 24, 2026

    @EffortlessSteven
    MemberAuthor

    Merge-front position

    #893 remains a single bounded PR and sits in #945 Horizon A containment:

    #946 least-privileged candidate dogfood
    → #893 committed source lockfile / no resolver mutation
    → #947 independent deterministic baseline
    → #948 RevisionIdentity contract
    

    It must remain limited to build_from_source() plus focused contract tests. Do not fold #923 identity, #876 trusted-base work, tool pinning or workflow authority into this patch.

  6. EffortlessSteven commented on Aug 24, 2026

    @EffortlessSteven
    MemberAuthor

    Implementation review packet from current action.yml

    The current build_from_source() copies the Action source into a temporary workdir, then runs:

    cargo generate-lockfile --manifest-path "$workdir/Cargo.toml"
    cargo build --manifest-path "$workdir/Cargo.toml" --locked ...

    That makes --locked largely ceremonial: the candidate dependency graph is resolved immediately before build rather than frozen by the committed source.

    Exact code shape

    After the copy and before any Cargo command:

    lockfile="$workdir/Cargo.lock"
    if [[ -L "$lockfile" || ! -f "$lockfile" ]]; then
      echo "::error::source install requires a committed regular Cargo.lock"
      exit 1
    fi

    Then invoke only:

    cargo build --manifest-path "$workdir/Cargo.toml" --locked --release --target-dir "$cargo_target_dir"

    Do not run generate-lockfile, cargo update, cargo metadata without --locked, or any fallback resolver mutation.

    Scope control

    • Change source mode only.
    • Do not alter release-mode resolution, checksums, archive layout, path mode, Rust toolchain, dependencies, or lockfile contents.
    • Do not extract a new installer subsystem merely to make this one command testable.
    • Preserve the current target-directory/cache behavior.

    Proof expectations

    Use both static contract and behavior:

    1. action contract test proves no resolver mutation precedes the source build;
    2. missing lockfile fails before Cargo;
    3. symlink/directory/non-regular lockfile fails before Cargo;
    4. stale lockfile reaches Cargo and fails through --locked;
    5. valid committed lockfile builds through the source branch;
    6. release/path branches remain byte/behaviorally unchanged in focused fixtures;
    7. actionlint, focused Action/CLI tests, cargo xtask policy-check, format and diff hygiene pass.

    Review stop condition

    Do not make the stale-lock test pass by regenerating or editing the fixture lockfile during execution. The expected behavior is a closed failure proving source admission is immutable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epictest

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions