V1Plugin.Decrypt panics on empty ciphertext (Remote DoS)
The Decrypt method of the V1Plugin reads the first byte of the ciphertext without checking that the ciphertext is non-empty. An attacker who can reach the gRPC socket can send a decrypt request with an empty ciphertext and crash the whole aws-encryption-provider process.
- Fixed in 2 months
- Disclosed after 2 months
Component: pkg/plugin/plugin.go:179 Affected Version: aws-encryption-provider @ 4341c70 (all versions) Found by: Fuzz testing (FuzzV1Decrypt, seed#0: empty []byte{})
Summary
V1Plugin.Decrypt() accesses request.Cipher[0] without checking that the slice is non-empty. Sending a DecryptRequest with empty or nil Cipher field causes an unrecoverable index out of range panic that crashes the entire gRPC server process.
Vulnerable Code
// pkg/plugin/plugin.go:175-181
func (p *V1Plugin) Decrypt(ctx context.Context, request *pb.DecryptRequest) (*pb.DecryptResponse, error) {
zap.L().Debug("starting decrypt operation")
startTime := time.Now()
if string(request.Cipher[0]) == kmsplugin.StorageVersion { // <-- LINE 179: PANIC if len == 0
request.Cipher = request.Cipher[1:]
}
Root Cause
The storage version prefix check indexes into request.Cipher at position 0 without any bounds check. The gRPC protobuf layer deserializes the Cipher field as a []byte which can be empty ([]byte{}) or nil. No validation ensures len(request.Cipher) > 0 before the index access.
Reproducer
The fuzz harness FuzzV1Decrypt in pkg/plugin/fuzz_test.go triggers this immediately:
$ go test -fuzz FuzzV1Decrypt -fuzztime 10s ./pkg/plugin/
--- FAIL: FuzzV1Decrypt (0.00s)
--- FAIL: FuzzV1Decrypt/seed#0 (0.00s)
panic: runtime error: index out of range [0] with length 0
sigs.k8s.io/aws-encryption-provider/pkg/plugin.(*V1Plugin).Decrypt
████████
Minimal gRPC client reproducer:
conn, _ := grpc.Dial("unix:///var/run/kmsplugin/socket.sock", grpc.WithInsecure())
client := pb.NewKeyManagementServiceClient(conn)
// This crashes the server:
client.Decrypt(context.Background(), &pb.DecryptRequest{Cipher: []byte{}})
Suggested Fix
func (p *V1Plugin) Decrypt(ctx context.Context, request *pb.DecryptRequest) (*pb.DecryptResponse, error) {
zap.L().Debug("starting decrypt operation")
startTime := time.Now()
if len(request.Cipher) == 0 {
return nil, fmt.Errorf("invalid empty ciphertext")
}
if string(request.Cipher[0]) == kmsplugin.StorageVersion {
request.Cipher = request.Cipher[1:]
}
Platform
Tested on macOS arm64, Go 1.26.1. Bug is platform-independent (pure Go).
Impact
Impact
- Server crash: The panic is unrecovered — it kills the entire aws-encryption-provider process
- Kubernetes secret unavailability: While the pod restarts, kube-apiserver cannot encrypt/decrypt any Secrets at rest, blocking pod creation, configmap reads, service account token issuance
- No authentication required: The gRPC server has no auth — any process with access to the Unix socket can trigger this
- Trivially exploitable: Single gRPC call with empty ciphertext, no valid KMS credentials needed
- Affects both nil and empty slices: Both
Cipher: nilandCipher: []byte{}trigger the panic
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The storage version prefix check indexes into request.Cipher at position 0 without first checking that the slice is non-empty.
Impact
The panic is unrecovered and kills the whole process, so while the pod restarts Kubernetes cannot encrypt or decrypt Secrets at rest, blocking pod creation, configmap reads and service account token issuance; no authentication is needed, only access to the Unix socket.
What the attacker needed
Access to the plugin's Unix socket
The fix
The code should reject an empty ciphertext with an error before reading the first byte.
How it was found
- Connect to the plugin's gRPC Unix socket.
- Send a Decrypt request whose Cipher field is an empty byte slice.
- Observe the server panic with an index out of range error.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The plugin checks whether the encrypted data starts with a particular marker byte, but it looks at the first byte before checking that any data was sent at all. When the data is empty, the program tries to read a byte that does not exist and crashes. Because the crash is not caught, the whole service goes down until it restarts.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.