Skip to content

fix(github): scope 2FA check to selected repos' orgs only#2569

Merged
tofikwest merged 2 commits intomainfrom
fix/github-2fa-skip-unowned-orgs
Apr 16, 2026
Merged

fix(github): scope 2FA check to selected repos' orgs only#2569
tofikwest merged 2 commits intomainfrom
fix/github-2fa-skip-unowned-orgs

Conversation

@tofikwest
Copy link
Copy Markdown
Contributor

@tofikwest tofikwest commented Apr 16, 2026

Problem

The 2FA check was iterating every org returned by /user/orgs — every org the connected GitHub user happens to belong to, regardless of what the customer configured. eighteenlabs saw findings for sisoputnfrba and dds-utn (personal orgs of the connecting account) alongside their own org eighteen-labs.

The "Repositories to monitor" UI selection was effectively ignored — the check never declared target_repos as a variable.

Fix

Derive the org list from ctx.variables.target_repos (same selection the user configures in the integration UI). Drop the /user/orgs call entirely.

Example: selecting eighteen-labs/ato-server, eighteen-labs/app, eighteen-labs/ato-device → checks only eighteen-labs. sisoputnfrba / dds-utn are never touched.

The user-selected list is already filtered to Organization-owned repos by targetReposVariable.fetchOptions, so we don't need to re-validate the org type here.

Why we don't filter /user/orgs instead

We deliberately keep /user/orgs as the source for the selectable repo list (in variables.ts) — that's how customers find all their orgs/repos in the picker. We just don't run the check against everything we discovered; we only check what they explicitly selected.

What changed

  • packages/integration-platform/src/manifests/github/checks/two-factor-auth.ts:
    • Added variables: [targetReposVariable]
    • Replaced /user/orgs fetch with parseRepoBranches(target_repos) → unique owners
    • Reverted the silent 422 skip from the previous commit on this branch — now that the org list comes from explicit user selection, a 422 means the customer selected a repo in an org they don't own, which is a real misconfiguration and should surface as a finding (with remediation).
    • Empty-config now emits "No repositories configured" instead of "No GitHub organizations found"

Verification

  • bun run --filter '@trycompai/integration-platform' build
  • npx turbo run typecheck --filter=@trycompai/integration-platform

Test plan

  • Configure 2FA Enforcement with only eighteen-labs/* repos → only eighteen-labs is checked, no findings for sisoputnfrba / dds-utn
  • Configure with no repos selected → single "No repositories configured" finding
  • Configure a repo in an org where the connected user is a member but not an owner → a "Cannot verify 2FA for {org}" finding with remediation to reconnect with an owner account
  • Configure a SAML-SSO org without authorization → existing SSO finding still emitted

Fixes CS-259

When the connected GitHub user belongs to orgs they don't own,
the 2FA filter returns a 422. Previously this surfaced as a
'Cannot verify 2FA' finding, which confused customers seeing
unrelated orgs in their results (e.g. eighteenlabs seeing
sisoputnfrba and dds-utn).

Now we silently skip these orgs with a log message instead of
emitting a fail finding. The /user/orgs fetch is preserved as-is
to ensure all relevant orgs are discovered.

Fixes CS-259
@linear
Copy link
Copy Markdown

linear bot commented Apr 16, 2026

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Apr 16, 2026 6:23pm
comp-framework-editor Ready Ready Preview, Comment Apr 16, 2026 6:23pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal Skipped Skipped Apr 16, 2026 6:23pm

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/integration-platform/src/manifests/github/checks/two-factor-auth.ts">

<violation number="1" location="packages/integration-platform/src/manifests/github/checks/two-factor-auth.ts:167">
P2: This silent-skip branch can mask real 422/validation errors because the permission detector is too broad. Narrow the skip condition so only confirmed non-owner errors are skipped.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread packages/integration-platform/src/manifests/github/checks/two-factor-auth.ts Outdated
The 2FA check was iterating every org returned by /user/orgs, which
included orgs the connected user happened to belong to but the customer
never selected. eighteenlabs saw findings for sisoputnfrba and dds-utn
(personal orgs of the connecting account) alongside their own org.

Derive the orgs to check from ctx.variables.target_repos instead — the
same selection the user already configures in the integration UI. Drop
the /user/orgs call entirely. The user-selected list is already filtered
to Organization-owned repos by targetReposVariable.fetchOptions.

Reverts the silent 422 skip from b5f9f3d: now that the org list comes
from explicit user selection, a 422 means the customer selected a repo
in an org they don't own — that's a real misconfiguration and should
surface as a finding.

Fixes CS-259

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel vercel bot temporarily deployed to Preview – portal April 16, 2026 18:18 Inactive
@tofikwest tofikwest changed the title fix(github): skip unowned orgs in 2FA check instead of failing fix(github): scope 2FA check to selected repos' orgs only Apr 16, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: Modifies core business logic and data source for a security check (2FA enforcement), changing how scanning targets are derived. Requires human review.

@tofikwest tofikwest merged commit 75630e2 into main Apr 16, 2026
10 checks passed
@tofikwest tofikwest deleted the fix/github-2fa-skip-unowned-orgs branch April 16, 2026 18:28
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.22.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants