-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ORM - Using limit with a negative number throws a MYSQL error #12419
Comments
Thank for reporting. I'll fix it asap |
NP, and thanks for the quick reply! |
php 7 0 13 maybe we can tune a little bit here https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model/criteria.zep#L512 to change var to int and offset only if limit is present stuff like that what do you think @sergeyklay |
3 tasks
Fixed in the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected
Calling ->limit($value) on a Query should parse all input to be a non negative number.
Actual Behavior
A user attempted a MYSQL injection where a limit value was passed to the API, the value passed was
Encoded:
limit=%3CMETA%20HTTP-EQUIV%3D%22refresh%22%20CONT ENT%3D
%220%3Burl%3Djavascript%3Aqss%3D7%22%3E
Decoded:
and the ORM treated LIMIT input as an intval so it stripped all characters except numbers and negatives which then returned "-07"
MYSQL limit does not accept negative numbers, so throws and error, and Phalcon outputs the full query to the user which then exposes more details to the user attempting to sql inject.
Response:
Syntax error, unexpected token -, near to '07', when parsing: SELECT .....
Details
Phalcon version:
Version => 3.0.1
Build Date => Aug 24 2016 11:18:13
PHP Version: (
php -v
)PHP 5.6.15
Operating System:
Windows, Ubuntu, Centos
Installation type:
DLL in windows, apt-get in Ubuntu etc..
Zephir version (if any):
Version 0.9.4a-dev-7e304ba18c
Server:
Nginx and Apache
The text was updated successfully, but these errors were encountered: