java - Vulnerabilities using model beans in view JSP -
i saw hundreds of examples in spring , struts model beans used in view , know if vulnerability , best approach solve it.
a dumb example. have model bean:
public class user { private string name; private string pass; //getters , setters }
and have views (jsp)
- adminview: view allowed admin have form 2 fields (name , password).
- userview: view common users have form 1 field (name)
in service layer (which should abstract view) have method:
if(pass.isempty) createnormaluser(); else createadminuser();
in userview intruder use both fields (modifying data in browser example) due opened in both views (userview , adminview) because same bean (user).
ok dumb example in complex webapp priori can not guarantee behavior model beans avoid because can have complex business logic , hundred of cases modify bean produce unwanted behavior. more, having in mind service layer should independent view layer.
so necessary control in controllers layer (controllers in spring or actions in struts).
what best approach solve it?
- using form beans contains object of type our bean model getters , setters fields used in form.
- validate in each controller fields in form allowed come data
- other?
Comments
Post a Comment