크로스사이트 스크립팅 (XSS) | 위험도: 4 (높음) | 통제구분: 5.8.4 서비스 보호
인터넷뱅킹 게시판 시스템
// ❌ 취약한 코드
<%
String name = request.getParameter("name");
String content = request.getParameter("content");
%>
// 입력값을 그대로 출력 (XSS 취약!)
<div>
<h3><%= name %></h3>
<p><%= content %></p>
</div>
게시글이 표시됩니다
// ✅ 안전한 코드 (JSTL 사용)
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
prefix="c" %>
// 1. JSTL <c:out> 자동 이스케이프
<div>
<h3><c:out value="${name}" /></h3>
<p><c:out value="${content}" /></p>
</div>
// 또는 OWASP Encoder 사용
<%@ page import="org.owasp.encoder.Encode" %>
<%
String safeName = Encode.forHtml(name);
String safeContent = Encode.forHtml(content);
%>
<div>
<h3><%= safeName %></h3>
<p><%= safeContent %></p>
</div>