--- title: "ADR 0042: Gitea deliveries can carry GitHub webhook headers" --- * Status: accepted * Code: [`pkg/provider/github/detect.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/github/detect.go), [`pkg/provider/github/repository.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/github/repository.go) ## Context Gitea and Forgejo borrowed GitHub's webhook payload shape and some of its headers, so a Gitea delivery can arrive with `X-Github-Event` set. Every provider's `Detect` and the automatic repository configuration run against the same request; the order they are tried in is not authoritative, and a header being present is not proof of origin. If GitHub's detection accepted such a delivery, a Gitea installation would be handled by the GitHub provider: wrong clone URL, wrong token, wrong API host. ## Decision * GitHub `Detect` returns "not mine" immediately when `X-Gitea-Event-Type` is present, before it looks at `X-Github-Event`. * `ConfigureRepository` makes the same check first, so automatic repository creation does not fire for Gitea deliveries either. * `X-Github-Event` is still the positive signal for GitHub when the Gitea header is absent. ## Consequences * The exclusion is a header check, not authentication. A Gitea delivery with `X-Gitea-Event-Type` stripped looks like GitHub, and a GitHub delivery that carries a forged Gitea header is routed away from GitHub. The allowlist and the signature check ([ADR 0011]({{< relref "0011-github-credentials-and-endpoints.md" >}})) are what protect the credential; this check only routes. * Both functions must keep the check, in that order. Adding a GitHub header test before it, or a new entry point that reads `X-Github-Event` directly, reintroduces the cross-provider confusion. * Any future provider that mimics GitHub's headers needs the same guard in both places.