Repository navigation
Bound nested-group recursion depth in Negotiate LdapAdapter - #70041
Open
GrantTotinov wants to merge 1 commit into
Open
GrantTotinov wants to merge 1 commit into
GrantTotinov wants to merge 1 commit into
Conversation
GetGroups followed memberOf links with no upper bound, so the length of an acyclic chain of distinct groups returned by the directory decided how deep the managed stack grew. A stack overflow cannot be caught and takes down the whole host. Traversal now stops descending at MaxNestedGroupDepth (32) levels below each directly held group, keeps the claims already collected, and logs a single warning per resolution. The visited-set check is kept so cycles are still skipped cheaply, and the existing behaviour of returning on an already processed group is unchanged. Fixes dotnet#69611
GrantTotinov
requested review from
Youssef1313,
cincuranet,
davpetr,
halter73 and
rokonec
as code owners
October 26, 2026 02:00
Contributor
|
Thanks for your PR, @GrantTotinov. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bound nested-group recursion depth in Negotiate LdapAdapter
Description
Hi! This follows the approach suggested in #69611. Thanks for writing it up in so much detail, that made it easy to pick up.
GetGroupsnow gets the current depth and stops going further up once it reachesMaxNestedGroupDepth, which is an internal constant set to 32. The direct group counts as depth 0. Whatever was collected up to that point is kept. No public API changes.When the limit is hit, one warning is logged for the whole resolution, not one per group. It only includes the user name and the limit, no group names. To make that testable, I moved the loop over the user's direct groups into a small
GetGroupClaimshelper.The visited-set check still runs before the depth check, so cycles are skipped like before and aren't reported as truncation.
I left the existing
returnfor already processed groups alone on purpose. Switching it tocontinuewould change which claims some directories get back, so it felt better as its own change. Happy to send a follow-up if you'd like.I also added a short remark to the
LdapSettings.IgnoreNestedGroupsdocs about the limit.Tests
I used the same
LdapConnectionsubclass plus the reflection helper for building responses that #69955 uses. Whichever of the two gets merged second can just reuse the helper from the other one, and I'm happy to handle the merge on my side.New tests:
All 105 tests in
Negotiate.Testpass locally. When I disabled only the depth check, just the two over-the-limit tests failed.Fixes #69611