728x90
반응형
HTTP 응답 헤더 인젝션
Noncompliant Code Example
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String value = req.getParameter("value");
resp.addHeader("X-Header", value); // Noncompliant
}
Compliant Solution
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String value = req.getParameter("value");
String whitelist = "safevalue1 safevalue2";
if (!whitelist.contains(value))
throw new IOException();
resp.addHeader("X-Header", value); // Compliant
}
728x90
반응형
'Secure Coding' 카테고리의 다른 글
로깅 인젝션 공격 (0) | 2021.09.17 |
---|---|
서버측 요청 위조 공격 (0) | 2021.09.17 |
OS 명령 삽입 공격 (0) | 2021.09.17 |
XPath 인젝션 공격 (0) | 2021.09.17 |
데이터베이스에 연결 시 암호 보안 (0) | 2021.09.17 |
댓글