Translate

레이블이 JSP인 게시물을 표시합니다. 모든 게시물 표시
레이블이 JSP인 게시물을 표시합니다. 모든 게시물 표시

2021년 3월 18일 목요일

[Eclipse, JSTL] 이클립스 정규 표현식을 이용한 Find/Replace로 웹 취약점 XSS 조치 (${} -> c:out 변환)





(\$\{.+?\})

<c:out value='\1'/>

웹 취약점 조치 작업중 단축키 Ctrl+F 로 나오는 Find/Replace에서 ${abc} -> <c:out value='${abc}'/> 로 일괄 변환할 수 있는 정규 표현식이다.

또한 이미 기존 JSTL태그에서 사용된것도 구분없이 변환되므로 위 바꾸기를 한 후에
<c:out value=.<c:out value
이런식으로 중복처리된 데이터를 탐색할 수 있다.

Regular Expression는 반드시 체크해야함

2018년 9월 7일 금요일

[JSP] _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit error 해결법


Laptop
운영체제 Windows 10 Enterprise 64bit
개발프로그램 Eclipse Photon (4.8.0)

말 그대로 서블릿 java 파일이 제한인 65535 bytes (약 64KB)를 초과하여 생기는 현상이다.

해결법은 실행 중인 서버의 web.xml 파일에서

<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>

를 찾아 아래 소스를 추가해준다.

<init-param>
            <param-name>mappedfile</param-name>
            <param-value>false</param-value>
</init-param>

만약  Eclipse + Tomcat 이라면 다음과 같이 바로 찾을 수 있다.


servlet-name값이 default인 것도 있으니 헷갈리지 않게 주의...(그걸로 몇 시간 헤맸다)


원리를 대충 설명하자면 
jsp 내에 html코드가 들어갈 경우 (모든 html인지, jsp와 혼합된 html만인지는 모르겠다)

out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");

이런 식으로  out.write로 변환해 버리는 구조로 되어있는데, 이것을 out.write("\r\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n"); 처럼 한줄로 바꾸는 별거 아닌 설정이다.

덤으로 마찬가지로 용량을 줄이기 위한 다른 설정들은 다음과 같다.

<init-param>
 <param-name>genStringAsCharArray</param-name>
 <param-value>true</param-value>
</init-param>
<init-param>
 <param-name>trimSpaces</param-name>
 <param-value>true</param-value>
</init-param>

하지만 이것들도 String을 char배열로 바꾸거나 공백을 없애는 등 소소한 설정들이고

사실 가장 적절한 해결법은 jsp 소스에서 최대한 참조로 뺄 수 있는 걸 빼는 거지만 규모가 크다면 매우 번거로운 작업이므로...



참고 사이트:
http://s4-ba.hatenablog.jp/entry/2016/06/19/095937 https://docs.oracle.com/cd/E19146-01/821-1489/ggkhi/index.html