개요
소스 점검 이후 발견된 취약점 수정 후 일부를 작성했습니다.
2022년 12월 1일에 작성된 글입니다.
취약점 개선
이미지는 첫 소스 점검 이후 검출된 취약점입니다.
Weak Encryption
"Protect sensitive personal information 'AES'" ", from ...java at line ..."
Protect sensitive personal information ""AES"" ", from ...java at line ... 하드 코딩된 민감 정보(Sensitive personal information)를 수정해야 합니다.
변경 전
Cipher aesCipher = Cipher.getInstance("AES");
변경 후
Cipher aesCipher = Cipher.getInstance(Encryption.AES.getName());
CGI Reflected XSS All Clients
"The application's "Method" embeds untrusted data in the generated output with println ..."
println() 메소드로 데이터를 출력할 경우, 해커가 악의적인 코드를 출력에 삽입할 수 있으므로 제거해야 합니다.
변경 전
System.out.println(url);
변경 후
// System.out.println(url);
Missing HSTS Header
"The web-application does not define an HSTS header, leaving it vulnerable to attack HTTP"
요청을 가로채서 암호화되지 않은 정보를 탈취할 수 있으므로, HSTS Header 설정이 필요합니다.
HSTS(HTTP Strict-Transport-Security)는 웹 사이트가 보안 연결(HTTPS)을 통해서만 액세스할 수 있도록 선언합니다.
예제
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<init-param>
<param-name>hstsMaxAgeSeconds</param-name>
<param-value>31536000</param-value>
</init-param>
<init-param>
<param-name>includeSubDomains</param-name>
<param-value>true</param-value>
</init-param>
</filter>
web.xml
<!-- HSTS Header -->
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>hstsEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>hstsMaxAgeSeconds</param-name>
<param-value>31536000</param-value>
</init-param>
<init-param>
<param-name>hstsIncludeSubDomains</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<!-- The mapping for the HTTP header security Filter -->
<filter-mapping>
<filter-name>httpHeaderSecurity</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
HttpOnlyCookies In Config
"... does not define sensitive application cookies with the "httpOnly" flag, which could allow client-side scripts access to the session cookies."
해커들이 자바스크립트로 쿠키를 가로채는 시도(Cross Site Scripting)를 할 수 없도록 브라우저에서 쿠키 접근 제한이 필요합니다.
web.xml
<!-- HTTP only -->
<session-config>
<session-timeout>10</session-timeout>
<cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
</session-config>