add a trailing slash to the folder check in the QHelp for java/path-injection

This commit is contained in:
erik-krogh
2024-01-23 14:46:02 +01:00
parent 00dadeb3bf
commit 158ff0da0a

View File

@@ -7,7 +7,7 @@ public void sendUserFileGood(Socket sock, String user) {
Path filePath = publicFolder.resolve(filename).normalize().toAbsolutePath();
// GOOD: ensure that the path stays within the public folder
if (!filePath.startsWith(publicFolder)) {
if (!filePath.startsWith(publicFolder + File.separator)) {
throw new IllegalArgumentException("Invalid filename");
}
BufferedReader fileReader = new BufferedReader(new FileReader(filePath.toString()));