Skip to content

Webhook endpoint returns 500 instead of 401 when X-Hub-Signature-256 header is missing #4275

Description

@ChristoRibeiro

Summary

The GitHub webhook endpoint returns HTTP 500 Internal Server Error when the X-Hub-Signature-256 header is missing, instead of the expected HTTP 401 Unauthorized.

Steps to reproduce

Send a POST to your Dokploy webhook endpoint with a well-formed GitHub-like JSON payload but without the X-Hub-Signature-256 header:

curl -sS -X POST "https://<your-dokploy>/api/deploy/github" \
  -H "Content-Type: application/json" \
  -H "X-GitHub-Event: push" \
  -H "X-GitHub-Delivery: test-$(uuidgen)" \
  -d '{"action":"test","installation":{"id":<valid-installation-id>},"repository":{"full_name":"foo/bar"}}'

Expected

HTTP 401 Unauthorized with a structured error body (e.g. {"message":"Missing signature header"}), consistent with the response for an invalid signature.

Actual

HTTP 500 Internal Server Error with body Internal Server Error.

Context

  • Dokploy v0.29.1
  • Consistent behavior: sending a wrong signature header returns 401 correctly — only a missing header crashes into 500.
  • Likely cause: the HMAC comparison path raises when X-Hub-Signature-256 is undefined before the nullity check.

Why it matters

  • Not a security hole (the signature check still prevents unauthorized deploys), but 500 makes monitoring noisy, can pollute error-tracking (Sentry etc.), and implies server-side crash instead of expected auth rejection.
  • Fix should be trivial: normalize missing-header and bad-signature into the same 401 branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions