Model::update() is dangerous |
The current Model::update() is very dangerous.
I created a sample vulnerable app. https://github.com/kenjis/ci4-model-update-danger PHP Code: public function update() The above code has vulnerability. Do you know what's wrong?
No valid ID? If empty id update all rows?
There is no vulnerability here.
This is an application design error. All input data must be validated.
haha, I just got this bug a couple of days ago. Gone to fix my model wrappers by checking id
Okay, I wrote another controller. You cannot set $id to null. But it is still vulnerable.
https://github.com/kenjis/ci4-model-upda...#L103-L123 PHP Code: public function postUpdate($id = false)
Your passing the body into the database just using required so it will pass as long as something is in it.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-15-2022, 11:02 PM)InsiteFX Wrote: Your passing the body into the database just using required so it will pass as long as something is in it. Okay, I added max and min length validation rules. https://github.com/kenjis/ci4-model-upda...hp#L16-L19 PHP Code: private array $rules = [ |
Welcome Guest, Not a member yet? Register Sign In |