Skip to content

The Unified and Autonomous Development Platform

Fix issue #941 - Pre Auth LFI

Robin Shen42920d75a470
diff --git a/server-core/src/main/java/io/onedev/server/web/resource/AttachmentResource.java b/server-core/src/main/java/io/onedev/server/web/resource/AttachmentResource.java
index ff94499ba7..5cfe49995e 100644
--- a/server-core/src/main/java/io/onedev/server/web/resource/AttachmentResource.java
+++ b/server-core/src/main/java/io/onedev/server/web/resource/AttachmentResource.java
@@ -50,6 +50,8 @@ public class AttachmentResource extends AbstractResource {
String group = params.get(PARAM_GROUP).toString();
if (StringUtils.isBlank(group))
throw new IllegalArgumentException("group parameter has to be specified");
+ else if (group.contains(".."))
+ throw new IllegalArgumentException("Invalid group parameter");
String authorization = params.get(PARAM_AUTHORIZATION).toOptionalString();
if (authorization == null
@@ -74,6 +76,8 @@ public class AttachmentResource extends AbstractResource {
String attachment = params.get(PARAM_ATTACHMENT).toString();
if (StringUtils.isBlank(attachment))
throw new IllegalArgumentException("attachment parameter has to be specified");
+ else if (attachment.contains(".."))
+ throw new IllegalArgumentException("Invalid attachment parameter");
File attachmentFile = new File(getGroupDir(project, group), attachment);
if (!attachmentFile.exists())