From 3dae12ab9989ac274f681acee0dd3290ce6f63db Mon Sep 17 00:00:00 2001 From: Parth Bhardwaj <196071556+bhardwajparth51@users.noreply.github.com> Date: Thu, 13 Aug 2026 14:10:43 +0530 Subject: [PATCH] fix(webhooks): compute HMAC signature over undecoded raw URL (#13196) --- src/Appwrite/Platform/Workers/Webhooks.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index f8dc2f7917..c9ba36cbb1 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -102,10 +102,10 @@ class Webhooks extends Action return null; } - $url = \rawurldecode($webhook->getAttribute('url')); + $rawUrl = $webhook->getAttribute('url'); if (System::getEnv('_APP_ENV', 'development') === 'production') { - $host = \parse_url($url, PHP_URL_HOST) ?? ''; + $host = \parse_url($rawUrl, PHP_URL_HOST) ?? ''; $hostnameValidator = new PublicHostname(); if (!$hostnameValidator->isValid($host)) { return 'Webhook target ' . $host . ' rejected: ' . $hostnameValidator->getDescription(); @@ -113,10 +113,10 @@ class Webhooks extends Action } $signatureKey = $webhook->getAttribute('signatureKey'); - $signature = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); + $signature = base64_encode(hash_hmac('sha1', $rawUrl . $payload, $signatureKey, true)); $httpUser = $webhook->getAttribute('httpUser'); $httpPass = $webhook->getAttribute('httpPass'); - $ch = \curl_init($webhook->getAttribute('url')); + $ch = \curl_init($rawUrl); \curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); \curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); @@ -167,7 +167,7 @@ class Webhooks extends Action $attempts = $webhook->getAttribute('attempts'); $logs = ''; - $logs .= 'URL: ' . $webhook->getAttribute('url') . "\n"; + $logs .= 'URL: ' . $rawUrl . "\n"; $logs .= 'Method: ' . 'POST' . "\n"; if (!empty($curlError)) {