NShiftKey-Rule-Guide logo NShiftKey-Rule-Guide

1. Vulnerability Description

Due to the nature of the Server Side Script, the Requester (Client) is unable to verify the source code under normal conditions because it is a browser that checks the results processed by the compiler. However, there may be vulnerabilities where source code is exposed to the outside world for a variety of reasons, and the acquired source code allows attackers to obtain sensitive information such as the path to class files, the path used to upload and download files, and the string of database connections.

The main causes of source code exposure are:

1.1 Server Side Script is Not Parsed

Source Code Exposure Vulnerability 2

1.2. Application Bugs

- 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 Server Side Script is Not Parsed

All Server Side Scripts located within the Web server must be set up to register extensions so that the Web server can parse normally.

(1) IIS

Source Code Exposure Vulnerability 3

(2) Apache

Source Code Exposure Vulnerability 4

4. Example Code

// Password for administrator is ""tiger"" <-- Have to remove
public boolean DBConnect() {
    String url = ""DBServer"";
    String password = ""tiger"";
    Connection = null;
  
    try {
        con = DriverManager.getConnection(url, ""scott"", password);
    } catch {
        ...
    }
}
// Password should be deleted in comment
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;
}