Skip to content

Flag Unconstrained delegation in LDAP processing - #1513

Merged
NeffIsBack merged 8 commits into
Pennyw0rth:mainfrom
SoftAndoWetto:delegation-fix
Nov 16, 2026
Merged

NeffIsBack merged 8 commits into
Pennyw0rth:mainfrom
SoftAndoWetto:delegation-fix

Conversation

@SoftAndoWetto

@SoftAndoWetto SoftAndoWetto commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Record Unconstrained delegation before overwriting delegation and rightsTo.

Description

Fix to the issue I raised #1512 where if an account has both UF_TRUSTED_FOR_DELEGATION and msDS-AllowedToDelegateTo set then "Unconstrained" gets overwritten by "Constrained" rather than both being listed

AI Assistance

Claude Sonnet 5

Type of change

Insert an "x" inside the brackets for relevant items

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Deprecation of feature or functionality
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dploot, lsassy, etc)
  • This PR was created with the assistance of AI (list what type of assistance, tool(s)/model(s) in the description)

Setup guide for the review

Have an account with both UF_TRUSTED_FOR_DELEGATION and msDS-AllowedToDelegateTo, then run the nxc flag --find-delegation

Screenshots (if appropriate):

image

Checklist:

Insert an "x" inside the brackets for completed and relevant items (do not delete options)

  • I have ran Ruff against my changes (poetry: poetry run ruff check ., use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary (new modules or features are required to be added to the e2e tests)
  • If reliant on changes of third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have linked relevant sources that describes the added technique (blog posts, documentation, etc)
  • I have performed a self-review of my own code (not an AI review)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)

Record Unconstrained delegation before overwriting delegation and rightsTo.

Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com>
@termanix

termanix commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for PR. I tested it against HTB (cant use my local lab right now); I think this fixes the Unconstrained + Constrained case (your case)

But the elif in the first block still hides Protocol Transition. If an account has TRUSTED_FOR_DELEGATION and TRUSTED_TO_AUTH_FOR_DELEGATION, the elif branch is skipped, protocolTransition stays 0, and the constrained row is labeled plain “Constrained”. Without msDS-AllowedToDelegateTo, PT isn’t shown at all.

I believe this way of fixing it is more sound. Could you also test it this way in your own lab, just to be sure?

# Filter out DCs, unconstrained delegation to DCs is not a useful information
if userAccountControl & UF_TRUSTED_FOR_DELEGATION and not userAccountControl & UF_SERVER_TRUST_ACCOUNT:
    # Append immediately: an account can also have constrained delegation configured
    answers.append([sAMAccountName, objectType, "Unconstrained", "N/A"])
if userAccountControl & UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION:
    delegation = "Constrained w/ Protocol Transition"
    protocolTransition = 1

if item.get("msDS-AllowedToDelegateTo") is not None:
    if protocolTransition == 0:
        delegation = "Constrained"
    rightsTo = item.get("msDS-AllowedToDelegateTo")

Once you have checked it as well, Then need to get @NeffIsBack opinion about the situation.

@NeffIsBack NeffIsBack added the bug-fix This Pull Request fixes a bug label Nov 8, 2026
@SoftAndoWetto

Copy link
Copy Markdown
Contributor Author

Works on my side

@mpgn

mpgn commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

agreed with @termanix fix

@NeffIsBack

Copy link
Copy Markdown
Member

Works on my side

Please apply it then :D

Refactor delegation handling logic for clarity and correctness.

Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com>
@NeffIsBack

Copy link
Copy Markdown
Member

Have an account with both UF_TRUSTED_FOR_DELEGATION and msDS-AllowedToDelegateTo, then run the nxc flag --find-delegation

Feedback for the review: Having an explanation where to configure this helps. In this case I know where the UI is, but people (including me) might not know especially with more complicated stuff like configuring Kerberos magic.

NeffIsBack
NeffIsBack previously approved these changes Nov 16, 2026

@NeffIsBack NeffIsBack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM although I still wonder how this could even be configured (see #1512 (comment)). Also made a bunch of improvements to the overall code while I was at it and deprecated --trusted-for-delegation as discussed on discord. @mpgn could you review my changes?

image

Comment thread nxc/protocols/ldap.py Resolved
@NeffIsBack
NeffIsBack merged commit df95344 into Pennyw0rth:main Nov 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix This Pull Request fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--find-delegation does not report Constrained and Unconstrained delegation types for the same account

4 participants