1、错误堆栈
try {
out = httpResponse.getOutputStream()
} catch (Exception e) {
e.printStackTrace(out);
}
异常堆栈可能含有敏感信息,如密码、文件路径、SQL语句、加密密钥等,不应该直接打印。
2、跨域脚本攻击
Cookie cookie = new Cookie("email",userName);
response.addCookie(cookie);
如上,Cookie未设置HttpOnly,客户端恶意脚本可以窃取cookie中的session信息。应加上
cookie.setHttpOnly(true); //HttpOnly flag
3、Cookie注入
String param1= request.getParameter("key");
Cookie cookie = new Cookie(p1,param1);
param1是不可信参数,需要进行安全校验,比如去掉CRLF等。
4、通过HTTP传送cookie
Cookie cookie = new Cookie("userName",userName);
response.addCookie(cookie);
通过HTTP传送cookie是不安全的,应该加上response.setSecure(true)即通过https传送。
5、HTTP响应拆分攻击
String returnUrl = request.getParameter("ret