Skip to content

Commit 7ad8b40

Browse files
committed
Updates php/challenge-74.md
Auto commit by GitBook Editor
1 parent ced66ee commit 7ad8b40

File tree

8 files changed

+85
-0
lines changed

8 files changed

+85
-0
lines changed

SUMMARY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
* [Challenge 65](php/challenge-65.md)
7272
* [Challenge 66](php/challenge-66.md)
7373
* [Challenge 67](php/challenge-67.md)
74+
* [Challenge 68](php/challenge-68.md)
75+
* [Challenge 69](php/challenge-69.md)
76+
* [Challenge 70](php/challenge-70.md)
77+
* [Challenge 71](php/challenge-71.md)
78+
* [Challenge 72](php/challenge-72.md)
79+
* [Challenge 73](php/challenge-73.md)
80+
* [Challenge 74](php/challenge-74.md)
7481

7582
## RUBY
7683

php/challenge-68.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Challenge
2+
```
3+
class Login {
4+
public function __construct($user, $pass) {
5+
$this->loginViaXml($user, $pass);
6+
}
7+
8+
public function loginViaXml($user, $pass) {
9+
if (
10+
(!strpos($user, '<') || !strpos($user, '>')) &&
11+
(!strpos($pass, '<') || !strpos($pass, '>'))
12+
) {
13+
$format = '<?xml version="1.0"?>' .
14+
'<user v="%s"/><pass v="%s"/>';
15+
$xml = sprintf($format, $user, $pass);
16+
$xmlElement = new SimpleXMLElement($xml);
17+
// Perform the actual login.
18+
$this->login($xmlElement);
19+
}
20+
}
21+
}
22+
23+
new Login($_POST['username'], $_POST['password']);
24+
```
25+
26+
# Solution
27+
This challenge suffers from an XML injection vulnerability in line 14. An attacker can manipulate the XML structure and hence bypass the authentication. There is an attempt to prevent exploitation in lines 8 and 9 by searching for angle brackets but the check can be bypassed with a specifically crafted payload. The bug in this code is the automatic casting of variables in PHP. The PHP built-in function strpos() returns the numeric position of the looked up character. This can be 0 if the first character is the one searched for. The 0 is then type-casted to a boolean false for the if comparison which renders the overall constraint to true. A possible payload could look like user=<"><injected-tag%20property="&pass=<injected-tag>.
28+
29+
# Refference
30+
+ php-security-calendar-2017

php/challenge-69.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge
2+
```php
3+
```
4+
5+
# Solution
6+
7+
# Refference
8+
+ php-security-calendar-2017

php/challenge-70.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge
2+
```php
3+
```
4+
5+
# Solution
6+
7+
# Refference
8+
+ php-security-calendar-2017

php/challenge-71.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge
2+
```php
3+
```
4+
5+
# Solution
6+
7+
# Refference
8+
+ php-security-calendar-2017

php/challenge-72.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge
2+
```php
3+
```
4+
5+
# Solution
6+
7+
# Refference
8+
+ php-security-calendar-2017

php/challenge-73.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge
2+
```php
3+
```
4+
5+
# Solution
6+
7+
# Refference
8+
+ php-security-calendar-2017

php/challenge-74.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge
2+
```php
3+
```
4+
5+
# Solution
6+
7+
# Refference
8+
+ php-security-calendar-2017

0 commit comments

Comments
 (0)