TooAngel / TooAngel/worlddriven
Implement GitHub webhook signature validation
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 18
- Forks
- 15
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 5
Description
Summary
Currently the GitHub webhook endpoint at accepts all webhook requests without validating they come from GitHub. This is a security risk as malicious actors could send fake webhook events.
Requirements
- Validate GitHub webhook signatures using HMAC-SHA256 and the GITHUB_WEBHOOK_SECRET environment variable
- Reject webhooks with invalid or missing signatures with HTTP 401
- Log security events for monitoring
Implementation Details
The webhook signature validation should:
- Read the
X-Hub-Signature-256header from incoming webhook requests - Calculate HMAC-SHA256 of the request body using GITHUB_WEBHOOK_SECRET
- Compare the calculated signature with the provided signature using constant-time comparison
- Return HTTP 401 for invalid signatures before processing the webhook
Security Benefits
- Prevents webhook spoofing attacks
- Ensures webhook events are authentic GitHub requests
- Protects against unauthorized repository manipulation
Environment Variables
The GITHUB_WEBHOOK_SECRET environment variable is already configured in production.
Files to Modify
src/index.js- Add signature validation middleware to/githubendpoint- Consider creating
src/helpers/webhookSecurity.jsfor reusable validation logic
References
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/index.js and the /github endpoint, then consult the linked GitHub Webhook Security Documentation for the expected X-Hub-Signature-256 format and validation behavior. Add validation using GITHUB_WEBHOOK_SECRET before webhook processing, return HTTP 401 for missing or invalid signatures, and log security events; done means authenticated requests proceed while unauthenticated ones are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, security
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100