The vulnerability (CVE-2024-52588) is a Server-Side Request Forgery (SSRF) in Strapi's webhook functionality. It allowed authenticated users with permissions to manage webhooks to create or update a webhook with a URL pointing to internal network resources (e.g., localhost, 127.0.0.1).
The patch commit 0b1222ea20f2dddd5d4222c5d57cd3a4c1f25be8 addresses this by modifying the webhookValidator located in packages/core/admin/server/src/controllers/webhooks.ts. Specifically, it adds a new test called is-public-url to the url field's validation rules. This test uses the is-localhost-ip library (and punycode for internationalized domain names) to check if the provided URL's hostname resolves to a local IP address. This check is enforced when the NODE_ENV is 'production'.
The vulnerable functions are the controller methods within webhooks.ts that handle the creation and updating of webhooks, as these methods would use the webhookValidator to process the user-supplied url. Typically, these methods are named create and update. Before the patch, these functions would accept and process URLs without the SSRF check, leading to the vulnerability. The new API tests added in tests/api/core/admin/admin-webhooks.test.api.ts confirm that POST requests to /admin/webhooks (for creation) and PUT requests to /admin/webhooks/:id (for updates) are the relevant endpoints, which correspond to these controller actions.