NShiftKey-Rule-Guide logo NShiftKey-Rule-Guide

1. Vulnerability Description

The main causes of source code exposure are:

1.1 If you do not parse a server-side script

Source Code Exposure Vulnerabilities 2

1.2. Bug of Applications

- www.target.com//notice/config.jsp
- www.target.com/notice/config.jsp/
- www.target.com/notice/config.jsp//
- www.target.com/notice/config.jsp%00
- www.target.com/notice/config.jsp%23
- www.target.com/notice/config.jsp%5c
- www.target.com/notice/config.%61%73%70
- www.target.com/notice/config.JSP

2. How to check vulnerability

3. Vulnerability Countermeasure

3.1 If you do not parse the Server Side Script

(1) IIS

Source Code Exposure Vulnerabilities 3

(2) Apache

Source Code Exposure Vulnerabilities 4

4. Example Code

// Password for administrator is ""tiger"" <-- A password is written on the annotation.
public boolean DBConnect() {
    String url = ""DBServer"";
    String password = ""tiger"";
    Connection = null;
  
    try {
        con = DriverManager.getConnection(url, ""scott"", password);
    } catch {
        ...
    }
}
// the password written in the source annotation for debugging must be deleted.
public Connection DBConnect(String id, String password) {
    String url = ""DBConnect"";
    Connection conn = null;
    try {
        String CONNECT_STRING = url + "":"" + id + "":"" + password;
        InitialContext ctx = new InitialContext();
        DataSource datasource = (DataSource) ctx.lookup(CONNECT_STRING);
        conn = datasource.getConnection();
    } catch (SQLException e) {
        ...
    }
    return conn;
}