Skip to content

pin-ci-job-identity.sh: GET /api/v4/projects/:id returns 404 with JOB-TOKEN on self-hosted GitLab EE #7965

Closed

Description

@ccronca

Summary

Since PR #7817 introduced pin-ci-job-identity.sh (v0.44.0 scaffold), all poll jobs fail at the identity-pinning step. The script calls GET /api/v4/projects/:id with JOB-TOKEN authentication, but this endpoint returns {"message":"404 Project Not Found"}. The endpoint is not listed in GitLab's CI job token access documentation and has no job_token_allowed: true in its route settings (lib/api/projects.rb in GitLab source).

Root cause

pin-ci-job-identity.sh makes three JOB-TOKEN-authenticated API calls after the initial GET /api/v4/job (which succeeds). Diagnostic logging with HTTP status codes and response bodies shows:

INFO: GET /job with JOB-TOKEN succeeded — project_id=143182 pipeline_id=18135424 ref=main
INFO: testing JOB-TOKEN auth against three API endpoints for project 143182
WARN: GET /projects/143182 with JOB-TOKEN — HTTP 404 — falling back to CI variables
WARN: response body: {"message":"404 Project Not Found"}
WARN: GET /projects/143182/repository/branches/main with JOB-TOKEN — HTTP 404
WARN: response body: {"message":"404 Project Not Found"}
INFO: GET /projects/143182/pipelines/18135424 with JOB-TOKEN — HTTP 200 OK
Endpoint HTTP Notes
GET /api/v4/job 200 Correctly returns project_id, pipeline_id, ref
GET /api/v4/projects/:id 404 "Project Not Found" — not listed in GitLab JOB-TOKEN docs
GET /api/v4/projects/:id/repository/branches/:branch 404 "Project Not Found" — listed in GitLab docs (Branches API), but the underlying project resolution fails first
GET /api/v4/projects/:id/pipelines/:id 200 Works

The branches endpoint 404 is not independent — the response body is "Project Not Found" (not branch not found), indicating the project resolution step rejects JOB-TOKEN before the branch lookup runs. The same project returns 200 with a personal access token.

Observed behaviour

fullsend slash poll (pipeline 18131668 / job 62521240) and fullsend event poll (pipeline 18131669 / job 62521241) fail identically:

fullsend version 0.44.0
$ . "${CI_PROJECT_DIR:-.}/.gitlab/ci/scripts/run-poll-job.sh"
curl: (22) The requested URL returned error: 404
curl: (22) The requested URL returned error: 404
curl: (22) The requested URL returned error: 404
curl: (22) The requested URL returned error: 404
ERROR: cannot read pinned project 143182 — aborting (fail-closed)

The four curl lines are --retry 3 --retry-delay 2 --retry-all-errors exhausted on GET /api/v4/projects/143182 with JOB-TOKEN.

  • GitLab: self-hosted EE 19.2.7
  • fullsend: v0.44.0

Related

Activity

  1. waynesun09 commented on Oct 2, 2026

    @waynesun09
    Member

    /fs-triage

  2. fullsend-ai-triage commented on Oct 2, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 11:28 AM UTC · Completed 11:31 AM UTC

    Commit: 406b794 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.46

  3. added
    type/bug
    priority/critical
    component/dispatch
    component/ci
    security
    ready-to-code
    on Oct 2, 2026
  4. fullsend-ai-triage commented on Oct 2, 2026

    @fullsend-ai-triage

    Thank you for the detailed diagnostics — the endpoint-by-endpoint breakdown with HTTP statuses and response bodies makes this straightforward to act on.

    This traces back to ADR 0125's own Caveats section, which flags verifying CI_JOB_TOKEN running-job-identity behavior against the target GitLab version as an open, ship-gating item before the fast-path shipped — this issue appears to be exactly that gap surfacing for GET /api/v4/projects/:id on self-hosted EE 19.2.7. No open PR currently addresses this, and the two referenced issues (#7769, the hardening epic, and #7892, a prior self-hosted EE incompatibility in the same gate) are both already closed, so there are no outstanding blockers here.

    A plausible fix direction: since the project/pipeline/ref identity is already pinned from the trusted GET /job JOB-TOKEN response before the failing call, the subsequent project-detail and branch-protection lookups may not need JOB-TOKEN auth at all — the already-provisioned Poller-role PAT could serve those reads instead, preserving fail-closed semantics without relying on an endpoint self-hosted EE apparently doesn't expose to JOB-TOKEN callers.

    Test: mock a GitLab API where JOB-TOKEN succeeds on GET /job and GET /projects/:id/pipelines/:id
          but returns 404 on GET /projects/:id (matching EE 19.2.7 behavior).
    Expected: identity pinning either succeeds via an alternate authenticated path, or fails closed
              with a specific, actionable error (not a generic retry-exhaustion message).
    Also cover: the existing GitLab.com-compatible case where JOB-TOKEN succeeds on /projects/:id,
                to guard against regressing the currently-working path.
    

    Labels: Matches this repo's pattern for confirmed, high-impact self-hosted GitLab EE defects in the CI identity/dispatch gate family (e.g. #7892, #7409): a critical, security-relevant bug in the dispatch/CI pipeline area, ready for automatic fix dispatch.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  5. fullsend-ai-coder commented on Oct 2, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 11:34 AM UTC · Completed 11:51 AM UTC

    Commit: 406b794 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.03

  6. added 2 commits that reference this issue on Oct 2, 2026
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

    bugcomponent/cicomponent/dispatchpriority/criticalready-to-codesecuritytype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions