CVE-2020-26230: Exposure of Sensitive Information to an Unauthorized Actor (CWE-200)
value: Radar COVID is the official COVID-19 exposure notification app for Spain. In affected versions of Radar COVID, identification and de-anonymization of COVID-19 positive users that upload Radar COVID TEKs to the Radar COVID server is possible. This vulnerability enables the identification and de-anonymization of COVID-19 positive users when using Radar COVID. The vulnerability is caused by the fact that Radar COVID connections to the server (uploading of TEKs to the backend) are only made by COVID-19 positives. Therefore, any on-path observer with the ability to monitor traffic between the app and the server can identify which users had a positive test. Such an adversary can be the mobile network operator (MNO) if the connection is done through a mobile network, the Internet Service Provider (ISP) if the connection is done through the Internet (e.g., a home network), a VPN provider used by the user, the local network operator in the case of enterprise networks, or any eavesdropper with access to the same network (WiFi or Ethernet) as the user as could be the case of public WiFi hotspots deployed at shopping centers, airports, hotels, and coffee shops. The attacker may also de-anonymize the user. For this additional stage to succeed, the adversary needs to correlate Radar COVID traffic to other identifiable information from the victim. This could be achieved by associating the connection to a contract with the name of the victim or by associating Radar COVID traffic to other user-generated flows containing identifiers in the clear (e.g., HTTP cookies or other mobile flows sending unique identifiers like the IMEI or the AAID without encryption). The former can be executed, for instance, by the Internet Service Provider or the MNO. The latter can be executed by any on-path adversary, such as the network provider or even the cloud provider that hosts more than one service accessed by the victim. The farther the adversary is either from the victim (the client) or the end-point (the server), the less likely it may be that the adversary has access to re-identification information. The vulnerability has been mitigated with the injection of dummy traffic from the application to the backend. Dummy traffic is generated by all users independently of whether they are COVID-19 positive or not. The issue was fixed in iOS in version 1.0.8 (uniform distribution), 1.1.0 (exponential distribution), Android in version 1.0.7 (uniform distribution), 1.1.0 (exponential distribution), Backend in version 1.1.2-RELEASE. For more information see the referenced GitHub Security Advisory.
CWE description: The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
CVSS v3 base score: 5.3
Published: 2020-11-13T19:15Z
Repository: https://github.com/RadarCOVID/radar-covid-backend-dp3t-server
Language: Java
Files changed: CHANGELOG.md, dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/docker/application.yml, dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/controller/GaenController.java, dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/annotation/ResponseRetention.java, dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/config/ResponseRetentionAspectConfiguration.java, dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/exception/RadarCovidServerException.java, dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/resources/application.yaml
Commit date: 2020-10-09 23:04:38 +0200
Commit message: [MAPR] Setted responses retention time on fake requests

Diff: diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed3de95..79a03a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,10 +2,19 @@
 
 All notable changes to this project will be documented in this file.
 
 ## [Unrelease]
 
+### Added
+
+- Setted responses retention time on fake requests
+- Added aspect configuration
+
+### Fixed
+
+- Fixed messages in aspects.
+
 ## [1.1.2.RELEASE] - 2020-10-09
 
 ### Added
 
 - Updated DP3T release: 1.1.2
diff --git a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/docker/application.yml b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/docker/application.yml
index 7a35b1f..cc28b0b 100644
--- a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/docker/application.yml
+++ b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/docker/application.yml
@@ -131,5 +131,12 @@ application:
     terms-of-service: http://sedia.com/
   endpoint:
     validation:
       url: ${TAN_VALIDATION_URL:}
       enabled: ${TAN_VALIDATION_ENABLED:false}
+  response:
+    retention:
+      enabled: ${RESPONSE_RETENTION_ENABLED:false}
+      time:
+        exposed: ${RESPONSE_RETENTION_TIME_EXPOSED:1000} # milliseconds
+  log:
+    enabled: ${LOGGABLE_ENABLED:false}
\ No newline at end of file
diff --git a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/controller/GaenController.java b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/controller/GaenController.java
index 9fc104c..50f311c 100644
--- a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/controller/GaenController.java
+++ b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/controller/GaenController.java
@@ -8,20 +8,22 @@
  * SPDX-License-Identifier: MPL-2.0
  */
 package org.dpppt.backend.sdk.ws.controller;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
+
 import io.jsonwebtoken.Jwts;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.responses.ApiResponse;
 import io.swagger.v3.oas.annotations.responses.ApiResponses;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.dpppt.backend.sdk.data.gaen.FakeKeyService;
 import org.dpppt.backend.sdk.data.gaen.GAENDataService;
 import org.dpppt.backend.sdk.model.gaen.*;
 import org.dpppt.backend.sdk.ws.radarcovid.annotation.Loggable;
+import org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention;
 import org.dpppt.backend.sdk.ws.security.ValidateRequest;
 import org.dpppt.backend.sdk.ws.security.ValidateRequest.InvalidDateException;
 import org.dpppt.backend.sdk.ws.security.signature.ProtoSignature;
 import org.dpppt.backend.sdk.ws.security.signature.ProtoSignature.ProtoSignatureWrapper;
 import org.dpppt.backend.sdk.ws.util.ValidationUtils;
@@ -98,10 +100,11 @@ public GaenController(GAENDataService dataService, FakeKeyService fakeKeyService
 		this.gaenSigner = gaenSigner;
 	}
 
 	@PostMapping(value = "/exposed")
 	@Loggable
+	@ResponseRetention(time = "application.response.retention.time.exposed")
 	@Transactional
 	@Operation(description = "Send exposed keys to server - includes a fix for the fact that GAEN doesn't give access to the current day's exposed key")
 	@ApiResponses(value = {
 			@ApiResponse(responseCode = "200", description = "The exposed keys have been stored in the database"),
 			@ApiResponse(responseCode = "400", description = 
diff --git a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/annotation/ResponseRetention.java b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/annotation/ResponseRetention.java
new file mode 100644
index 0000000..a6df1b7
--- /dev/null
+++ b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/annotation/ResponseRetention.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2020 Gobierno de España
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+package org.dpppt.backend.sdk.ws.radarcovid.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(value=RetentionPolicy.RUNTIME)
+@Target(value={ElementType.CONSTRUCTOR, ElementType.METHOD})
+public @interface ResponseRetention {
+
+	/**
+	 * Environment property with response retention time, in milliseconds
+	 */
+	String time();
+}
diff --git a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/config/ResponseRetentionAspectConfiguration.java b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/config/ResponseRetentionAspectConfiguration.java
new file mode 100644
index 0000000..681d278
--- /dev/null
+++ b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/config/ResponseRetentionAspectConfiguration.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2020 Gobierno de España
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+package org.dpppt.backend.sdk.ws.radarcovid.config;
+
+import java.util.Arrays;
+
+import org.apache.commons.lang3.math.NumberUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention;
+import org.dpppt.backend.sdk.ws.radarcovid.exception.RadarCovidServerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+
+/**
+ * Aspect in charge of controlling the minimum response time of a service.
+ */
+@Configuration
+@ConditionalOnProperty(name = "application.response.retention.enabled", havingValue = "true", matchIfMissing = true)
+public class ResponseRetentionAspectConfiguration {
+
+	private static final Logger log = LoggerFactory.getLogger("org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention");
+	
+	@Autowired
+	private Environment environment;
+	
+    @Aspect
+    @Component
+    public class ControllerTimeResponseControlAspect {
+
+        @Pointcut("@annotation(responseRetention)")
+        public void annotationPointCutDefinition(ResponseRetention responseRetention){
+        }
+        
+		@Around("execution(@org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention * *..controller..*(..)) && annotationPointCutDefinition(responseRetention)")
+        public Object logAround(ProceedingJoinPoint joinPoint, ResponseRetention responseRetention) throws Throwable {
+
+        	log.debug("************************* INIT TIME RESPONSE CONTROL *********************************");
+            long start = System.currentTimeMillis();
+            try {
+                String className = joinPoint.getSignature().getDeclaringTypeName();
+                String methodName = joinPoint.getSignature().getName();
+                Object result = joinPoint.proceed();
+                long elapsedTime = System.currentTimeMillis() - start;
+                long responseRetentionTimeMillis = getTimeMillis(responseRetention.time());
+                log.debug("Controller : Controller {}.{} () execution time : {} ms", className, methodName, elapsedTime);
+                if (elapsedTime < responseRetentionTimeMillis) {
+                	Thread.sleep(responseRetentionTimeMillis - elapsedTime);
+                }
+                elapsedTime = System.currentTimeMillis() - start;
+                log.debug("Controller : Controller {}.{} () NEW execution time : {} ms", className, methodName, elapsedTime);
+                log.debug("************************* END TIME RESPONSE CONTROL **********************************");
+                return result;
+
+            } catch (IllegalArgumentException e) {
+				log.error("Controller : Illegal argument {} in {} ()", Arrays.toString(joinPoint.getArgs()),
+						joinPoint.getSignature().getName());
+				log.debug("************************* END TIME RESPONSE CONTROL **********************************");
+                throw e;
+            }
+        }
+        
+		private long getTimeMillis(String timeMillisString) {
+			String stringValue = environment.getProperty(timeMillisString);
+			if (NumberUtils.isCreatable(stringValue)) {
+				return Long.parseLong(stringValue);
+			} else {
+				throw new RadarCovidServerException(HttpStatus.INTERNAL_SERVER_ERROR,
+						"Invalid timeMillisString value \"" + timeMillisString + "\" - not found or cannot parse into long");
+			}
+		}
+    }
+
+}
diff --git a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/exception/RadarCovidServerException.java b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/exception/RadarCovidServerException.java
new file mode 100644
index 0000000..620ef55
--- /dev/null
+++ b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/java/org/dpppt/backend/sdk/ws/radarcovid/exception/RadarCovidServerException.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2020 Gobierno de España
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+package org.dpppt.backend.sdk.ws.radarcovid.exception;
+
+import org.springframework.http.HttpStatus;
+
+
+public class RadarCovidServerException extends RuntimeException {
+
+    private final HttpStatus httpStatus;
+
+    /**
+     * The Constructor for the Exception class.
+     *
+     * @param httpStatus the state of the server
+     * @param message    the message
+     */
+    public RadarCovidServerException(HttpStatus httpStatus, String message) {
+        super(message);
+        this.httpStatus = httpStatus;
+    }
+
+	public HttpStatus getHttpStatus() {
+		return httpStatus;
+	}
+    
+}
diff --git a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/resources/application.yaml b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/resources/application.yaml
index 7a35b1f..73f6cb6 100644
--- a/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/resources/application.yaml
+++ b/dpppt-backend-sdk/dpppt-backend-sdk-ws/src/main/resources/application.yaml
@@ -131,5 +131,12 @@ application:
     terms-of-service: http://sedia.com/
   endpoint:
     validation:
       url: ${TAN_VALIDATION_URL:}
       enabled: ${TAN_VALIDATION_ENABLED:false}
+  response:
+    retention:
+      enabled: ${RESPONSE_RETENTION_ENABLED:true}
+      time:
+        exposed: ${RESPONSE_RETENTION_TIME_EXPOSED:1000} # milliseconds
+  log:
+    enabled: ${LOGGABLE_ENABLED:true}
\ No newline at end of file

Fixed code: ### Added

- Setted responses retention time on fake requests
- Added aspect configuration

### Fixed

- Fixed messages in aspects.

  response:
    retention:
      enabled: ${RESPONSE_RETENTION_ENABLED:false}
      time:
        exposed: ${RESPONSE_RETENTION_TIME_EXPOSED:1000} # milliseconds
  log:
    enabled: ${LOGGABLE_ENABLED:false}

import org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention;
	@ResponseRetention(time = "application.response.retention.time.exposed")
/*
 * Copyright (c) 2020 Gobierno de España
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * SPDX-License-Identifier: MPL-2.0
 */
package org.dpppt.backend.sdk.ws.radarcovid.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Retention(value=RetentionPolicy.RUNTIME)
@Target(value={ElementType.CONSTRUCTOR, ElementType.METHOD})
public @interface ResponseRetention {

	/**
	 * Environment property with response retention time, in milliseconds
	 */
	String time();
}
/*
 * Copyright (c) 2020 Gobierno de España
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * SPDX-License-Identifier: MPL-2.0
 */
package org.dpppt.backend.sdk.ws.radarcovid.config;

import java.util.Arrays;

import org.apache.commons.lang3.math.NumberUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention;
import org.dpppt.backend.sdk.ws.radarcovid.exception.RadarCovidServerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * Aspect in charge of controlling the minimum response time of a service.
 */
@Configuration
@ConditionalOnProperty(name = "application.response.retention.enabled", havingValue = "true", matchIfMissing = true)
public class ResponseRetentionAspectConfiguration {

	private static final Logger log = LoggerFactory.getLogger("org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention");
	
	@Autowired
	private Environment environment;
	
    @Aspect
    @Component
    public class ControllerTimeResponseControlAspect {

        @Pointcut("@annotation(responseRetention)")
        public void annotationPointCutDefinition(ResponseRetention responseRetention){
        }
        
		@Around("execution(@org.dpppt.backend.sdk.ws.radarcovid.annotation.ResponseRetention * *..controller..*(..)) && annotationPointCutDefinition(responseRetention)")
        public Object logAround(ProceedingJoinPoint joinPoint, ResponseRetention responseRetention) throws Throwable {

        	log.debug("************************* INIT TIME RESPONSE CONTROL *********************************");
            long start = System.currentTimeMillis();
            try {
                String className = joinPoint.getSignature().getDeclaringTypeName();
                String methodName = joinPoint.getSignature().getName();
                Object result = joinPoint.proceed();
                long elapsedTime = System.currentTimeMillis() - start;
                long responseRetentionTimeMillis = getTimeMillis(responseRetention.time());
                log.debug("Controller : Controller {}.{} () execution time : {} ms", className, methodName, elapsedTime);
                if (elapsedTime < responseRetentionTimeMillis) {
                	Thread.sleep(responseRetentionTimeMillis - elapsedTime);
                }
                elapsedTime = System.currentTimeMillis() - start;
                log.debug("Controller : Controller {}.{} () NEW execution time : {} ms", className, methodName, elapsedTime);
                log.debug("************************* END TIME RESPONSE CONTROL **********************************");
                return result;

            } catch (IllegalArgumentException e) {
				log.error("Controller : Illegal argument {} in {} ()", Arrays.toString(joinPoint.getArgs()),
						joinPoint.getSignature().getName());
				log.debug("************************* END TIME RESPONSE CONTROL **********************************");
                throw e;
            }
        }
        
		private long getTimeMillis(String timeMillisString) {
			String stringValue = environment.getProperty(timeMillisString);
			if (NumberUtils.isCreatable(stringValue)) {
				return Long.parseLong(stringValue);
			} else {
				throw new RadarCovidServerException(HttpStatus.INTERNAL_SERVER_ERROR,
						"Invalid timeMillisString value \"" + timeMillisString + "\" - not found or cannot parse into long");
			}
		}
    }

}
/*
 * Copyright (c) 2020 Gobierno de España
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * SPDX-License-Identifier: MPL-2.0
 */
package org.dpppt.backend.sdk.ws.radarcovid.exception;

import org.springframework.http.HttpStatus;


public class RadarCovidServerException extends RuntimeException {

    private final HttpStatus httpStatus;

    /**
     * The Constructor for the Exception class.
     *
     * @param httpStatus the state of the server
     * @param message    the message
     */
    public RadarCovidServerException(HttpStatus httpStatus, String message) {
        super(message);
        this.httpStatus = httpStatus;
    }

	public HttpStatus getHttpStatus() {
		return httpStatus;
	}
    
}
  response:
    retention:
      enabled: ${RESPONSE_RETENTION_ENABLED:true}
      time:
        exposed: ${RESPONSE_RETENTION_TIME_EXPOSED:1000} # milliseconds
  log:
    enabled: ${LOGGABLE_ENABLED:true}