Tiny Bunny

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

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

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

[case4]

if (FileUploadCtr.PostedFile.ContentType == "image/jpeg")
{
	if (FileUploadCtr.PostedFile.ContentLength < 102400)
	{
		string fn = Path.GetFileName(FileUploadCtr.FileName);
		FileUploadCtr.SaveAs(Server.MapPath("~/") + fn);
		StatusLabel.Text = "Upload status: File uploaed!";
	}
	else
		StatusLabel.Text = "Upload Status: The File has to be less than 100 kb!";
	}
else
	StatusLabel.Text = "Upload Status: Only JPEG files are accepted!";
취약점 파일 업로드 (File Upload)
양호/취약 양호
사유 화이트리스트 기반 파일 타입 검증과 파일 크기 검증 모두 진행하기 때문

 

[case5]

String id = (String)session.getValue("id");
String bn = request.getParameter("gubun");
String rd = request.getParameter("redirect");
if (id.length() > 0) {
	String sql = "select level from customer where customer_id = ? ";
	conn = db.getConnection();
	pstmt = conn.prepareStatement(sql);
	pstmt.setString(1, id);
	rs = pstmt.executeQuery();
	rs.next();
	if ("0".equals(rs.getString(1)) && "01AD".equals(bn)) {
		response.sendRedirect(rd);
		return;
}
취약점 SQL Injection
양호/취약 양호
사유 PrepareStatement를 사용하며 데이터 바인딩을 통해 동적 쿼리로서 동작되지 않도록 설정하기 때문
취약점 Open Redirect / Reflected XSS
양호/취약 취약
사유 파라미터 redirect에 대한 검증 부재로 악의적인 사이트로의 리다이렉트 또는 Reflected XSS 가능성이 존재

 

[case6]

String gubun = request.getParameter(“gubun”);

…

String sql = “SELECT * FROM board WHERE b_gubun = ‘”+gubun+ “’”;
Connection con = db.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
취약점 SQL Injection
양호/취약 취약
사유 Statement 클래스를 통해 입력 값 gubun을 보호하여 DB 쿼리를 실행하지 않기 때문

 

728x90