조치사항
[패턴문자]
./ ../
.\ ..\
%

- 패턴 문자 필터링
- fckeditor 등 디폴트 디렉토리 및 파일 삭제 또는 유추할 수 없는 이름으로 변경

JSP SQL Injection 시큐어 코딩


page.jsp 파일중에서
String fileName= request.getParameter("filename");
if ( fileName == null || “”.equals(fileName) ) {
}
String filePath = UPLOAD_PATH + fileName;
String decodeFileName = URLDecoder.decode(fileName,Charset.defaultCharset().name());

if ( decodeFileName.equalsIgnoreCase("..") ||
decodeFileName.equalsIgnoreCase("/") ) {
customerror("error");
}

OR
String[] PreventChars = {"./",...} //위 표에 있는 데이터 나열함.

for (int i=0; i< PreventChars.length; i++) {
if(param.indexOf(PreventChars[i]) != -1){
System.out.println("금지된 키워드 사용입니다.");
return false;
}
}

PHP SQL Injection 시큐어 코딩


page.php 파일중에서
$PreventChars = array("'","\""...); //위 표에 있는 데이터 나열함.

foreach($PreventChars as $keyword){
$param = str_replace($keyword,"",$param);
}




ASP.NET (C#) 시큐어 코딩(MSDN 참조)


page.aspx 파일중에서

<%@ Page Language="C#" ValidateRequest="false"%>

<script runat="server">

  void submitBtn_Click(object sender, EventArgs e)
  {
    string[] patterns = {"./"...}; 위 표에 나열된 데이터 나열함
    // Encode the string input
    StringBuilder sb = new StringBuilder(HttpUtility.HtmlEncode(htmlInputTxt.Text));
    for(int i=0; i<patterns.length; i++){
     if(pattens[i].indexOf(sb.ToString()) > 0){
      sb.Replace(pattenrs[i],"");
     }
    }
    Response.Write(sb.ToString());
  }
</script>

<html>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:TextBox ID="htmlInputTxt" Runat="server"
                     TextMode="MultiLine" Width="318px"
                     Height="168px"></asp:TextBox>
        <asp:Button ID="submitBtn" Runat="server"
                     Text="Submit" OnClick="submitBtn_Click" />
      </div>
    </form>
  </body>
</html>