# Bypass validation parts in AWS IAM Authenticator for Kubernetes

Case-sensitive duplicate query params in aws-iam-authenticator tokens let attackers override signed values like AccessKeyID and cluster ID, enabling identity spoofing and replay.

- Payout: $2,500
- Severity: high
- Program: Kubernetes
- Found by: 0ria
- Disclosed: 2023-05-25
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1580493
- Library page: https://bugbountylibrary.com/r/h1%3A1580493
- Tags: area:cloud domain:cloud domain:infra impact:privesc kind:bounty platform:hackerone sev:high tech:aws tech:go tech:kubernetes technique:param-pollution technique:source-review vuln:access-control vuln:auth-bypass

**Target:** aws-iam-authenticator /authenticate webhook token validation
**Root cause:** Token parser lowercases query param keys into a map while the signed URL retains both case variants; AWS STS ignores the duplicate but the authenticator's map is overwritten by whichever iteration order wins, so unsigned attacker-controlled values (AccessKeyID, action, signedheaders) can override signed ones.
**Steps:**
1. Generate a presigned STS GetCallerIdentity URL with boto3 RequestSigner including `x-k8s-aws-id` header.
2. Append a duplicate param with different case, e.g. `&x-amz-credential=some-other-value` or `&action=GetCallerIdentity` after stripping the original, then base64url-encode without padding prefixed with `k8s-aws-v1.`.
3. POST `{"Spec":{"Token":"<token>"}}` to `/authenticate`; retry until the unordered map iteration picks the attacker value.
4. Observe server logs `accesskeyid=some-other-value` and mapping template `user:{{AccessKeyID}}` yields attacker-controlled K8s username.
**How found:** Code reading of token.go's query param whitelist loop revealed keys are lowercased into a map while the raw URL keeps both cases; hypothesis that AWS STS ignores the duplicate but the local map is overwritten, confirmed by crafting tokens with boto3.
**Exploitation:** Attacker with any valid AWS credentials mints a signed token, injects a case-variant duplicate query param, and replays it to the authenticator; because the map override is nondeterministic, repeated requests eventually yield a token whose AccessKeyID or cluster-ID binding is attacker-chosen, letting them impersonate a mapped user/group with higher privileges or replay a token across clusters.
**Escalation:** Mapping AccessKeyID into username/groups via config template turns the parser bug into cluster privilege escalation.
**Insight:** When a validator normalizes keys (lowercase) but forwards the raw URL to a backend that ignores duplicates, look for case-variant duplicate params to smuggle unsigned values past signature checks; also probe nondeterministic map iteration as an oracle for override success.

## Proof of concept (copied exactly from the original report)

**POST /authenticate request with malicious token**

```
POST /authenticate HTTP/1.1
Host: 127.0.0.1:21362
Content-Length: 563

{"Spec":{"Token":"<token-value>"}}
```

