Mesh deforming when moving bones

I’m having an issue with the mesh deforming in a weird way when I move the bones of the leg. See screenshot attached. Any ideas how this is happening? Also there is a box appearing in object mode and pose mode that I can’t get rid of, it doesn’t appear in edit mode however…

you probably need to give some corrections, select the vertices that mess up, remove from all vertex groups, then assign to the right vertex group

Are the vertices of this box hidden in edit mode, eventually? ALT + h should show them again.