I am receiving a Trust Boundary Violation from Veracode. My code is
userName= req.getParameter(Constant.USERNAME);
session.setAttribute(Constant.USERNAME, userName); //At this line i am getting Trust Boundry Violation flaw.
How can I validate userName
to avoid a trust boundary violation flaw?
Simply use a regular expression to validate the userName according to the rules your usernames follow:
if(userName.matches("[0-9a-zA-Z_]+")
session.setAttribute(Constant.USERNAME, userName);