Server Side Request Forgery in macro creation
The macro creation page fetched user-supplied URLs from the server without restrictions, allowing an attacker to make requests to internal addresses and localhost. This could reveal open ports and internal HTTP services, and potentially trigger state-changing GET requests on internal applications.
- Disclosed after 44 hours
mongoose (just getting it out of the way ;))
Hi,
I would like to report a Server Side Request Forgery (SSRF [1]) in the meme creation section of the phabricator software [2].
SSRF is a vulnerability allowing requests to be made from the context of the server. This could allow an attacker to gain access to previously unknown data, and potentially also cause malicious access on services previously inaccessible.
The vulnerability makes use of the URL field on the macro creation page at [2]. Entering in different styles of URL can lead to CURL errors returning data that provides information to the attacker with suitable knowledge. These URLs are connected to from the context of the server machine, allowing the attacker to access internal addresses, as well as "localhost" (being the server machine itself). These systems may be behind a firewall or in a demilitarized zone (DMZ), allowing the attacker to bypass those protections. The most simple attack is making use of a port scan attack, but further attacks could be possible to applications that allow GET requests to modify data and don't have CSRF protection. This could also allow the attacker to send a GET request to an application that has host based access protection (ie, only localhost).
Some example URL's and their responses and the meaning of the responses:
- http://localhost:22/
Could not fetch URL: [cURL/56] (http://localhost:22/) <CURLE_RECV_ERROR> The cURL library raised an error while making a request. You may be able to find more information about this error (error code: 56) on the cURL site: http://curl.haxx.se/libcurl/c/libcurl-errors.html#CURLERECVERRORThis error suggests that there is a port open on port 22 on the server machine (ie, ssh server running) - http://localhost:21/
Could not fetch URL: [cURL/7] (http://localhost:21/) <CURLE_COULDNT_CONNECT> The cURL library raised an error while making a request. You may be able to find more information about this error (error code: 7) on the cURL site: http://curl.haxx.se/libcurl/c/libcurl-errors.html#CURLECOULDNTCONNECTThis error suggests that ther is NOT a port open on port 21 on the server machine (ie, no ftp server) - http://google.com:22/
Could not fetch URL: [cURL/28] (http://google.com:22/) <CURLE_OPERATION_TIMEDOUT> The request took too long to complete.This error also suggests a closed port - http://localhost/
Could not fetch URL: [HTTP/500] Internal Server Error <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Unhandled Exception</title> <style type="text/css">/** * @provides phabricator-fatal-config-template-css */ body { overflow-y: scroll; background: #f9f9f9; margin: 0; padding: 0; font: 13px/1.231 'Helvetica Neue', Arial, sans-serif; text-align: left; -webkit-text-size-adjust: none; } </style> <style type="text/css">/** * @provides unhandled-exception-css */ .unhandled-exception-detail { max-width: 760px; margi...This shows an open port, serving up HTTP responses, in this case, a 500 error (accessing phabricator by a different domain name) - http://google.com/
No curl error, but
You must upload an image.Suggests open port serving HTTP responses, 200 most likely - http://davenport.net.nz/test.php This HTTP 302 redirect to http://localhost/, and gives the same result
- http://testing.allthethings.co.nz/ Same, but via DNS
- http://testing6.allthethings.co.nz/ Same, but via DNS (and IPv6 localhost)
- http://127.0.0.1 Same, direct IP
These messages can give an attacker information about open/closed ports, and in case of HTTP errors, can disclose information to the attacker. If there are applications that allow certain GET requests to change state in favour of the attacker, these can also be used.
I found that non HTML files returned would be saved, and perhaps viewed, HTML just said you must upload an image, but getting css/js worked fine.
Note that you can also get internal addresses, either via HTTP redirect, DNS entry, or direct IP.
My recommendations would be: - Disallow localhost, and any RFC1914 ip's (private LAN) - Disallow unusual ports - Rate limit requests
- Don't follow redirects to localhost and/or local LAN IP's, either via HTTP redirects, or DNS records.
I hope this report helps, let me know if you require any more information.
Cheers,
Hugh
[1] http://www.acunetix.com/blog/articles/server-side-request-forgery-vulnerability/ [2] http://phabricator.example.com/macro/create/
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application passed user-controlled URLs directly to a server-side HTTP client without validating the destination host or port.
Impact
An attacker could map open ports and reach internal HTTP services, and could send GET requests to applications that allow state changes without CSRF protection; non-HTML files returned were saved and possibly viewable.
What the attacker needed
Access to the macro creation page
The fix
The application should block localhost and private IP ranges, disallow unusual ports, rate-limit requests, and avoid following redirects or DNS resolutions to local addresses.
How it was found
- Go to the macro creation page.
- Enter a URL pointing to localhost or an internal address in the URL field.
- Submit the form and observe the cURL error or response returned by the server.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The website had a feature where you give it a link to an image, and the server downloads that image. The problem is the server would download any link, even ones pointing to itself or to internal machines that outsiders cannot reach. An attacker could use error messages to learn which internal services are running.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.