Skip to content

Fix(Rbac, Front, guard, github_hooks) limit github account to be linked to only one user account#1098

Open
adbatista wants to merge 30 commits into
mainfrom
adb/github_account
Open

Fix(Rbac, Front, guard, github_hooks) limit github account to be linked to only one user account#1098
adbatista wants to merge 30 commits into
mainfrom
adb/github_account

Conversation

@adbatista

@adbatista adbatista commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📝 Description

PR description as bullets:

Problem

  • Multiple Semaphore users could connect to the same GitHub account — nothing enforced uniqueness on repo_host_accounts, causing nondeterministic user lookups by provider UID, broken login flows, and duplicate users created during OIDC signup.

Changes

  • Add an application-level uniqueness check in guard (mirrored in ee/rbac) that rejects connecting a GitHub account already linked to another user, covering the OAuth connect callback and user-creation paths.
  • Surface a clear "account already connected to another Semaphore user" error on the account page via a new account_taken OAuth error code.
  • OIDC signup skips the conflicting provider link (with a warning logged) instead of failing user creation; gRPC User.Create fails with invalid_argument and rolls back.

✅ Checklist

  • I have tested this change
  • This change requires documentation update

@github-project-automation github-project-automation Bot moved this to Backlog in Roadmap Jul 8, 2026
@adbatista adbatista changed the title Adb/GitHub account Fix(Rbac, Front, guard) limit github account to be linked to only one user account Jul 8, 2026
@adbatista
adbatista marked this pull request as ready for review July 9, 2026 19:18
@adbatista
adbatista force-pushed the adb/github_account branch from b24b174 to 08bc939 Compare July 9, 2026 19:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b24b174bb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread guard/lib/guard/front_repo/repo_host_account.ex
@adbatista
adbatista force-pushed the adb/github_account branch from 7d88e11 to ac41550 Compare July 20, 2026 19:00
adbatista added 10 commits July 23, 2026 15:00
Fixes CVE-2026-59869: quadratic CPU blowup parsing YAML with chained
merge keys in js-yaml <3.15.0. Drop-in upgrade within the existing
semver range; the safeLoad/safeDump API used by the workflow editor is
unchanged.
A claim's Keycloak sync was fire-and-forget: a restart between the claim
commit and task completion lost it, a push that failed past retries left
the GitHub identity attached to nobody, and a failed removal left login
routed to the old owner - with nothing to repair any of it.

Every claim now writes a federated_identity_sync_requests outbox row in
the same transaction that releases the losing rows. The row is deleted
only when the sync fully succeeds; failures and crashes leave it for the
FederatedIdentitySyncDrainer (Quantum, every minute) to lease with
SKIP LOCKED and retry with exponential backoff. Removals are uid-aware
so a retried sync never detaches an identity the loser has since
reconnected, and the push is skipped when a later claim superseded the
row. Identity pushes derived from repo_host_accounts skip uids with a
pending outbox row, closing the path that could attach the same GitHub
identity to two Keycloak users while removals are unconfirmed.
Claims made through rbac write the same federated_identity_sync_requests
outbox rows (in the transaction that releases the losing rows) and mark
completion or failure on them; guard's drainer processes the shared
table, so rbac needs no scheduler of its own. Removals are uid-aware and
identity pushes derived from repo_host_accounts skip uids with a pending
outbox row, mirroring guard.
Collapse the two Credentials stubs into a single receive_messages call;
rubocop failed the Lint job on them.
The floating registry.semaphoreci.com/ruby:3 tag now resolves to ruby
3.4, whose toolchain cannot compile the forked grpc gem's boringssl
extension during the scan's bundle install, so Check dependencies fails
for any change touching github_hooks. Pin the scan to the ruby line the
app actually runs (Dockerfile base ruby:3.3.11, CI prologue sem-version
ruby 3.3) - the configuration that passed when the fork landed in #1114.
Bump loofah 2.25.1 -> 2.25.2 (GHSA-5qhf-9phg-95m2, GHSA-8whx-365g-h9vv,
GHSA-9wjq-cp2p-hrgf) and rails-html-sanitizer 1.7.0 -> 1.7.1
(GHSA-cj75-f6xr-r4g7); both are patch releases inside the existing
Gemfile ranges, lockfile-only change.

Waive GHSA-4phc-fq33-39gx (selenium-webdriver < 4.14.0): test-only
dependency pinned to ~> 2.53; the 4.x move is a breaking Capybara-stack
upgrade tracked separately.

bundle-audit check --update: no vulnerabilities found.
@adbatista adbatista changed the title Fix(Rbac, Front, guard) limit github account to be linked to only one user account Fix(Rbac, Front, guard, github_hooks) limit github account to be linked to only one user account Jul 24, 2026
Resolves the JS dependency scan findings: CVE-2026-59887 (linkify-it
mailto: validator quadratic DoS) and CVE-2026-13676 / CVE-2026-16221
(fast-uri host canonicalization parser differentials). Both are
transitive patch bumps inside the existing semver ranges (markdown-it
^5.0.0, ajv ^3.0.1), lockfile-only; exports verified unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant