fix: add webhook authentication validation for GitLab and Forgejo providers#411
Open
sahu-virendra-1908 wants to merge 3 commits into
Open
Conversation
Signed-off-by: sahu-virendra-1908 <virendrashivsahu@gmail.com>
Signed-off-by: sahu-virendra-1908 <virendrashivsahu@gmail.com>
…ders GitLab: - Validate X-Gitlab-Token against configured webhook secret Forgejo/Gitea: - Validate X-Gitea-Signature using HMAC-SHA256 This prevents unauthenticated webhook requests from creating, modifying, or triggering issue and pull request workflows. Signed-off-by: sahu-virendra-1908 <virendrashivsahu@gmail.com> git log -1#:wq
31d3690 to
57bf80a
Compare
Author
|
@Ronit-Raj9 @Parvm1102 @vibhor-5 Please review this PR. This PR adds authentication validation for GitLab and Forgejo webhook endpoints in Previously, webhook requests from GitLab and Forgejo could be processed without validating provider-specific authentication headers. This could allow unauthenticated webhook payloads to reach event-processing logic and trigger downstream workflows. Changes included in this PR:
If any improvements, corrections, or additional changes are needed, please let me know and I will update the PR accordingly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds authentication validation for GitLab and Forgejo webhook endpoints before processing incoming webhook events.
Previously, GitLab and Forgejo webhook handlers accepted and processed webhook payloads without verifying the authenticity of the request. This could allow unauthorized requests to trigger webhook processing, create or update issue records, and invoke downstream agent workflows.
This change introduces provider-specific webhook authentication checks and rejects invalid requests with HTTP 401 Unauthorized before any event processing occurs.
Related Issue
Fixes #407
Type of Change
Changes Made
GitLab Webhook Validation
Added webhook token validation using the
X-Gitlab-Tokenheader.validateGitLabToken()crypto.timingSafeEqual()for secure comparisonForgejo Webhook Validation
Added webhook signature validation using the
X-Gitea-Signatureheader.validateForgejoSignature()Webhook Processing Protection
Authentication is now enforced before:
Unauthenticated requests now receive:
401 Unauthorizedinstead of being processed.
Security Impact
This change mitigates a vulnerability where GitLab and Forgejo webhook endpoints could process unauthenticated requests.
Without validation, a malicious actor could potentially:
The new validation layer ensures that only requests originating from configured forge providers are accepted.
How Was This Tested?
Notes:
CE & Security Check
Screenshots / Demos (if UI or UX)
N/A – Backend security fix.
Checklist