1- ### Security Considerations
1+ # Security Considerations
22
3- * Url may point to system files. Don't blindly accept arbitrary urls from users. Curl supports many protocols including
4- ` FILE ` . The following would show the contents of ` file:///etc/passwd ` .
3+ ### Url may point to system files
4+
5+ * Don't blindly accept urls from users as they may point to system files. Curl supports many protocols including ` FILE ` .
6+ The following would show the contents of ` file:///etc/passwd ` .
57
68``` bash
79# Attacker.
@@ -31,8 +33,12 @@ if (!is_website_url(http://github.com/$url)) {
3133}
3234```
3335
34- * Url may point to internal urls behind firewall (e.g. http://192.168.0.1/ or ftp://192.168.0.1/). Use a whitelist to
35- allow certain urls. Definitely don't use a blacklist.
36+ ### Url may point to internal urls
37+
38+ * Url may point to internal urls including those behind a firewall (e.g. http://192.168.0.1/ or ftp://192.168.0.1/). Use
39+ a whitelist to allow certain urls rather than a blacklist.
40+
41+ ### Request data may refer to system files
3642
3743* Request data prefixed with the @ character may have special interpretation and read from system files.
3844
@@ -49,6 +55,8 @@ $curl->post('http://www.anotherwebsite.com/', array(
4955));
5056```
5157
58+ ### Unsafe response with redirection enabled
59+
5260* Requests with redirection enabled may return responses from unexpected sources.
5361 Downloading https://www.example.com/image.png may redirect and download https://www.evil.com/virus.exe
5462
@@ -58,6 +66,8 @@ $curl->setOpt(CURLOPT_FOLLOWLOCATION, true); // DANGER!
5866$curl->download('http://www.example.com/image.png', 'my_image.png');
5967```
6068
69+ ### Keep SSL protections enabled.
70+
6171* Do not disable SSL protections.
6272
6373``` php
0 commit comments