Skip to content

Commit 25ff03d

Browse files
committed
Updates php/challenge-78.md
Auto commit by GitBook Editor
1 parent 1faae5c commit 25ff03d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

php/challenge-78.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ $carrot = new Carrot($_GET);
2626
```
2727

2828
# Solution
29+
This class is vulnerable to directory traversal because of mass assignment. The constructor can be used to set arbitrary class attributes (line 11). By overwriting the attribute $id you gain control over the first parameter of file_put_contents() in line 16. With the help of ../ it is possible to target arbitrary files on the system that are writable, for example it can be used to create a PHP shell in the document root. The values that are send to the class are incremented in line 11 and thus an integer after the operation is done. The incrementation happens after the assignment though, so the class attribute contains the original value of $count.
30+
To avoid this security issue be vary careful when using reflection based on user input to set variables. It is recommended to implement a white-list verfication that contains the names of all variables that can be modified. A real world example of a vulnerability that is caused by mass assignment can be found in our blog.
2931

3032
# Refference
3133
+ php-security-calendar-2017 Day 14 - Snowman

0 commit comments

Comments
 (0)