Skip to content

drsuapi: drop writeDSNAME structLen +2 cargo-cult#34

Merged
psycep merged 1 commit into
mainfrom
drsuapi-dsname-structlen-fix-issue-32
May 13, 2026
Merged

drsuapi: drop writeDSNAME structLen +2 cargo-cult#34
psycep merged 1 commit into
mainfrom
drsuapi-dsname-structlen-fix-issue-32

Conversation

@psycep
Copy link
Copy Markdown
Collaborator

@psycep psycep commented May 13, 2026

Summary

Closes the final item from #32. MS-DRSR 4.1.4.1.1 specifies structLen as the exact byte size of the DSNAME structure, rounded up to a 4-byte boundary. The previous code applied the round-up and then added 2 more bytes "per Impacket" — neither the spec nor the wire trace justifies the extra 2 bytes. AD is forgiving in practice but a stricter implementation could reject. With the +2 in place the advertised structLen was systematically congruent to 2 mod 4 (i.e. off the alignment) and 2 bytes larger than the actual serialized payload. The trailing written % 4 round at the end of writeDSNAME already handles wire-side NDR alignment, so dropping the +2 doesn't leave a gap.

Verification

Item 3 was held out of #33 because it's request-side and there's no parser-side regression detection. Verified end-to-end against the GOAD lab:

  • Forest root (sevenkingdoms.local, kingslanding @ 10.10.10.10) — secretsdump --just-dc-ntlm exercises DsBindDsDomainControllerInfoDsCrackNames (via GetDomainDN) → DsGetNCChanges. All four returned success; full account dump captured.
  • Child domain (north.sevenkingdoms.local, winterfell @ 10.10.10.11) — same four-RPC sequence, full dump captured.
  • Output is byte-for-byte identical to the dumps captured with the +2 in place (the same dumps from drsuapi: tighten V6 parser allocations, fix RDN unescape, drop dead helper #33's lab pass).

Test plan

  • go build ./...
  • go vet ./pkg/dcerpc/drsuapi/...
  • go test ./pkg/dcerpc/drsuapi/...
  • secretsdump --just-dc-ntlm against forest root (sevenkingdoms.local)
  • secretsdump --just-dc-ntlm against child domain (north.sevenkingdoms.local)
  • Diff of pre-fix vs post-fix dumps shows zero differences

Closes #32.

MS-DRSR 4.1.4.1.1 specifies structLen as the exact byte size, rounded
to a 4-byte boundary. Impacket carries a "+2" on top of the round-up
that no part of the spec or wire trace justifies; AD is forgiving in
practice but a stricter implementation could reject. Keep just the
alignment round, drop the unexplained 2 extra bytes.

This is the last open item from #32. Request-side change with no
parser-side regression detection, so it was held out of #33 pending
lab verification.

Verified end-to-end against the GOAD lab (sevenkingdoms.local forest
root + north.sevenkingdoms.local child domain): secretsdump
--just-dc-ntlm exercises DsBind, DsDomainControllerInfo, DsCrackNames,
and DsGetNCChanges in sequence and returns success on both domains.
Output is byte-for-byte identical to the pre-fix dumps captured before
removing the +2.

Closes #32.
@psycep psycep merged commit 0c32715 into main May 13, 2026
2 checks passed
@psycep psycep deleted the drsuapi-dsname-structlen-fix-issue-32 branch May 13, 2026 16:03
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.

drsuapi: parser hardening follow-ups from PR #31 review

1 participant