# GHSA-QCRP-P3RQ-PFFR: Anonymous nested LDAP filter stack overflow aborts kanidmd process

- Database: GitHub
- Severity: CVSS 7.5 (High)
- Published: 2026-06-23
- Modified: 2026-06-23

## Affected versions

- kanidm (crates.io): through 1.10.3

## Description

## Summary

The kanidm LDAP listener decodes every inbound request with the `lber` BER parser before any authentication, bind, or depth check runs. `LdapCodec` from `ldap3_proto` 0.7.1 delegates structural parsing to `lber` 0.4.2, whose recursive-descent decoder has no nesting-depth bound. `ldap3_proto` 0.7.1 added a depth limit to its string-filter PEG parser, and kanidm bounds filter depth in `Filter::from_ldap_ro`, but neither check runs before the wire decoder has already built the nested tag tree on the stack.

GHSA-qcxq-75wr-5cm8 lists `ldap3_proto` 0.7.1 as the patched version for this stack-exhaustion class. The BER wire path stays unbounded on 0.7.1, so the fix does not cover LDAP-protocol input.

An anonymous client that reaches the LDAPS port sends one SearchRequest whose filter nests a few thousand AND tags. The recursive decode overflows the worker-thread stack and the Rust runtime aborts the process.

Result: one unauthenticated LDAP packet under 32 KB terminates the entire kanidmd process, taking down the LDAP server (:3636) and the HTTPS web/OIDC API (:8443) together.

## Affected

kanidm/kanidm server, v1.10.3 (current latest as of 2026-06-10). Live-exploitable on v1.10.3; identical code on master HEAD b1092a7 (1.11.0-dev).
Dependencies: `lber` 0.4.2, `ldap3_proto` 0.7.1 (the version GHSA-qcxq-75wr-5cm8 records as patched).
Condition: the LDAP interface is enabled (`ldapbindaddress` set in the server config). It is off by default (commented in `examples/server_container.toml:16`), and the evaluation quickstart maps port 636 for it.
Not affected: deployments with no LDAP interface configured.

## Root cause

The LDAPS session decodes every message through `FramedRead::new(r, LdapCodec::default())` (`server/core/src/ldaps.rs:64`), and `LdapCodec` parses the BER structure with the `lber` 0.4.2 decoder. The `lber` decoder builds the nested `Tag` tree from constructed TLV elements by recursive descent with no depth bound, so a filter of several thousand nested AND tags (`0xa0`) consumes one stack frame per level. kanidm's filter-depth guard `Filter::from_ldap_ro` (`server/lib/src/filter.rs:772`, `DEFAULT_LIMIT_FILTER_DEPTH_MAX`) runs only after the codec has built the full tree, so it never sees the oversized input. The single codec-level limit is `DEFAULT_MAX_BER_SIZE` (32 KB), a byte-size cap and not a depth cap, and a payload of about 31.9 KB stays under it while overflowing the default 2 MB worker stack (`.thread_stack_size(8 * 1024 * 1024)` is commented out at `server/daemon/src/main.rs:730`). A Rust stack overflow terminates the process, so the overflow on any `kanidmd-thread-pool` worker ends the whole process instead of dropping one connection.

## Reproduction

kanidm v1.10.3 Docker (`docker.io/kanidm/server:1.10.3`), default config with `ldapbindaddress = "0.0.0.0:3636"` enabled, no accounts and no bind used (same code on master HEAD b1092a7).

1. Open one TLS connection to `:3636` and send a single LDAP SearchRequest whose filter is an AND element (`0xa0`) nested 8000 times around `(cn=x)`, with no preceding bind.

```
LDAPMessage ::= SEQUENCE {
  messageID 2,
  SearchRequest {
    baseObject "dc=localhost", scope wholeSubtree,
    filter = a0 a0 a0 ... (x8000) ... a3 04 "cn" 04 "x"
  }
}
total wire size = 31,888 bytes  (under the 32,768-byte DEFAULT_MAX_BER_SIZE)
```

2. Observe the process abort and both ports go down.

```
thread 'kanidmd-thread-pool' has overflowed its stack
fatal runtime error: stack overflow, aborting
# docker inspect: Running=false ExitCode=139 OOMKilled=false
# GET https://localhost:8443/status  ->  connection refused
```

Live-verified: depth 8000 (31,888 bytes, under the size cap) and depth 15000 both abort kanidmd (exit 139, SIGSEGV); depth 7000 (27,888 bytes) is below the stack threshold and the process survives. Recovery requires a manual restart.

## Impact

- One anonymous packet ends the kanidmd process, taking down both LDAPS (:3636) and the HTTPS web/OIDC API (:8443), which share the process.
- The 31.9 KB payload stays under the 32 KB BER size limit, so that limit is not a mitigation.
- With restart policy disabled the outage is permanent; with restart-on-failure the same packet drives a crash loop.
- No authentication, no bind, no account, no UI interaction.

## Credit

Jan Kahmen, [turingpoint](https://www.turingpoint.de) (jan@turingpoint.de)

## References

- https://github.com/kanidm/kanidm/security/advisories/GHSA-qcrp-p3rq-pffr

Page: https://cve.now/GHSA-QCRP-P3RQ-PFFR

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
