Skip to content

fix: prevent silent abort of webhook payload when a single repo validation fails#6360

Open
AftAb-25 wants to merge 1 commit intomindersec:mainfrom
AftAb-25:fix/6359-webhook-batch-abort
Open

fix: prevent silent abort of webhook payload when a single repo validation fails#6360
AftAb-25 wants to merge 1 commit intomindersec:mainfrom
AftAb-25:fix/6359-webhook-batch-abort

Conversation

@AftAb-25
Copy link
Copy Markdown
Contributor

@AftAb-25 AftAb-25 commented Apr 13, 2026

Description

This PR patches a massive loop abort vulnerability inside the GitHub App Webhook processor (processInstallationRepositoriesAppEvent) that was causing data starvation and ghost-access leaks.

When an installation_repositories payload arrives from GitHub, it iterates through both addedRepos and removedRepos to synchronize the installation. Previously, if any single repository failed the basic name or ID parsing validation (e.g. an empty name string), the function would instantly return an error.

This broke three major things:

  1. It instantly returned a 500 error to GitHub, tricking GitHub into repeatedly retrying the exact same webhook payload, crashing on the exact same bad repo every time.
  2. Every subsequent valid repository in the addedRepos batch was completely dropped.
  3. Because the abort happened top-down, the loop never even reached event.GetRepositoriesRemoved(). Any repositories the user explicitly revoked access to in that same batch were ignored, causing Minder to inappropriate retain data access tracking indefinitely.

Changes

  • Swapped the fatal return nil, err across both the added and removed loops with a graceful zerolog warning and a continue.
  • Hardened the repositoryRemoved() signature to proactively validate repo.GetID() != 0 and safely surface errors rather than blinding panicking or injecting zero-values.
  • Added explicit unit tests (app_batch_test.go) validating batch resilience when dropping mixed invalid repositories into both the added and removed slices.

Fixes #6359

Checklist

  • Code compiles cleanly
  • Includes tests for the changes

@AftAb-25 AftAb-25 requested a review from a team as a code owner April 13, 2026 17:14
@AftAb-25 AftAb-25 force-pushed the fix/6359-webhook-batch-abort branch from 0b41aa4 to b58a74b Compare April 13, 2026 17:18
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 13, 2026

Coverage Status

coverage: 59.404% (+0.01%) from 59.39% — AftAb-25:fix/6359-webhook-batch-abort into mindersec:main

@AftAb-25 AftAb-25 force-pushed the fix/6359-webhook-batch-abort branch from b58a74b to 2fca364 Compare April 13, 2026 17:30
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.

Bug: GitHub App Webhook silently drops entire batch of added/removed repositories if a single repo fails validation

2 participants