Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 00262ed

Browse files
committed
Resolved security flaw
1 parent 5b51e75 commit 00262ed

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/ktt/lib/httpserver/handler/DirectoryEntry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ public final File getFile(final String path){
157157
return !match.isEmpty() ? files.get(match).getFile() : null;
158158
}else{
159159
if(isWalkthrough){
160-
final File parent = new File(directory.getAbsolutePath() + path).getParentFile(); // todo // ⚠ security flaw: user may have access to folders outside of directory by using ../
160+
final File parent = new File(directory.getAbsolutePath() + path).getParentFile();
161+
if(!parent.getAbsolutePath().startsWith(directory.getAbsolutePath())) return null;
161162
final String name = path.substring(path.lastIndexOf('/'));
162163
final File[] listFiles = parent.listFiles(pathname -> !pathname.isDirectory());
163164

0 commit comments

Comments
 (0)