Exploit the possiblities

CodeIgniter / Kohana PHP Object Injection / Timing Attack

CodeIgniter / Kohana PHP Object Injection / Timing Attack
Posted May 13, 2014
Authored by Scott Arciszewski

CodeIgniter versions 2.1.4 and below and Kohana versions 3.2.3 and below and 3.3.2 and below suffer from PHP object injection, a timing attack, and a remote code execution vulnerability.

tags | advisory, remote, php, code execution
MD5 | 0e2759065ec55f466d26c91ad9a85d27

CodeIgniter / Kohana PHP Object Injection / Timing Attack

Change Mirror Download
Background info and boring history shit:
https://scott.arciszewski.me/research/view/php-framework-timing-attacks-object-injection

Vulnerability:
1. Remote timing attack
2. PHP Object Injection
3. Possibly, as a result of 2, remote code execution

Affects:
- CodeIgniter (<= 2.1.4)
- Kohana (<= 3.2.3, 3.3.2)

Some PHP frameworks (CodeIgniter and Kohana, for sure), give you the option
of storing $_SESSION data in a cookie, then appending a hash of the session
data and an unknown key.

For example:

a:2:{s:1:"a";s:10:"douchelord";s:8:"is_admin";b:0;}5c2d88368e2c154398e77269c3af3edd

Vulnerability 1 - Remote Timing Attack

https://github.com/EllisLab/CodeIgniter/blob/master/system/libraries/Session.php#L159
https://github.com/kohana/core/blob/3.3/master/classes/Kohana/Cookie.php#L74

If you wanted to alter the above serialized blob to read:

a:2:{s:1:"a";s:5:"admin";s:8:"is_admin";b:1;}

... in theory, you would need to either know the encryption key stored in
the framework's configuration. And remotely brute-forcing an md5/sha1 hash
isn't really attractive.

Luckily, the behavior of standard string comparison operators (== and ===)
is to return false as soon as two bytes do not match. Thus we could
discover that...

a:2:{s:1:"a";s:5:"admin";s:8:"is_admin";b:1;}ef000000000000000000000000000000

...takes a little longer than...

a:2:{s:1:"a";s:5:"admin";s:8:"is_admin";b:1;}00000000000000000000000000000000

... and then ...

a:2:{s:1:"a";s:5:"admin";s:8:"is_admin";b:1;}ef870000000000000000000000000000

... will take slightly longer.

Theoretically, if we need 100 samples per possible hexit to guess the
correct value through this strategy, and there are 32 hexits in a hash, at
10 request per second it will take 51200 samples to crack an md5 hash. If
you can guess 50 per second without bringing the target server to its
knees, that's about 18 minutes (worst case) to get the end result:

a:2:{s:1:"a";s:5:"admin";s:8:"is_admin";b:1;}ef87978c40e2c2871ba58ab55b50854e

Vulnerability 2 - PHP Object Injection

If you can convince PHP to pass arbitrary data to unserialize(), which is
the automatic next step when the timing attack succeeds, then you can
inject objects into the code. From what I understand, this can also lead to
remote code execution.

CodeIgniter already patched this in its 3.0/develop branch.
Kohana accepted my pull request for its 3.3/develop branch:
https://github.com/kohana/core/pull/492

Note: Kohana uses SHA1, not MD5, so add another 20% to my estimate.


Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

Want To Donate?


Bitcoin: 18PFeCVLwpmaBuQqd5xAYZ8bZdvbyEWMmU

File Archive:

January 2018

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jan 1st
    2 Files
  • 2
    Jan 2nd
    13 Files
  • 3
    Jan 3rd
    16 Files
  • 4
    Jan 4th
    39 Files
  • 5
    Jan 5th
    26 Files
  • 6
    Jan 6th
    40 Files
  • 7
    Jan 7th
    2 Files
  • 8
    Jan 8th
    16 Files
  • 9
    Jan 9th
    25 Files
  • 10
    Jan 10th
    28 Files
  • 11
    Jan 11th
    44 Files
  • 12
    Jan 12th
    32 Files
  • 13
    Jan 13th
    2 Files
  • 14
    Jan 14th
    4 Files
  • 15
    Jan 15th
    31 Files
  • 16
    Jan 16th
    15 Files
  • 17
    Jan 17th
    16 Files
  • 18
    Jan 18th
    8 Files
  • 19
    Jan 19th
    0 Files
  • 20
    Jan 20th
    0 Files
  • 21
    Jan 21st
    0 Files
  • 22
    Jan 22nd
    0 Files
  • 23
    Jan 23rd
    0 Files
  • 24
    Jan 24th
    0 Files
  • 25
    Jan 25th
    0 Files
  • 26
    Jan 26th
    0 Files
  • 27
    Jan 27th
    0 Files
  • 28
    Jan 28th
    0 Files
  • 29
    Jan 29th
    0 Files
  • 30
    Jan 30th
    0 Files
  • 31
    Jan 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2018 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close