1
- ### Security Considerations
1
+ # Security Considerations
2
2
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 ` .
5
7
6
8
``` bash
7
9
# Attacker.
@@ -31,8 +33,12 @@ if (!is_website_url($url)) {
31
33
}
32
34
```
33
35
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
36
42
37
43
* Request data prefixed with the @ character may have special interpretation and read from system files.
38
44
@@ -49,6 +55,8 @@ $curl->post('http://www.anotherwebsite.com/', array(
49
55
));
50
56
```
51
57
58
+ ### Unsafe response with redirection enabled
59
+
52
60
* Requests with redirection enabled may return responses from unexpected sources.
53
61
Downloading https://www.example.com/image.png may redirect and download https://www.evil.com/virus.exe
54
62
@@ -58,6 +66,8 @@ $curl->setOpt(CURLOPT_FOLLOWLOCATION, true); // DANGER!
58
66
$curl->download('http://www.example.com/image.png', 'my_image.png');
59
67
```
60
68
69
+ ### Keep SSL protections enabled.
70
+
61
71
* Do not disable SSL protections.
62
72
63
73
``` php
0 commit comments