Webhook auth bypass when webhook_secret is None #56

Closed
opened 2026-03-30 13:28:02 +00:00 by sharang · 1 comment
Owner

When webhook_secret is None on a repository, the webhook handlers silently skip HMAC/token verification and proceed to trigger a full scan. Any unauthenticated POST to /webhook/{type}/{repo_id} will execute the scan pipeline. Fix: Reject with 401 when webhook_secret is None. Use constant-time comparison for GitLab token. Files: webhooks/github.rs, webhooks/gitlab.rs, webhooks/gitea.rs

When webhook_secret is None on a repository, the webhook handlers silently skip HMAC/token verification and proceed to trigger a full scan. Any unauthenticated POST to /webhook/{type}/{repo_id} will execute the scan pipeline. Fix: Reject with 401 when webhook_secret is None. Use constant-time comparison for GitLab token. Files: webhooks/github.rs, webhooks/gitlab.rs, webhooks/gitea.rs
sharang added the securitybugv0.3.0critical labels 2026-03-30 13:28:02 +00:00
Author
Owner

Fixed on main. Every webhook handler fails closed: without a webhook secret the delivery is rejected with 401 before anything runs (let Some(secret) = super::webhook_secret(..) else { return StatusCode::UNAUTHORIZED } in webhooks/github.rs, gitea.rs, gitlab.rs). GitHub and Gitea verify the HMAC with Mac::verify_slice (constant time); GitLab compares the token with subtle::ConstantTimeEq. Landed with #302 (secrets sealed at rest).

Fixed on main. Every webhook handler fails closed: without a webhook secret the delivery is rejected with 401 before anything runs (`let Some(secret) = super::webhook_secret(..) else { return StatusCode::UNAUTHORIZED }` in `webhooks/github.rs`, `gitea.rs`, `gitlab.rs`). GitHub and Gitea verify the HMAC with `Mac::verify_slice` (constant time); GitLab compares the token with `subtle::ConstantTimeEq`. Landed with #302 (secrets sealed at rest).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/pruefwerk#56