what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Microsoft Windows Containers DP API Cryptography Flaw

Microsoft Windows Containers DP API Cryptography Flaw
Posted Mar 16, 2021
Authored by Marc Nimmerrichte

Microsoft Windows Containers suffers from a DP API design flaw where encryption keys are shared and reused between images.

tags | exploit
systems | windows
advisories | CVE-2021-1645
SHA-256 | 9ca89e4b58c712f3b5cd994828e6290959a5d09fa6b74c261d55967effb8af17

Microsoft Windows Containers DP API Cryptography Flaw

Change Mirror Download
~ Certitude Security Advisory - CSA-2021-002 ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
PRODUCT : Windows Containers
VENDOR : Microsoft
AFFECTED VERSION : Windows 10, Windows Server
PATCH VERSION : KB4598229, KB4598230, KB4598242, KB4598243
FOUND BY : Marc Nimmerrichter, Certitude Lab


Windows containers is a feature that extends the container concept well-known
from Linux environments to Windows. Just like containers on Linux, Windows
containers utilize a shared kernel but container processes are somewhat
isolated from one another.

The Windows Data Protection API (DP API) allows applications to encrypt
arbitrary data. An application does not have to manage keys, but instead, any
data can be passed to the API, which then returns an encrypted blob.
Similarly, an application can pass a previously encrypted blob to DP API to
retrieve the plain text. The cryptographic key used for these encryption
operations is either tied to the user context or is unique to a machine.

There was a design issue with DP API in containers which resulted in DP API
using the same key in all containers. Additionally, these keys were public in
base-image layers published by Microsoft.

Organizations using DP API inside containers should apply patches to Windows
and use the latest base images. However, the fix causes a design change, which
might render the use of DP API difficult for many use-cases.

Vulnerability Overview

The vulnerability described applies to both, user- and machine-key DP API
encryption within Windows Docker containers. In our description we will use
machine key encryption, but the same issue exists if data is encrypted with
the user-key.

Normally, a machine key is tied to a (virtual-)machine. Therefore, a machine
is not able to decrypt data encrypted by an application on another machine.
However, due to a design issue, DP API machine keys used in containers came
from the container images. Since Windows docker images are based on the same
base images, the DP API keys of containers were identical. As the base image
is public, the DP API keys were public too!

Therefore, DP API operations performed by any Windows container application
were ineffective, as the encryption key that was used is public. Organizations
that used DP API in Windows Docker containers and relied on it to store
encrypted data in a potentially insecure location, should consider this data
as compromised.


First, start a docker container called Alice on VM1:

\$ docker run --name Alice -it

Then, encrypt a file in the Alice container using the powershell script

C:\>powershell.exe -File vault.ps1 -StoreSecret "This is my secret text"

C:\>type secret.txt

Start a docker container Bob on VM2:

\$ docker run --name Bob -it

The following command shows that the file encrypted by Alice on VM1 can be
decrypted in the Bob container on VM2:

C:\>powershell.exe -File vault.ps1 secret.txt
This is my secret text

The vault.ps1 PowerShell script from
https://blag.nullteilerfrei.de/2018/01/05/powershell-dpapi-script/ used in
this PoC:

``` {.powershell```}
[string] $StoreSecret,
[string] $filename )
[void] [Reflection.Assembly]::LoadWithPartialName("System.Security")
$scope = [System.Security.Cryptography.DataProtectionScope]::CurrentUser
if ($StoreSecret -eq "") {
$data = Get-Content $filename
$ciphertext = [System.Convert]::FromBase64String($data)
$plaintext = [System.Security.Cryptography.ProtectedData]::Unprotect(
$ciphertext, $null, $scope )
} else {
$plaintext = [System.Text.UTF8Encoding]::UTF8.GetBytes($StoreSecret)
$ciphertext = [System.Security.Cryptography.ProtectedData]::Protect(
$plaintext, $null, $scope )
[System.Convert]::ToBase64String($ciphertext) > $filename


Microsoft fixed this vulnerability with a patch for Windows Server and Windows
10 operating systems and in their docker base-images. Users should apply both,
OS updates and base-image updates, to address this issue. Please also refer to

However, the patch comes with a caveat: As the issue is a design problem, it
could not be fixed in a straightforward way. Windows containers now generate a
DP API key when the container is first started. This also means that all
containers use different keys. There is currently no supported way to share
keys between containers or transfer a key from one container to another. This
is impractical, because containers are often relatively short-lived. Moreover,
when a container is scaled up, new containers will not be able to work with
previously encrypted blobs. This reduces the potential use-cases of DP API
with containers.



(c) 2021 Certitude Consulting GmbH

Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags


packet storm

© 2022 Packet Storm. All rights reserved.

Security Services
Hosting By