CVE-2021-21243 (published 2021-01-15T20:15Z)

OneDev is an all-in-one devops platform. In OneDev before version 4.0.3, a Kubernetes REST endpoint exposes two methods that deserialize untrusted data from the request body. These endpoints do not enforce any authentication or authorization checks. This issue may lead to pre-auth RCE. This issue was fixed in 4.0.3 by not using deserialization at KubernetesResource side.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-502
cwe_name: Deserialization of Untrusted Data
description: The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
extended_description: 
            It is often convenient to serialize objects for communication or to save them for later use. However, deserialized data or code can often be modified without using the provided accessor functions if it does not use cryptography to protect itself. Furthermore, any cryptography would still be client-side security -- which is a dangerous security assumption.
            Data that is untrusted can not be trusted to be well-formed.
            When developers place no restrictions on "gadget chains," or series of instances and method invocations that can self-execute during the deserialization process (i.e., before the object is returned to the caller), it is sometimes possible for attackers to leverage them to perform unauthorized actions, like generating a shell.
         
         

Fix information:
repo_url: https://github.com/theonedev/onedev
commit_details: repo_url: https://github.com/theonedev/onedev
author: Robin Shen
author_date: 2020-11-19 12:09:04+08:00
msg: Do not deserialize data from job nodes in Kubernetes resource to avoid
security vulnerability
repository: repo_url: https://github.com/theonedev/onedev
repo_name: theonedev/onedev
description: Git Server with CI/CD, Kanban, and Packages. Seamless integration. Unparalleled experience.
repo_language: Java
owner: theonedev
file_changes: filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -9,7 +9,7 @@
 		<version>1.0.5</version>
 	</parent>
 	<artifactId>server</artifactId>
-	<version>4.0.0</version>
+	<version>4.0.1</version>
 	<packaging>pom</packaging>
 	<build>
 		<finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
@@ -574,7 +574,7 @@
 	</repositories>
 	<properties>
 		<commons.version>1.1.21</commons.version>
-		<k8shelper.version>1.0.20</k8shelper.version>
+		<k8shelper.version>1.0.21</k8shelper.version>
 		<slf4j.version>1.7.5</slf4j.version>
 		<logback.version>1.0.11</logback.version>
 		<antlr.version>4.7.2</antlr.version>

programming_language: HTML
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -7,7 +7,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<build>
 		<plugins>

programming_language: HTML
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<dependencies>
 		<dependency>

programming_language: TypeScript
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<build>
 		<resources>

programming_language: HTML
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.authenticator.ldap.LdapModule</moduleClass>

programming_language: Markdown
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<dependencies>
 		<dependency>

programming_language: SQL
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.buildspec.maven.MavenModule</moduleClass>

programming_language: SQL
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.buildspec.node.NodePluginModule</moduleClass>

programming_language: CoffeeScript
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.docker.DockerModule</moduleClass>

programming_language: Markdown
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.executor.kubernetes.KubernetesModule</moduleClass>

programming_language: CoffeeScript
filename: KubernetesResource.java
change_type: ModificationType.MODIFY
diff: @@ -25,6 +25,7 @@ import javax.ws.rs.core.StreamingOutput;
 
 import org.apache.commons.lang.SerializationUtils;
 
+import com.google.common.base.Splitter;
 import com.google.common.collect.Lists;
 
 import io.onedev.commons.utils.TarUtils;
@@ -73,20 +74,19 @@ public class KubernetesResource {
 	@Consumes(MediaType.APPLICATION_OCTET_STREAM)
 	@Produces(MediaType.APPLICATION_OCTET_STREAM)
     @POST
-    public byte[] allocateJobCaches(byte[] cacheAllocationRequestBytes) {
-		CacheAllocationRequest allocationRequest = (CacheAllocationRequest) SerializationUtils
-				.deserialize(cacheAllocationRequestBytes);
+    public byte[] allocateJobCaches(String cacheAllocationRequestString) {
+		CacheAllocationRequest cacheAllocationRequest = CacheAllocationRequest.fromString(cacheAllocationRequestString);
 		return SerializationUtils.serialize((Serializable) jobManager.allocateJobCaches(
-				getJobToken(), allocationRequest.getCurrentTime(), allocationRequest.getInstances()));
+				getJobToken(), cacheAllocationRequest.getCurrentTime(), cacheAllocationRequest.getInstances()));
     }
 	
 	@Path("/report-job-caches")
 	@Consumes(MediaType.APPLICATION_OCTET_STREAM)
 	@POST
-	public void reportJobCaches(byte[] cacheInstanceBytes) {
-		@SuppressWarnings("unchecked")
-		Collection<CacheInstance> cacheInstances = (Collection<CacheInstance>) SerializationUtils
-				.deserialize(cacheInstanceBytes);
+	public void reportJobCaches(String cacheInstancesString) {
+		Collection<CacheInstance> cacheInstances = new ArrayList<>();
+		for (String field: Splitter.on(';').omitEmptyStrings().split(cacheInstancesString))
+			cacheInstances.add(CacheInstance.fromString(field));
 		jobManager.reportJobCaches(getJobToken(), cacheInstances);
 	}
 	

programming_language: Java
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.report.html.HtmlReportModule</moduleClass>

programming_language: HTML
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<properties>
 		<moduleClass>io.onedev.server.plugin.report.markdown.MarkdownReportModule</moduleClass>

programming_language: Markdown
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server-plugin</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<dependencies>
 		<dependency>

programming_language: SQL
filename: pom.xml
change_type: ModificationType.MODIFY
diff: @@ -7,7 +7,7 @@
 	<parent>
 		<groupId>io.onedev</groupId>
 		<artifactId>server</artifactId>
-		<version>4.0.0</version>
+		<version>4.0.1</version>
 	</parent>
 	<dependencies>
 		<dependency>

programming_language: HTML