cloudflare / cloudflare/gokey

Weak PBKDF2 Iteration Count

Open
#84 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
109
PR merge metrics
No merged PRs in 30d

Description

## Summary
The `gokey` utility uses an inadequately low iteration count (4,096) for PBKDF2-HMAC-SHA256 when deriving the master encryption key for "seed files". This significantly weakens the cryptographic protection described in the documentation, allowing an attacker who obtains a user's seed file to perform high-speed offline brute-force attacks to recover the master password and all derived secrets.

## Details
`gokey` is a vaultless password manager that can optionally use a "seed file" as an entropy source. According to the [README.md](https://github.com/cloudflare/gokey/blob/79f478658a0c15b4ef6fed1fbf5e8282e473e583/README.md#L118-L119), it is "reasonably safe to store/backup seed files to a third party location" because the data is encrypted with the user's master password.

The encryption key (`masterkey`) used to protect the seed file is derived in [`csprng.go`](https://github.com/cloudflare/gokey/blob/79f478658a0c15b4ef6fed1fbf5e8282e473e583/csprng.go#L28) using the `passKey` function:

```go
func passKey(password, realm string) []byte {
return pbkdf2.Key([]byte(password), []byte(realm), 4096, 32, sha256.New)
}
```

The iteration count is hardcoded to `4096`. This value is drastically below modern security guidelines (e.g., OWASP recommends at least 600,000 iterations for PBKDF2-HMAC-SHA256). Since the 12-byte salt is stored as a plaintext prefix in the seed file, there is no effective salt secret, and the low work-factor makes the master password vulnerable to GPU-accelerated brute-forcing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.