simpleMDMpy icon indicating copy to clipboard operation
simpleMDMpy copied to clipboard

Lack of data validation

Open disconnect3d opened this issue 4 years ago • 1 comments

The code does not perform any data validation of the arguments passed into given API methods, which may cause different operations to be triggered if the data is controlled by an untrusted party.

As an example, if the app_id passed into the Apps.delete_app method is controlled by an attacker, they can trigger a DELETE http request into any other endpoint as the final url is constructed as: https://github.com/macadmins/simpleMDMpy/blob/5221aa32548e2468ade4b92f700d7ebc9d826699/SimpleMDMpy/Apps.py#L46-L50

This may allow e.g. to trigger a ManagedAppConfigs.delete_config case if the attacker would know both app_id and managed_config_id.

While this case may not be a good attack example, since none of the arguments are validated, this can be true for any other HTTP method and endpoint used. Additionally, the untrusted input can also traverse the paths upper with "../some_other_endpoint/" and most likely to make the MDM backend server to ignore a given path suffix. For example in:

url = self.url + "/" + app_id + "/managed_configs/" + managed_config_id

We can provide app_id = "some_path#" or app_id = "some_path?a=" since the other server most likely doesn't care about additional query params or anchor marker in URLs.

disconnect3d avatar Jul 26 '21 16:07 disconnect3d

I'm not sure I agree that this is the responsibility of SimpleMDMpy, but I am thinking about reworking url construction which would be a place to insert this. Do you have any examples of other libraries that perform validation?

MagerValp avatar Dec 01 '22 08:12 MagerValp