Skip to content
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

[fix] don't allow string values in limits to avoid sql injection #8779

Merged

Conversation

saurabh6790
Copy link
Member

@saurabh6790 saurabh6790 commented May 11, 2017

URL: http://data.erpnext.dev:8000/?cmd=erpnext.templates.pages.product_search.get_product_list&start=1%20PROCEDURE%20ANALYSE(EXTRACTVALUE(2288,CONCAT(0x5c,(BENCHMARK(5000000,MD5(0x4f716f73))))),1)-afDR&search

Before

Traceback (most recent call last):
  File "/Users/saurabh/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/Users/saurabh/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/Users/saurabh/frappe-bench/apps/frappe/frappe/handler.py", line 52, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/Users/saurabh/frappe-bench/apps/frappe/frappe/__init__.py", line 907, in call
    return fn(*args, **newargs)
  File "/Users/saurabh/frappe-bench/apps/erpnext/erpnext/templates/pages/product_search.py", line 50, in get_product_list
    }, as_dict=1)
  File "/Users/saurabh/frappe-bench/apps/frappe/frappe/database.py", line 138, in sql
    self._cursor.execute(query, values)
  File "/Users/saurabh/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/Users/saurabh/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-afDR, 12' at line 6")

after

screen shot 2017-05-11 at 4 59 29 pm

@saurabh6790 saurabh6790 force-pushed the sql_injection_fix_for_product_search branch from 453abff to 424b2fd Compare May 11, 2017 12:29
@saurabh6790 saurabh6790 force-pushed the sql_injection_fix_for_product_search branch from 424b2fd to 4b41325 Compare May 11, 2017 12:30
@rmehta rmehta merged commit 62c7dee into frappe:develop May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants