facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.18k stars 2.99k forks source link

Async mysql queryf and prepared statements #7412

Closed DemiMarie closed 8 years ago

DemiMarie commented 8 years ago

The async MySQL queryf method needs to use server-side prepared statements, not client-side emulated prepared statements. This is to avoid SQL injection problems related to locales.

fredemmott commented 8 years ago

As connections are re-used and queries are multiplexed, this isn't possible with the current architecture.

If you have found a security issue with queryf()/escapeString(), report it with here with additional details: https://www.facebook.com/whitehat/report/ - do not provide additional details on github

Note that these do use server-side escaping via the connection object.

shtse8 commented 7 years ago

As many libraries are supported prepared statements in connection pool, I believe it is possible. Once a connection is prepared for a query, every binding for that query will use the same connection. Once the prepared connection is busy, try to get a ready connection to prepare again.