Skip to content

providers/ldap: fix memory leak in the cached searcher (cherry-pick #26028 to version-2026.8) - #26050

Merged
BeryJu merged 2 commits into
version-2026.8from
cherry-pick/26028-to-version-2026.8
Sep 11, 2026
Merged

BeryJu merged 2 commits into
version-2026.8from
cherry-pick/26028-to-version-2026.8

Conversation

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

Cherry-pick of #26028 to version-2026.8 branch.

Original PR: #26028
Original Author: @cheesegrits
Cherry-picked commit: def9ac7

internal/outpost/ldap: stop retaining pointers into the cached user slice

The memory searcher stored `&ms.users[i]` on a non-searching bind DN's
flags the first time that user searched, and never cleared it. Every
refresh replaces `ms.users`, so each stored pointer kept an entire
superseded copy of the directory alive for the life of the process. On
a directory of ~6k users with ~70k memberships, each distinct password
login after a restart pinned ~100-160 MB until the outpost was killed
for memory. The same pointer also froze the user's own entry (memberOf)
at its first-search state.

Replace the two bare slices with an immutable snapshot (users, groups
and a pk index) behind an atomic pointer. fetch() builds a new snapshot
and swaps it; Search() loads the snapshot once per request, resolves
the bound user by pk against the current one and copies the value for
the duration of the request. Nothing is written to the per-DN flags.

This also removes the unsynchronised slice replacement during a refresh
and the per-request linear scan over all users.

The regression test drives the searcher against a fake core: a
non-searching user's self-read must reflect a group change after the
searcher is re-initialised the way Refresh() does, and the DN's flags
must not carry a user pointer afterwards. It fails on the previous
code on both counts.

Co-authored-by: Dewi Roberts <[email protected]>
@netlify

netlify Bot commented Sep 11, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit f70e20f
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6aa3ee2ebf81f2000846b82f
😎 Deploy Preview https://deploy-preview-26050--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 11, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit f70e20f
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6aa3ee2ebf81f2000846b834
😎 Deploy Preview https://deploy-preview-26050--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.81%. Comparing base (ebe2661) to head (c7baa00).
⚠️ Report is 1 commits behind head on version-2026.8.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                Coverage Diff                 @@
##           version-2026.8   #26050      +/-   ##
==================================================
+ Coverage           91.77%   91.81%   +0.04%     
==================================================
  Files                1160     1160              
  Lines               74621    74621              
  Branches             4054     4054              
==================================================
+ Hits                68482    68514      +32     
+ Misses               6097     6065      -32     
  Partials               42       42              
Flag Coverage Δ
conformance 33.90% <ø> (+<0.01%) ⬆️
e2e 38.55% <ø> (+0.86%) ⬆️
integration 30.54% <ø> (+<0.01%) ⬆️
rust 42.92% <ø> (ø)
unit 93.37% <ø> (+<0.01%) ⬆️
unit-migrate 93.39% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Signed-off-by: Jens Langhammer <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-c7baa00cbc4cdd4f57c595ad7467515f7edc0215
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-c7baa00cbc4cdd4f57c595ad7467515f7edc0215

Afterwards, run the upgrade commands from the latest release notes.

@BeryJu
BeryJu merged commit 35ccf1d into version-2026.8 Sep 11, 2026
138 checks passed
@BeryJu
BeryJu deleted the cherry-pick/26028-to-version-2026.8 branch September 11, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants