fix get_one sqla.ModelView#2788
Conversation
|
The value is passed to SQLAlchemy’s Session.get() using bound parameters, not interpolated SQL, so the security vulnerability is a false positive. |
| if isinstance(self._primary_key, tuple): | ||
| _id = tools.iterdecode(id) | ||
| else: | ||
| _id = (tools.escape(id),) |
There was a problem hiding this comment.
Why tools.escape?
Looks unnecessary to me
There was a problem hiding this comment.
hmmm, what if the actual string-single-PK="1,2", is it possible to navigate /admin/details?id=1,2 without escaping ?
There was a problem hiding this comment.
yes, by passing another time iterdecode. Here you don't need to escape, but to undo the escaping needed to build the url.
There was a problem hiding this comment.
what do you mean by build the url ?
There was a problem hiding this comment.
The url that is linked in a view e.g. the one for editing will be edit/?id=1,2 but 1,2 will be escaped. You can check it by clicking on the pencil icon of a list view
There was a problem hiding this comment.
ok, yes, it will be escaped, but what if the user wrote edit/?id=1,2 manually in the browser ? then 500 will be returned with error.

A run-time error is raised when
get_one()is called inflask_admin.contrib.sqla.view.ModelViewTo replicate the error try to browse this:
/admin/details/?id=1,2Risk:
A security vulnerability is raised by Tnable where it could lead to Blind SQL Inejection which is classified as a High risk vulnerability. This can be exploited in
/editand/detailsA test case is added to make sure that
/admin/details/?id=1,2is working as expected