{"id":"CVE-2026-58511","aliases":["GHSA-3r5c-2xxx-h872"],"title":"Gitea: Webhook Authorization Header Returned in Plaintext via API","summary":"Gitea: Webhook Authorization Header Returned in Plaintext via API","severity":"low","cvss":2.7,"cwe":["CWE-200"],"vendor":"gitea","product":"code.gitea.io/gitea","ecosystem":"go","affected":["code.gitea.io/gitea < 1.27.0"],"patched":["code.gitea.io/gitea 1.27.0"],"published":"2026-07-21","updated":"2026-07-21","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-3r5c-2xxx-h872","references":[{"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-3r5c-2xxx-h872"},{"url":"https://github.com/go-gitea/gitea/releases/tag/v1.27.0"},{"url":"https://github.com/advisories/GHSA-3r5c-2xxx-h872"}],"tags":["ghsa","go"],"ingestedAt":"2026-07-21T21:54:47.152Z","epss":0.00244,"epssPercentile":0.15876,"slug":"CVE-2026-58511","body":"## Overview\n\n## Summary\n\nThe `ToHook()` function in `services/webhook/general.go` decrypts the webhook's `HeaderAuthorizationEncrypted` field and returns the plaintext authorization header in the API response. Any repository admin can read the full plaintext value of webhook authorization headers (Bearer tokens, Basic auth credentials, API keys) set by other admins.\n\nThe authorization header is stored encrypted in the database using the server's `SecretKey`, but `ToHook()` decrypts it before serializing it into the API response — converting a write-only secret into a readable credential.\n\n## Vulnerable Code\n\n**File:** `services/webhook/general.go:407-420`\n\n```go\nfunc ToHook(repoLink string, w *webhook_model.Webhook) (*api.Hook, error) {\n    // ...\n    authorizationHeader, err := w.HeaderAuthorization()  // DECRYPTS from DB\n    if err != nil {\n        return nil, err\n    }\n    return &api.Hook{\n        // ...\n        AuthorizationHeader: authorizationHeader,  // PLAINTEXT in response\n        // ...\n    }, nil\n}\n```\n\n**Decryption function:** `models/webhook/webhook.go:209-216`\n\n```go\nfunc (w Webhook) HeaderAuthorization() (string, error) {\n    if w.HeaderAuthorizationEncrypted == \"\" {\n        return \"\", nil\n    }\n    return secret.DecryptSecret(setting.SecretKey, w.HeaderAuthorizationEncrypted)\n}\n```\n\n## Affected Endpoints\n\nAll call `ToHook()`:\n- `GET /api/v1/repos/{owner}/{repo}/hooks` (requires repo admin)\n- `GET /api/v1/repos/{owner}/{repo}/hooks/{id}` (requires repo admin)\n- `GET /api/v1/admin/hooks` (requires site admin)\n- `GET /api/v1/orgs/{org}/hooks` (requires org admin)\n- `GET /api/v1/user/hooks` (requires authenticated user)\n\n## Steps to Reproduce\n\n1. Admin A creates a webhook with a sensitive authorization header.\n2. Admin B (different repo admin) lists webhooks via `GET /api/v1/repos/{owner}/{repo}/hooks`.\n3. The API response includes the full plaintext authorization header set by Admin A.\n\n## Impact\n\n- Cross-admin secret exposure on shared repositories\n- Credential harvesting if a repo admin's Gitea token is stolen\n- External service compromise via leaked Bearer tokens and API keys\n- Undermines the intentional encryption-at-rest protection\n\n## Suggested Fix\n\nThe authorization header should be write-only. Return a masked/redacted version or a boolean `has_authorization_header` flag instead.\n\n## References\n\n- Vulnerable function: `services/webhook/general.go:392-425`\n- Decryption function: `models/webhook/webhook.go:209-216`\n- Verified against commit 19f0169\n\n## Affected packages\n\n- `code.gitea.io/gitea < 1.27.0`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `code.gitea.io/gitea 1.27.0`","depth":"sunlit","depthScore":15,"depthScoreParts":{"impact":14.9,"likelihood":0,"exploitation":0,"ransomware":0},"changes":[]}