Skip to content

Hardcoded DPAPI entropy string in ProtectedKeyProvider weakens defense-in-depth #355

@Christophe-Rogiers

Description

@Christophe-Rogiers

Description

In src/Servy.Core/Security/ProtectedKeyProvider.cs (line 29):

private static readonly byte[] Entropy = Encoding.UTF8.GetBytes("Servy-Entropy-Secure-Key-Storage");

This static entropy value is passed to ProtectedData.Protect() / Unprotect() (DPAPI). The purpose of the entropy parameter is to limit which applications can decrypt the protected data — it acts as a shared secret between the encrypting and decrypting code.

Since this value is hardcoded in the source code (and thus embedded in the compiled binary), anyone with access to the binary can extract it. Combined with access to the DPAPI-protected key files on the target machine (C:\ProgramData\Servy\security\aes_key.dat), an attacker can call ProtectedData.Unprotect() with this entropy to recover the master key.

Severity

Warning — weakens the intended defense-in-depth layer. Exploitable only when combined with access to the target machine's key files, but the entropy value is meant to add an additional protection layer that is currently ineffective.

Suggested fix

Consider moving the entropy to an external protected configuration source (e.g., a machine-level registry key with restricted ACLs, or a separate DPAPI-protected file), so that possession of the binary alone is not sufficient to derive the entropy.

Alternatively, document this as an accepted limitation — DPAPI's primary protection is the user/machine scope, and the entropy is a secondary layer.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions