Skip to content

fix: harden GitLab API redirects and CSRF compatibility - #4

Closed
jonschumaker wants to merge 4 commits into
mainfrom
agent/gitlab-api-hardening
Closed

fix: harden GitLab API redirects and CSRF compatibility#4
jonschumaker wants to merge 4 commits into
mainfrom
agent/gitlab-api-hardening

Conversation

@jonschumaker

Copy link
Copy Markdown
Owner

Summary

  • synchronize jonschumaker/main with upstream CI Runner Farm 1.9.0
  • incorporate Eli Bosley's PR fix(gitlab): stop leaking the API token on redirect and globbing project paths #3 hardening while preserving authorship
  • reject every non-2xx GitLab API response without following redirects, and disable user curl configuration before sending PRIVATE-TOKEN
  • enumerate monitored GitLab projects without pathname expansion while retaining valid dot/underscore-prefixed paths
  • support both legacy Unraid 6.12–7.2 and Unraid 7.3 CSRF prevalidation states

Root cause

Removing curl's location flag prevented the normal redirect path, but curl still returns success for 3xx responses and a user-level .curlrc can re-enable redirects. The endpoint also assumed Unraid always retained a local $csrf_token, which is only true in newer releases.

Validation

  • bash tests/run-linux-checks.sh
  • official GitLab Runner generated-config parse fallback
  • mocked 300–399 responses, redirect-enabling curl options, token redaction, multi-project aggregation, glob inputs, and both Unraid CSRF paths
  • installed dev build 2026.08.06.1357.10-1.9.0-jcuratec.gitlab.dev.4e1e049ad1d5 on Unraid 7.3.0
  • disposable Docker-executor validation passed with no leftover resources
  • real curatec-ai/bedside_assistant jobs completed successfully while the farm autoscaled across three slots

jonschumaker and others added 4 commits August 6, 2026 09:44
* feat: add GitLab runner provider

* fix(gitlab): keep DinD API on private socket

* fix: address provider review feedback

---------

Co-authored-by: Jonathon Schumaker <jon@curatec.ai>
* chore(main): release 1.9.0

* chore(release): prepare plugin metadata

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ect paths

Two narrow hardening fixes on top of the GitLab provider work.

gitlab_api/gitlab_api_capture passed --location while supplying the API
token through `header = "PRIVATE-TOKEN: ..."`. curl strips only the
Authorization header on a cross-host redirect, so a 3xx from a
self-managed instance would resend the token to whatever host it named.
These are plain /api/v4 GETs against the configured base URL and have no
reason to follow a redirect off it, so drop -L.

GITLAB_PROJECTS was iterated as `for project in $GITLAB_PROJECTS`, which
is subject to pathname expansion as well as word splitting. A plausible
entry like `group/*` expands against the process CWD, so the advisory
queue/stats/public-visibility scans would query whatever directory names
happened to match. Split the list with `read -a` instead and emit only
well-formed namespace/project paths. The field is telemetry-only and does
not define runner scope, so a malformed entry is skipped rather than
failing validation and blocking a fleet.

gitlab_stats_refresh reads its project list on fd 3 because its
per-project status scan is itself a `while read` on stdin.
@jonschumaker

Copy link
Copy Markdown
Owner Author

Superseded after upstream sync PR #5 merged: GitHub retained the pre-sync comparison for this PR. Reopening as a fresh five-file hardening PR from the unchanged branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants