Skip to content

fix: require GitHub webhook secret like other VCS providers - #13999

Merged
eldadfux merged 4 commits into
mainfrom
fix-github-webhook-empty-secret
Sep 29, 2026
Merged

eldadfux merged 4 commits into
mainfrom
fix-github-webhook-empty-secret

Conversation

@eldadfux

@eldadfux eldadfux commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

POST /v1/vcs/github/events skipped signature validation when _APP_VCS_GITHUB_WEBHOOK_SECRET was empty, which is the default. Any unsigned payload was accepted and processed as a genuine GitHub event.

GitHub was the only VCS provider with an optional webhook secret. This PR makes it behave exactly like Gitea, GitLab and Bitbucket:

  • app/config/vcs.php: webhookSecret is now required: true for GitHub. Without it, Factory::isConfigured('github') returns false, so GitHub is disabled the same way the other providers are.
  • The events endpoint uses the same check as the other providers ($valid = !empty($secretKey) && validateWebhookEvent(...)), so a missing secret is rejected with the same 403 general_access_forbidden as a bad signature.
  • The now-outdated "GitHub's legacy optional secret" comment is removed from the Gitea entry.
  • .env sets a test value for _APP_VCS_GITHUB_WEBHOOK_SECRET, like Gitea's. The e2e push helper always signs its payload. The Factory unit tests use a test-only env var so they no longer depend on the container's environment.

Upgrade note (breaking for some self-hosted setups): instances that use GitHub without a webhook secret will see the GitHub integration disabled after upgrading. To restore it, set a webhook secret in the GitHub App settings and the same value in _APP_VCS_GITHUB_WEBHOOK_SECRET. This needs to go in the release notes.

Test Plan

  • New e2e test testCreateEventWithInvalidSignature checks that unsigned events and events signed with the wrong secret both get a 403.
  • The existing push-deployment e2e test now sends a signed payload and should still create a deployment.
  • composer lint passes on the changed files.

Related PRs and Issues

  • Security report (Help Scout 1468250 and duplicates)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? (No API metadata changed.)

@ghost

ghost commented Sep 29, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new commits only simplify the handler condition and rename a test; behavior still matches the PR intent.

GitHub webhook events at POST /v1/vcs/github/events now always validate the signature, and requests are rejected with 403 general_access_forbidden when _APP_VCS_GITHUB_WEBHOOK_SECRET is empty. The GitHub webhookSecret is required: true in the VCS config, so GitHub counts as unconfigured without it, like Gitea, GitLab and Bitbucket. .env, the e2e push helper, a new invalid-signature e2e test and the unit test fixture are updated to match.

Latest changes: The handler now folds the empty-secret check into the signature check (!empty($secretKey) && validateWebhookEvent(...)), so both cases return the single "Invalid webhook payload signature" 403. The separate "secret is not configured" message is gone. The e2e test was renamed to testCreateEventWithInvalidSignature.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php Rejects with 403 when the webhook secret is empty or the signature is invalid, using one combined check.
app/config/vcs.php GitHub webhookSecret is now required. Removed the stale Gitea comment.
app/config/variables.php Description says GitHub is disabled and events are rejected while the secret is empty.
.env Adds a test value for _APP_VCS_GITHUB_WEBHOOK_SECRET.
tests/e2e/Services/VCSGitHub/VCSGitHubConsoleClientTest.php The push helper always signs its payload. New testCreateEventWithInvalidSignature checks that unsigned and wrongly signed events get a 403.
tests/unit/Vcs/FactoryTest.php Fixture marks the GitHub webhook secret as required. testGetWebhookSecret uses its own entry and env var.

Reviewed the commits since 0733c56 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 2/5

[Critical risk] Enforces GitHub webhook signature validation.

The PR does not appear safe to merge while the checked-in webhook secret and the outstanding provider-availability finding remain unresolved.

Fix All in Claude CodeFindings

  1. P1 Security Public webhook secret ▶
  2. P1 GitHub disappears from Console ▶
  3. P2 Missing secret looks like invalid signature ▶
  4. P2 Missing-secret rejection remains untested ▶
  5. P2 Test mirrors configuration ▶
Fix with agent prompt
### Issue 1
.env:undefined-186
If a repository-based Compose deployment does not override this value, it forwards a publicly known secret to the public GitHub webhook endpoint. Anyone who knows the value can produce a valid signature and send forged installation, push, or pull-request events for processing. The repository guide also requires credentials not to be hardcoded. **How this was verified:** The Compose configuration forwards the checked-in secret, and the public endpoint accepts events after comparing their signature against an HMAC keyed by that secret.

### Issue 2
app/config/vcs.php:undefined-31
When the GitHub webhook secret is empty, this required flag makes the factory exclude GitHub from the provider list returned to the Console. GitHub authorization and repository listing can still work, but the Console no longer shows GitHub as an available provider. The intended change is to reject webhook deliveries, not to hide the provider.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 3
src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php:78-82
When `_APP_VCS_GITHUB_WEBHOOK_SECRET` is empty, the endpoint now reports an invalid signature instead of saying the server secret is not configured. An operator troubleshooting a failed webhook cannot tell from this error whether the secret is missing or differs from the one in the GitHub App.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 4
tests/e2e/Services/VCSGitHub/VCSGitHubConsoleClientTest.php:undefined-683
This test runs with a configured webhook secret, so both requests exercise invalid-signature rejection rather than the new missing-secret guard. The test would still pass if the endpoint again accepted unsigned events when no secret is set, leaving the main security regression undetected. Add an endpoint-level check with the server secret unset.

### Issue 5
tests/unit/Vcs/FactoryTest.php:undefined-228
This changes the hand-written test fixture to copy the production `required` flag, but none of the tests using this fixture checks whether GitHub is considered configured. The repository requires tests to check observable behavior rather than mirror configuration. That requirement must be satisfied before merging; this change adds no coverage of the behavior affected by the flag.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR requires a configured secret for GitHub webhooks, validates signed deliveries, and updates the supporting tests. Since the previous review, it has consolidated the missing-secret rejection into the invalid-signature path, shortened the secret’s configuration description, and revised test fixtures.

Reviews (4) · Last reviewed commit: "refactor: align GitHub webhook secret ch..."

Comment thread .env
_APP_VCS_GITHUB_CLIENT_SECRET=
_APP_VCS_GITHUB_PRIVATE_KEY=disabled
_APP_VCS_GITHUB_WEBHOOK_SECRET=
_APP_VCS_GITHUB_WEBHOOK_SECRET=github-webhook-secret

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 security Public webhook secret
If a repository-based Compose deployment does not override this value, it forwards a publicly known secret to the public GitHub webhook endpoint. Anyone who knows the value can produce a valid signature and send forged installation, push, or pull-request events for processing. The repository guide also requires credentials not to be hardcoded. How this was verified: The Compose configuration forwards the checked-in secret, and the public endpoint accepts events after comparing their signature against an HMAC keyed by that secret.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: .env
Line: 186

Comment:
**Public webhook secret**
If a repository-based Compose deployment does not override this value, it forwards a publicly known secret to the public GitHub webhook endpoint. Anyone who knows the value can produce a valid signature and send forged installation, push, or pull-request events for processing. The repository guide also requires credentials not to be hardcoded. **How this was verified:** The Compose configuration forwards the checked-in secret, and the public endpoint accepts events after comparing their signature against an HMAC keyed by that secret.

**Context Used:** AGENTS.md ([source](https://github.com/appwrite/appwrite/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

return ['event' => $event, 'commit' => $commit];
}

public function testGitHubEventWithInvalidSignature(): void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Missing-secret rejection remains untested
This test runs with a configured webhook secret, so both requests exercise invalid-signature rejection rather than the new missing-secret guard. The test would still pass if the endpoint again accepted unsigned events when no secret is set, leaving the main security regression undetected. Add an endpoint-level check with the server secret unset.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/VCSGitHub/VCSGitHubConsoleClientTest.php
Line: 683

Comment:
**Missing-secret rejection remains untested**
This test runs with a configured webhook secret, so both requests exercise invalid-signature rejection rather than the new missing-secret guard. The test would still pass if the endpoint again accepted unsigned events when no secret is set, leaving the main security regression undetected. Add an endpoint-level check with the server secret unset.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

@eldadfux eldadfux changed the title fix: reject GitHub webhook events when no webhook secret is configured fix: require GitHub webhook secret like other VCS providers Sep 29, 2026
Comment thread app/config/vcs.php
'clientId' => ['required' => true, 'envVariable' => '_APP_VCS_GITHUB_CLIENT_ID'],
'clientSecret' => ['required' => true, 'envVariable' => '_APP_VCS_GITHUB_CLIENT_SECRET'],
'webhookSecret' => ['required' => false, 'envVariable' => '_APP_VCS_GITHUB_WEBHOOK_SECRET'],
'webhookSecret' => ['required' => true, 'envVariable' => '_APP_VCS_GITHUB_WEBHOOK_SECRET'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 GitHub disappears from Console
When the GitHub webhook secret is empty, this required flag makes the factory exclude GitHub from the provider list returned to the Console. GitHub authorization and repository listing can still work, but the Console no longer shows GitHub as an available provider. The intended change is to reject webhook deliveries, not to hide the provider.

Prompt To Fix With AI
This is a comment left during a code review.
Path: app/config/vcs.php
Line: 31

Comment:
**GitHub disappears from Console**
When the GitHub webhook secret is empty, this required flag makes the factory exclude GitHub from the provider list returned to the Console. GitHub authorization and repository listing can still work, but the Console no longer shows GitHub as an available provider. The intended change is to reject webhook deliveries, not to hide the provider.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

'clientId' => ['required' => true, 'envVariable' => '_APP_VCS_GITHUB_CLIENT_ID'],
'clientSecret' => ['required' => true, 'envVariable' => '_APP_VCS_GITHUB_CLIENT_SECRET'],
'webhookSecret' => ['required' => false, 'envVariable' => '_APP_VCS_GITHUB_WEBHOOK_SECRET'],
'webhookSecret' => ['required' => true, 'envVariable' => '_APP_VCS_GITHUB_WEBHOOK_SECRET'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Test mirrors configuration
This changes the hand-written test fixture to copy the production required flag, but none of the tests using this fixture checks whether GitHub is considered configured. The repository requires tests to check observable behavior rather than mirror configuration. That requirement must be satisfied before merging; this change adds no coverage of the behavior affected by the flag.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/unit/Vcs/FactoryTest.php
Line: 223

Comment:
**Test mirrors configuration**
This changes the hand-written test fixture to copy the production `required` flag, but none of the tests using this fixture checks whether GitHub is considered configured. The repository requires tests to check observable behavior rather than mirror configuration. That requirement must be satisfied before merging; this change adds no coverage of the behavior affected by the flag.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-github-webhook-empty-secret (after).

Metric Before After Change
🚀 Requests/sec 201.49 208.47 ⚪ +3.5%
⏱️ Latency P50 85.25 ms 82.55 ms ⚪ -3.2%
⏱️ Latency P95 203.84 ms 199.09 ms ⚪ -2.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 82.55 199.09 13,053 208.47 -4.74
Account 161.86 311.21 687 11.4 +22.9
TablesDB 78.1 148 7,099 115.94 -9.42
Storage 78.76 166.2 3,435 57.56 -12.36
Functions 121.74 235.98 1,832 31.43 -5.27

Top API waits (after)

API request Max wait (ms)
account.name.update 542.25
account.prefs.update 455.49
storage.buckets.create 418
functions.create 371.8
functions.variables.update 370.23

Comment on lines +78 to +82
$valid = !empty($secretKey) && $vcs->validateWebhookEvent($payload, $signature, $secretKey);
Span::add('vcs.github.event.signature.valid', $valid);

if (!$valid) {
throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, "Invalid webhook payload signature. Please make sure the webhook secret has same value in your GitHub app and in the _APP_VCS_GITHUB_WEBHOOK_SECRET environment variable");
throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Invalid webhook payload signature. Please make sure the webhook secret has same value in your GitHub app and in the _APP_VCS_GITHUB_WEBHOOK_SECRET environment variable');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Missing secret looks like invalid signature
When _APP_VCS_GITHUB_WEBHOOK_SECRET is empty, the endpoint now reports an invalid signature instead of saying the server secret is not configured. An operator troubleshooting a failed webhook cannot tell from this error whether the secret is missing or differs from the one in the GitHub App.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php
Line: 78-82

Comment:
**Missing secret looks like invalid signature**
When `_APP_VCS_GITHUB_WEBHOOK_SECRET` is empty, the endpoint now reports an invalid signature instead of saying the server secret is not configured. An operator troubleshooting a failed webhook cannot tell from this error whether the secret is missing or differs from the one in the GitHub App.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@eldadfux
eldadfux merged commit e9949c0 into main Sep 29, 2026
52 checks passed
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.

1 participant