Tiny Bunny

Rookies/클라우드 기반 취약점 진단 및 대응 실무

[SK shieldus Rookies 19기] 소스코드 진단 03

bento 2024. 5. 17. 21:47
[SK쉴더스 Rookies 19기] 클라우드 기반 스마트 융합보안 과정

[case7]

public static void main(String args[]) throws IOException {
    List<String> allowedCommands = new ArrayList<String>();
	allowedCommands.add("notepad");
	allowedCommands.add("calc");
	String cmd = args[0];
	if (!allowedCommands.contains(cmd)) {
		System.err.println("Error");
		return;
	}
	Process ps = null;
	try {
		ps = Runtime.getRuntime().exec(cmd);
......
취약점Command Injection
양호/취약양호
사유화이트리스트 기반 응용프로그램 종류 필터링을 정의하고 있기 때문

 
[case8]

string file = Request.QueryString["path"];
if (file != null)
{
	if (file.IndexOf('\\') > -1 || file.IndexOf('/') > -1)
	{
		Response.Write("Path Traversal Attack");
	}
	else
	{
		File.Delete(file);
	}
}
취약점경로 순회 공격(Directory Traversal) / 경로 조작 및 자원 삽입
양호/취약양호
사유/와 \\를 검증하고 있기 때문

 
[case9]

<%
String param = request.getParameter(“param”);
If(param != null) {
	param = param.replaceAll(“<script>”,””);
	param = param.replaceAll(“</script>”,””);
}
%>

…

<p> 제목 : <%=param%></p>
취약점XSS, CSRF
양호/취약취약
사유공격을 방어하기 위한 충분한 키워드 필터링이 적용되지 않았기 때문

 
[case10]

<%@taglibprefix=”c”url=”http://java.sun.com/jsp/jstl/core”%>
<%@tagliburi=”http://java.sun.com/jsp/jstl/functions”prefix=”fn”%>

…

<c:out value=”${param.name}” escapeXml=”false”/>
취약점XSS
양호/취약취약
사유escapeXml="false"로 설정하여 특수문자가 이스케이프되지 않고 그대로 출력되기 때문
728x90