what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

PHP 5.4.3 PDO Access Violation

PHP 5.4.3 PDO Access Violation
Posted Jun 12, 2012
Authored by 0x721427D8 | Site beyondsecurity.com

PHP versions 5.4.3 and below have a parsing bug in PDO prepared statements that may lead to an access violation.

tags | advisory, php
SHA-256 | 63b75d37126d6b5d3ffcfea40451283f8d4bb2a0b2906244f247c2d6bc8c62d7

PHP 5.4.3 PDO Access Violation

Change Mirror Download
[php<=5.4.3] Parsing Bug in PHP PDO prepared statements may lead to
access violation

Affected Product:     PHP
Affected Component:   PDO - PHP Data Objects
Affected Versions:    <=5.4.3 (latest version and trunk)
PHP Bug Ref:          #61755
Patch:                bug61755.diff
Discovery Date:       Feb 2012
Advisory Date:        2012-06-10

Description:
------------
Inconsistent parsing of PHP PDO prepared statements. Erroneous design
of parsers
state machine. Under special circumstances parsing of prepared statements does
not stop leading in cycling the whole stack without terminating on \0. This
leads to access violations, accessing of stack data, DoS.

Bug Description:
----------------
There are several design errors in the state-machine responsible for
parsing PHP
PDO based statement objects. These errors are based on the state-machines
inability to consistently check the supplied SQL-Query. Under special
circumstances an attacker is able to force the responsible PDO code to iterate
beyond the termination of the supplied query string resulting in a
buffer out of
bounds access. This access may lead to uncontrollable as well as attacker
controllable behavior and Access Violations caused by the code iterating the
whole stack and trying to access addresses beyond the stack end. In
very unlikely
and constructed environments it may also be possible to force
parameter rebinding
of prepared statements - even though some context specific input
filtering is applied -
by utilizing the stack cycling behavior of the state machine.
This can be accomplished by 1) pushing a manipulated SQL string containing fake
parameter bindings (:named:, ?) onto the stack (e.g. using post variables)
2) manipulating the main SQL query string (see preconditions) to make
the pdo_parser
cycle the stack 3) until it cycles into the fake query previously
pushed to stack where
the magic happens. This forces the state machine into cycling into
random stack data
and then into the previously pushed manipulated SQL string with fake
parameter bindings.
To finalize this attack the manipulated SQL string then terminates the
SQL parsing
resulting in rebinding of prepared parameters. The attacker needs to
know the original
binding names (for named parameters) and the number of bound params
for this attack
to succeed. This scenario is unlikely to occur but as usual in
computer security this may
be used in conjunction with other attacks to multiply the impact.

Preconditions:
--------------
* PDO is used to access the DB
* For remote attacks: User must be able to directly control any part of the
query string prior its preparation (stm->prepare()). We are well aware
that this
is a general coding fault which leads to other security relevant implications
but sadly enough it’s also quite common in many frameworks, projects to use
prepared statements with user controlled data instead of binding them after
preparation.

State-Machine Graph, Test-Scripts, Traces, PoCs are available.

Vendor Response:
----------------
* Patch 2012-04-19 (bug61755.diff) (see php bugref)
Patch available, but still not fixed in 5.4.3 (latest)

Timeline:
---------
* 2012 Feb   - Discovered in 5.3.8, verified for 5.3.0/5.3.10 and 5.4.0
* 2012 March - Responsible Disclosure via SSD/BeyondSecurity
* 2012 April - Patch available 2012-04-19
* 2012 May/June - No trace of bugfix in svn for 5.3/5.4/trunk although
mentioned in bugref #61755
* 2012 June  - No trace of bugfix in svn for 5.3/5.4/trunk, code ...
* 2012 June  - public disclosure

CREDITS:
--------
Discovered by 0x721427D8 via BeyondSecurity - SecuriTeam Secure Disclosure




Refs:
-----
http://php.net/
http://www.php.net/manual/en/intro.pdo.php
http://svn.php.net/viewvc/php/php-src/trunk/ext/pdo/
http://www.securiteam.com/
Login or Register to add favorites

File Archive:

April 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close