Skip to content

ENG-8821 fix(network-ops): honor empty-string null session in netexec - #178

Merged
thomasqbrady merged 2 commits into
mainfrom
eng-8821-netexec-null-session
Oct 16, 2026
Merged

thomasqbrady merged 2 commits into
mainfrom
eng-8821-netexec-null-session

Conversation

@thomasqbrady

Copy link
Copy Markdown
Contributor

Summary

netexec's tool docstrings told agents that an empty username/password triggers a null session, but the argv builder used truthiness guards (if username:), so username=""/password="" were falsy and -u/-p were dropped entirely. The agent followed the documented contract and got a different invocation than promised — a real NetExec null session is the explicit -u '' -p '' form (reported live repro on a Samba AD DC: the omitted-flag form connects as Null Auth:True but then fails --shares with STATUS_USER_SESSION_DELETED, while -u '' -p '' succeeds).

Change

  • Distinguish None/[] (omit the flag) from "" (emit the flag with its empty value) in the base netexec() argv builder, via a shared _emit_auth_flag helper. All specialized/generic wrappers delegate to this builder, so the fix applies uniformly.
  • Tighten the username/password docstrings (base + wrappers) to state exactly what "" emits and that a null session needs both empty.
  • Bump network-ops to 2.2.0 (behavior change to an existing argument's public surface).

NetExec requires password == "" for both the anonymous null session and the unauthenticated AS-REP roast (it logs a hint to run with -p ''), so emitting the empty flag is what the tool expects; None stays "omit".

Tests

tests/test_tool_fixes.py — new TestNetexecNullSession: -u '' -p '' null session, None omits, populated-creds regression, username + empty password (AS-REP style), multi-value list expansion, empty-list omission, and the netexec_smb_enum_shares wrapper pass-through. 72 pass; pre-commit and just validate clean.

…G-8821)

The netexec docstrings told agents that an empty username/password triggers a
null session, but the argv builder used truthiness guards, so username=""/
password="" were falsy and -u/-p were dropped — the agent got a different
invocation than documented. A real NetExec null session is the explicit
-u '' -p '' form.

Distinguish None/[] (omit the flag) from "" (emit the flag with its empty
value) via a shared _emit_auth_flag helper. This also satisfies NetExec's
unauthenticated AS-REP roast, which gates on password == "" to engage.

Tighten the username/password docstrings to state what "" emits, and bump
network-ops to 2.2.0 for the public-surface behavior change.
…-session

# Conflicts:
#	capabilities/network-ops/capability.yaml
#	capabilities/network-ops/tests/test_tool_fixes.py
@mkultraWasHere
mkultraWasHere self-requested a review October 16, 2026 01:33

@mkultraWasHere mkultraWasHere left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good one.

@thomasqbrady
thomasqbrady merged commit fea4b7b into main Oct 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants