The vulnerability exists in the webhook delivery system of Papra. An authenticated user can register a webhook with a URL pointing to an attacker-controlled server. When a webhook event is triggered, Papra's server sends a POST request to this URL. The attacker's server can respond with an HTTP 3xx redirect to an internal IP address. The core of the vulnerability lies in the webhookHttpClient function within packages/webhooks/src/webhooks.services.ts. This function uses the ofetch library to make HTTP requests. By default, ofetch follows redirects. The application's SSRF protection only validates the initial webhook URL, not the URL it is redirected to. This allows an attacker to bypass the SSRF protection and cause the server to make requests to internal resources (e.g., 127.0.0.1, 169.254.169.254).
The patch addresses this by introducing a new, secure HTTP client created by createWebhookHttpClient in apps/papra-server/src/modules/webhooks/webhooks.http-client.ts. This new client explicitly disables redirects by setting redirect: 'manual' in the ofetch.raw() call. The application is then refactored to use this new secure client for all webhook deliveries, effectively mitigating the vulnerability. The vulnerable webhookHttpClient and the triggerWebhook function that uses it are the key functions that would appear in a runtime profile during exploitation. The flawed filterOutSsrfUnsafeWebhooks function, which was supposed to provide protection but failed to do so against this attack vector, was also removed as part of the fix.