Skip to content

fix(kerberos): support inter-realm (referral) TGT from a ccache - #2351

Merged
anadrianmanrique merged 3 commits into
fortra:masterfrom
azoxlpf:fix/cross-realm-referral-tgt
Nov 3, 2026
Merged

anadrianmanrique merged 3 commits into
fortra:masterfrom
azoxlpf:fix/cross-realm-referral-tgt

Conversation

@azoxlpf

@azoxlpf azoxlpf commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR makes impacket usable with an inter-realm (referral) TGT (krbtgt/FOREIGN.REALM@LOCAL.REALM) stored in a ccache, e.g. the one getST.py -spn krbtgt/FOREIGN.REALM writes. Two bugs were in the way:

  • CCache.parseFile() only looked for krbtgt/<domain>@<domain>, so the referral TGT was ignored and impacket fell back to a password-less AS-REQ → KDC_ERR_PREAUTH_FAILED (see "Before"). New CCache.getInterRealmTGT() returns it.

  • getKerberosTGS() sent the TGS-REQ to the realm that issued the TGT instead of the realm its krbtgt/<realm> sname grants → KDC_ERR_WRONG_REALM. The realm is now read from the TGT, and only when its sname is krbtgt/<realm>, so a regular TGT and an explicitly passed realm are unaffected.

Fixing it in getKerberosTGS() covers SMB, LDAP, MSSQL/TDS and DCE/RPC at once.

Related: #541, same root cause, opened in 2018, never merged.

Before :

image

After :

image

@azoxlpf

azoxlpf commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Hey @anadrianmanrique , sorry to bother you again ahaha. If you have a bit of time, could you take a look at this? I think it’s an important fix for Impacket, I’ve had feedback from several engagements where people were unable to use a TGT from domain A to access domain B

@anadrianmanrique anadrianmanrique self-assigned this Oct 29, 2026
@anadrianmanrique anadrianmanrique added enhancement Implemented features can be improved or revised medium Medium priority item labels Oct 29, 2026
@Dfte

Dfte commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Hey! I can confirm, this happened to me twice and the only solution we have so far is using this tool https://github.com/AlexLinov/Cross-Realm-TGS/.

@anadrianmanrique
anadrianmanrique force-pushed the fix/cross-realm-referral-tgt branch 2 times, most recently from 77e305c to a4ca783 Compare November 2, 2026 20:44
@anadrianmanrique
anadrianmanrique force-pushed the fix/cross-realm-referral-tgt branch from a4ca783 to 8e97020 Compare November 2, 2026 20:46
@anadrianmanrique

Copy link
Copy Markdown
Collaborator

I'll merge this one, although I've found issues regarding cached bundled tickets, and also using referrals with intermediate domains, all reproducible in GOAD env. These will be addressed in a separate PR. Thank you!
Also @Ramzeth, thanks! your PR will be finally merged.

@anadrianmanrique
anadrianmanrique merged commit c6efd1a into fortra:master Nov 3, 2026
8 checks passed
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 11, 2026
…ra#2351)

Upstream: fortra#2351

Conflict with fortra#2244 on parseFile: kept anySPN for TGS/TGT lookup, then
fall back to getInterRealmTGT.
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 11, 2026
…2303)

Upstream: fortra#2303

Conflict in tests/misc/test_kerberosv5.py with fortra#2351: kept both test classes.
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 22, 2026
Upstream: fortra#2244
Keep getInterRealmTGT fallback from fortra#2351; pass anySPN through to getCredential.
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 22, 2026
…2303)

Upstream: fortra#2303
Keep fortra#2351 Type3/inter-realm tests alongside sendReceive tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Implemented features can be improved or revised medium Medium priority item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants