PHP SSRF

SSRF PHP functions

Some function such as file_get_contents(), fopen(), file(), md5_file() accept URLs as input that they will follow making possible SSRF vulnerabilities if the use can control the data:

file_get_contents("http://127.0.0.1:8081");
fopen("http://127.0.0.1:8081", "r");
file("http://127.0.0.1:8081");
md5_file("http://127.0.0.1:8081");

Wordpress SSRF via DNS Rebinding

As explained in this blog post, even the Wordpress function wp_safe_remote_get is vulnerable to DNS rebinding, making it potentially vulnerable to SSRF attacks. The main validation it calls is wp_http_validate_url, which checks that the protocol is http:// or https:// and that the port is one of 80, 443, and 8080, but it's vulnerable to DNS rebinding.

Other vulnerable functions according to the post are:

  • wp_safe_remote_request()

  • wp_safe_remote_post()

  • wp_safe_remote_head()

  • WP_REST_URL_Details_Controller::get_remote_url()

  • download_url()

  • wp_remote_fopen()

  • WP_oEmbed::discover()

CRLF

Moreover, in some cases it might be even possible to send arbitrary headers via CRLF "vulnerabilities" in the previous functions:

Note that these function might have other methods to set arbitrary headers in requests, like:

Last updated