mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-16 14:50:15 +08:00
dbeaver/pro#9599 fix allows unauthorized server file stream (#4411)
Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
co-authored by
Daria Marutkina
parent
12030822ea
commit
caef729a8d
+15
-2
@@ -1268,10 +1268,23 @@ public class WebSQLProcessor implements WebSessionProvider {
|
||||
throws DBException {
|
||||
if (cellRow instanceof Map<?, ?> variables) {
|
||||
if (variables.get(FILE_ID) != null) {
|
||||
Path path = WebAppUtils.getWebPlatform()
|
||||
String fileId = variables.get(FILE_ID).toString();
|
||||
try {
|
||||
// file id must be UUID
|
||||
UUID.fromString(fileId);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new DBException("File ID is invalid");
|
||||
}
|
||||
|
||||
Path uploadFolder = WebAppUtils.getWebPlatform()
|
||||
.getTempFolder(webSession.getProgressMonitor(), TEMP_FILE_FOLDER)
|
||||
.resolve(webSession.getSessionId())
|
||||
.resolve(variables.get(FILE_ID).toString());
|
||||
.normalize();
|
||||
Path path = uploadFolder.resolve(fileId).normalize();
|
||||
// ensure the resolved path stays within the session upload directory
|
||||
if (!path.startsWith(uploadFolder)) {
|
||||
throw new DBException("File ID is invalid");
|
||||
}
|
||||
|
||||
try {
|
||||
var file = Files.newInputStream(path);
|
||||
|
||||
Reference in New Issue
Block a user