Treeherder SQL injection in API 'offset' parameter due to Datasource's LIMIT/OFFSET handling
Originally disclosed on Mozilla
- Fixed in 9 hours
- Paid in 21 days
- Disclosed after 9 hours
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36
Steps to reproduce:
The Treeherder API constructs raw SQL queries for certain endpoints. The data is not properly escaped resulting in SQL injection.
STR:
1. Visit
https://treeherder.mozilla.org/api/project/mozilla-central/bug-job-map/?offset=%27abcd
Actual results:
SQL Error indicating successful injection
{"detail": "(1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''abcd,10' at line 1\")"}
Expected results:
No error
This specific bug exists due to the code not properly casting the GET param to an int. [1] There may be more vulnerable API endpoints which call jobs_execute() in [2]
[1] - https://github.com/mozilla/treeherder/blob/12f80ce4486497e33131faeaae19429f1e00ff4e/treeherder/webapp/api/bug.py#L74
[2] - https://github.com/mozilla/treeherder/blob/12f80ce4486497e33131faeaae19429f1e00ff4e/treeherder/model/derived/jobs.py#L209
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A critical-severity SQL injection bug in Treeherder: API. Mozilla made it public on 13 July 2015.
About SQL injection
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.