JAVA-013 / 기초
경로 탐색 (파일 다운로드)
왜 문제가 될까요?
../../etc/passwd 로 임의 파일 읽기.
이렇게 수정하세요
java
Path base = Path.of("/data/files").toRealPath();
Path file = base.resolve(name).toRealPath();
if (!file.startsWith(base) || !Files.isRegularFile(file)) {
throw new SecurityException();
}