Headline
CVE-2023-46736: SSRF via /Attachment/fromImageUrl endpoint
EspoCRM is an Open Source CRM (Customer Relationship Management) software. In affected versions there is Server-Side Request Forgery (SSRF) vulnerability via the upload image from url api. Users who have access to the /Attachment/fromImageUrl
endpoint can specify URL to point to an internal host. Even though there is check for content type, it can be bypassed by redirects in some cases. This SSRF can be leveraged to disclose internal information (in some cases), target internal hosts and bypass firewalls. This vulnerability has been addressed in commit c536cee63
which is included in release version 8.0.5. Users are advised to upgrade. There are no known workarounds for this vulnerability.
Summary
There is SSRF via the upload image from url api.
Details
Users that can use the /Attachment/fromImageUrl can specify URL to point to an internal host. Even though there is check for content type, it can be bypassed by redirects in some cases.
PoC
Login as a user who can access attachments APIs, with credentials, make a post request to /api/v1/Attachment/fromImageUrl
with the following data
{
"url": "http://localhost:8888",
"parentType": "Note",
"field": "attachments"
}
On server side, listen on localhost:8888 and it will receive a request, which normally shouldn’t be accessible from outside.
To bypass content type check, use a redirect, for example, by using https://ssrf.localdomain.pw/img-with-body/301-http-127.0.0.1:8888-.i.jpg as url, which spoofs the content type, and the actual response will be saved as an attachment. Then by using the /api/v1/Attachment/file/id endpoint the response can be retrieved.
Impact
This SSRF can be leveraged to disclose internal information (in some cases), target internal hosts and bypass firewalls.
See here for more information on SSRF and here for fix strategies