# GHSA-53hj-r94p-8c8f: Kanidm has non-constant-time comparison of OAuth2 client_secret

> An unauthenticated attacker can theoretically recover OAuth2 client secrets via timing side-channels, though practical exploitation is deemed unrealistic.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 May 2026

## What is GHSA-53hj-r94p-8c8f?

GHSA-53hj-r94p-8c8f is a vulnerability in kanidm, published on 6 May 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Summary

The kanidmd OAuth2 token-exchange (`/oauth2/token`) and token-introspection (`/oauth2/token/introspect`) endpoints compare the supplied `client_secret` against the stored secret using Rust's `PartialEq` on `String`, which short-circuits on the first mismatching byte. This produces an observable timing discrepancy that varies with the length of the matching prefix.

### Details

- https://github.com/kanidm/kanidm/blob/master/server/lib/src/idm/oauth2.rs#L1135 — variable-time comparison in `check_oauth2_token_exchange`
- https://cwe.mitre.org/data/definitions/208.html — CWE-208: Observable Timing Discrepancy

### PoC

Static analysis only — no timing-recovery script was run because remote recovery of a 48-byte high-entropy secret over HTTPS is not practically demonstrable. The variable-time behaviour is established by inspection:

```rust
// server/lib/src/idm/oauth2.rs:1135  (check_oauth2_token_exchange)
if authz_secret == &secret { … } else { return Err(Oauth2Error::AuthenticationRequired); }
```

`String: PartialEq` delegates to `<[u8] as PartialEq>::eq`, which checks length equality then iterates byte-by-byte and returns on the first difference.

### Impact

An unauthenticated network attacker who can reach the OAuth2 endpoints can submit arbitrary `client_id`/`client_secret` pairs and observe response latency. In principle the early-exit comparison leaks the position of the first mismatching byte, providing a timing oracle toward incremental recovery of a confidential client's secret. In practice the stored secret is a server-generated 48-character high-entropy string, the comparison runs inside an async tokio handler behind TLS, and network jitter is orders of magnitude larger than a single byte-compare — so remote recovery is not considered realistic with current techniques. This is a hardening issue rather than a practically exploitable vulnerability.

### Affected versions

All published `kanidmd_lib` releases; the comparison is still variable-time on `master` at 1.10.0-dev

## Which versions are affected by GHSA-53hj-r94p-8c8f?

2 open source packages ship an affected version, including kanidm.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `kanidm` | crates.io | All versions | 1.9.3 |
| `kanidm` | crates.io | All versions | 1.9.3 |

## How do I fix GHSA-53hj-r94p-8c8f?

Upgrade kanidm to 1.9.3 or later.

## Is GHSA-53hj-r94p-8c8f being exploited?

There is no known exploitation of GHSA-53hj-r94p-8c8f in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-53hj-r94p-8c8f and fix it if it is affected.

What it is: GHSA-53hj-r94p-8c8f is a vulnerability in kanidm, published on 6 May 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-53hj-r94p-8c8f in the wild and no public exploit code.

Affected packages and fixed versions:
- kanidm (crates.io): affected all versions; fixed in 1.9.3
- kanidm (crates.io): affected all versions; fixed in 1.9.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-53hj-r94p-8c8f/ (Markdown: https://insights.sbomify.com/GHSA-53hj-r94p-8c8f/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-53hj-r94p-8c8f

---
From sbomify Insights: https://insights.sbomify.com/GHSA-53hj-r94p-8c8f/
Summaries are generated and may contain mistakes; the official description above is the record.
