mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
Use data model for request/session attribute operations
This commit is contained in:
@@ -1,20 +1,40 @@
|
||||
edges
|
||||
| FilePathInjection.java:20:21:20:34 | getPara(...) : String | FilePathInjection.java:25:47:25:59 | finalFilePath |
|
||||
| FilePathInjection.java:40:21:40:34 | getPara(...) : String | FilePathInjection.java:43:25:43:37 | finalFilePath |
|
||||
| FilePathInjection.java:65:29:65:55 | getSessionAttr(...) : String | FilePathInjection.java:71:47:71:59 | finalFilePath |
|
||||
| FilePathInjection.java:111:17:111:44 | getParameter(...) : String | FilePathInjection.java:115:24:115:31 | filePath |
|
||||
| FilePathInjection.java:21:21:21:34 | getPara(...) : String | FilePathInjection.java:26:47:26:59 | finalFilePath |
|
||||
| FilePathInjection.java:41:21:41:34 | getPara(...) : String | FilePathInjection.java:44:25:44:37 | finalFilePath |
|
||||
| FilePathInjection.java:64:21:64:34 | getPara(...) : String | FilePathInjection.java:65:31:65:38 | savePath : String |
|
||||
| FilePathInjection.java:65:3:65:39 | this <.method> [post update] [com.jfinal.core.Controller.session, <map.value>] : String | FilePathInjection.java:66:29:66:55 | this <.method> [com.jfinal.core.Controller.session, <map.value>] : String |
|
||||
| FilePathInjection.java:65:31:65:38 | savePath : String | FilePathInjection.java:65:3:65:39 | this <.method> [post update] [com.jfinal.core.Controller.session, <map.value>] : String |
|
||||
| FilePathInjection.java:66:29:66:55 | getSessionAttr(...) : String | FilePathInjection.java:72:47:72:59 | finalFilePath |
|
||||
| FilePathInjection.java:66:29:66:55 | this <.method> [com.jfinal.core.Controller.session, <map.value>] : String | FilePathInjection.java:66:29:66:55 | getSessionAttr(...) : String |
|
||||
| FilePathInjection.java:87:21:87:34 | getPara(...) : String | FilePathInjection.java:88:24:88:31 | savePath : String |
|
||||
| FilePathInjection.java:88:3:88:32 | this <.method> [post update] [com.jfinal.core.Controller.request, <map.value>] : String | FilePathInjection.java:89:29:89:48 | this <.method> [com.jfinal.core.Controller.request, <map.value>] : String |
|
||||
| FilePathInjection.java:88:24:88:31 | savePath : String | FilePathInjection.java:88:3:88:32 | this <.method> [post update] [com.jfinal.core.Controller.request, <map.value>] : String |
|
||||
| FilePathInjection.java:89:29:89:48 | getAttr(...) : String | FilePathInjection.java:95:47:95:59 | finalFilePath |
|
||||
| FilePathInjection.java:89:29:89:48 | this <.method> [com.jfinal.core.Controller.request, <map.value>] : String | FilePathInjection.java:89:29:89:48 | getAttr(...) : String |
|
||||
| FilePathInjection.java:158:17:158:44 | getParameter(...) : String | FilePathInjection.java:162:24:162:31 | filePath |
|
||||
nodes
|
||||
| FilePathInjection.java:20:21:20:34 | getPara(...) : String | semmle.label | getPara(...) : String |
|
||||
| FilePathInjection.java:25:47:25:59 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:40:21:40:34 | getPara(...) : String | semmle.label | getPara(...) : String |
|
||||
| FilePathInjection.java:43:25:43:37 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:65:29:65:55 | getSessionAttr(...) : String | semmle.label | getSessionAttr(...) : String |
|
||||
| FilePathInjection.java:71:47:71:59 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:111:17:111:44 | getParameter(...) : String | semmle.label | getParameter(...) : String |
|
||||
| FilePathInjection.java:115:24:115:31 | filePath | semmle.label | filePath |
|
||||
| FilePathInjection.java:21:21:21:34 | getPara(...) : String | semmle.label | getPara(...) : String |
|
||||
| FilePathInjection.java:26:47:26:59 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:41:21:41:34 | getPara(...) : String | semmle.label | getPara(...) : String |
|
||||
| FilePathInjection.java:44:25:44:37 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:64:21:64:34 | getPara(...) : String | semmle.label | getPara(...) : String |
|
||||
| FilePathInjection.java:65:3:65:39 | this <.method> [post update] [com.jfinal.core.Controller.session, <map.value>] : String | semmle.label | this <.method> [post update] [com.jfinal.core.Controller.session, <map.value>] : String |
|
||||
| FilePathInjection.java:65:31:65:38 | savePath : String | semmle.label | savePath : String |
|
||||
| FilePathInjection.java:66:29:66:55 | getSessionAttr(...) : String | semmle.label | getSessionAttr(...) : String |
|
||||
| FilePathInjection.java:66:29:66:55 | this <.method> [com.jfinal.core.Controller.session, <map.value>] : String | semmle.label | this <.method> [com.jfinal.core.Controller.session, <map.value>] : String |
|
||||
| FilePathInjection.java:72:47:72:59 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:87:21:87:34 | getPara(...) : String | semmle.label | getPara(...) : String |
|
||||
| FilePathInjection.java:88:3:88:32 | this <.method> [post update] [com.jfinal.core.Controller.request, <map.value>] : String | semmle.label | this <.method> [post update] [com.jfinal.core.Controller.request, <map.value>] : String |
|
||||
| FilePathInjection.java:88:24:88:31 | savePath : String | semmle.label | savePath : String |
|
||||
| FilePathInjection.java:89:29:89:48 | getAttr(...) : String | semmle.label | getAttr(...) : String |
|
||||
| FilePathInjection.java:89:29:89:48 | this <.method> [com.jfinal.core.Controller.request, <map.value>] : String | semmle.label | this <.method> [com.jfinal.core.Controller.request, <map.value>] : String |
|
||||
| FilePathInjection.java:95:47:95:59 | finalFilePath | semmle.label | finalFilePath |
|
||||
| FilePathInjection.java:158:17:158:44 | getParameter(...) : String | semmle.label | getParameter(...) : String |
|
||||
| FilePathInjection.java:162:24:162:31 | filePath | semmle.label | filePath |
|
||||
subpaths
|
||||
#select
|
||||
| FilePathInjection.java:25:47:25:59 | finalFilePath | FilePathInjection.java:20:21:20:34 | getPara(...) : String | FilePathInjection.java:25:47:25:59 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:20:21:20:34 | getPara(...) | user-provided value |
|
||||
| FilePathInjection.java:43:25:43:37 | finalFilePath | FilePathInjection.java:40:21:40:34 | getPara(...) : String | FilePathInjection.java:43:25:43:37 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:40:21:40:34 | getPara(...) | user-provided value |
|
||||
| FilePathInjection.java:71:47:71:59 | finalFilePath | FilePathInjection.java:65:29:65:55 | getSessionAttr(...) : String | FilePathInjection.java:71:47:71:59 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:65:29:65:55 | getSessionAttr(...) | user-provided value |
|
||||
| FilePathInjection.java:115:24:115:31 | filePath | FilePathInjection.java:111:17:111:44 | getParameter(...) : String | FilePathInjection.java:115:24:115:31 | filePath | External control of file name or path due to $@. | FilePathInjection.java:111:17:111:44 | getParameter(...) | user-provided value |
|
||||
| FilePathInjection.java:26:47:26:59 | finalFilePath | FilePathInjection.java:21:21:21:34 | getPara(...) : String | FilePathInjection.java:26:47:26:59 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:21:21:21:34 | getPara(...) | user-provided value |
|
||||
| FilePathInjection.java:44:25:44:37 | finalFilePath | FilePathInjection.java:41:21:41:34 | getPara(...) : String | FilePathInjection.java:44:25:44:37 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:41:21:41:34 | getPara(...) | user-provided value |
|
||||
| FilePathInjection.java:72:47:72:59 | finalFilePath | FilePathInjection.java:64:21:64:34 | getPara(...) : String | FilePathInjection.java:72:47:72:59 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:64:21:64:34 | getPara(...) | user-provided value |
|
||||
| FilePathInjection.java:95:47:95:59 | finalFilePath | FilePathInjection.java:87:21:87:34 | getPara(...) : String | FilePathInjection.java:95:47:95:59 | finalFilePath | External control of file name or path due to $@. | FilePathInjection.java:87:21:87:34 | getPara(...) | user-provided value |
|
||||
| FilePathInjection.java:162:24:162:31 | filePath | FilePathInjection.java:158:17:158:44 | getParameter(...) : String | FilePathInjection.java:162:24:162:31 | filePath | External control of file name or path due to $@. | FilePathInjection.java:158:17:158:44 | getParameter(...) | user-provided value |
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.nio.file.Paths;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.jfinal.core.Controller;
|
||||
|
||||
@@ -58,7 +59,7 @@ public class FilePathInjection extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// BAD: Upload file to user specified path without validation
|
||||
// BAD: Upload file to user specified path without validation through session attribute
|
||||
public void uploadFile3() throws IOException {
|
||||
String savePath = getPara("dir");
|
||||
setSessionAttr("uploadDir", savePath);
|
||||
@@ -81,6 +82,52 @@ public class FilePathInjection extends Controller {
|
||||
fos.close();
|
||||
}
|
||||
|
||||
// BAD: Upload file to user specified path without validation through request attribute
|
||||
public void uploadFile4() throws IOException {
|
||||
String savePath = getPara("dir");
|
||||
setAttr("uploadDir", savePath);
|
||||
String requestUploadDir = getAttr("uploadDir");
|
||||
|
||||
File file = getFile("fileParam").getFile();
|
||||
String finalFilePath = BASE_PATH + requestUploadDir;
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
FileOutputStream fos = new FileOutputStream(finalFilePath);
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
byte[] buf = new byte[1024];
|
||||
i = fis.read(buf);
|
||||
fos.write(buf);
|
||||
} while (i != -1);
|
||||
|
||||
fis.close();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
// BAD: Upload file to user specified path without validation through session object (not detected)
|
||||
public void uploadFile5() throws IOException {
|
||||
String savePath = getPara("dir");
|
||||
getSession().setAttribute("uploadDir", savePath);
|
||||
String sessionUploadDir = getSessionAttr("uploadDir");
|
||||
|
||||
File file = getFile("fileParam").getFile();
|
||||
String finalFilePath = BASE_PATH + sessionUploadDir;
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
FileOutputStream fos = new FileOutputStream(finalFilePath);
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
byte[] buf = new byte[1024];
|
||||
i = fis.read(buf);
|
||||
fos.write(buf);
|
||||
} while (i != -1);
|
||||
|
||||
fis.close();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
private void readFile(HttpServletResponse resp, File file) {
|
||||
OutputStream os = null;
|
||||
FileInputStream fis = null;
|
||||
|
||||
Reference in New Issue
Block a user