External Trusts Are Evil
The author found that external non-transitive trusts in Active Directory can be abused to authenticate to other domains within the same forest, contrary to Microsoft's description. An attacker with any low-privileged account in a trusted domain could request a 'local' TGT for the trusting domain and then obtain referrals to other domains in the forest, enabling lateral movement and attacks like Kerberoasting.
exploit.ph
Published on exploit.ph
Another day, another “by design” but clearly unintended Windows AD feature. While playing with Kerberos tickets I discovered an issue that allowed me to authenticate to other domains within a forest across external non-transitive trusts.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up is about Kerberos authentication across Active Directory trusts, specifically external trusts. Microsoft describes an external trust as a trust between two domains that is "non-transitive", which should mean that only users within the trusted domain can authenticate against only the trusting domain. The researcher found that this is not the case: an account in a domain that has an external trust with a domain inside a forest can reach other domains in that forest, which the trust description implies should be prohibited.
The issue was reported to Microsoft. The researcher received the response shown below, and Microsoft did not consider the behaviour to affect security and did not plan to fix it.

Figure 1: MSRC Response
Because Microsoft do not consider this a security issue, the only way to avoid what is described is not to use external trusts at all.
Setup
The lab uses several multi-domain forests with external trusts between them.

Figure 3: Lab Setup
The setup involves three forests, two of which have three domains and the other containing two domains. The domains semperis.lab and treetest.lab have a bidirectional non-transitive external trust.

Figure 4: External Trust 1
The domains grandchild1.child1.semperis.lab and semperisaz.lab also have a bidirectional non-transitive external trust.

Figure 5: External Trust 2
The tickets in the walkthrough are requested with Rubeus. The authenticating user in the first part is lowpriv, and the DCs involved include SGC1DC1.grandchild1.child1.semperis.lab, SC1DC1.child1.semperis.lab and SDC1.semperis.lab.
Finding it
The researcher was playing with Kerberos tickets and noticed that authentication was possible to other domains within a forest across external non-transitive trusts. The description of a trust as non-transitive when it is created is, in the researcher's words, at best misleading, and leaves systems administrators with a false sense of security.
Microsoft's own documentation describes transitivity as follows:
Transitivity determines whether a trust can be extended outside of the two domains with which it was formed.
- A transitive trust can be used to extend trust relationships with other domains.
- A non-transitive trust can be used to deny trust relationships with other domains.
For non-transitive trusts, only the two domains involved in the trust should be able to authenticate to each other and not beyond. The researcher demonstrates that this is not the case.
Exploitation
How Kerberos cross-trust authentication works
The main thing required to authenticate to a service across a trust using Kerberos is a referral (or referral TGT). This is a ticket requested from the local domain controller for the foreign domain. The walkthrough focuses on the semperis.lab forest, which is sufficient to demonstrate how ticket requests across trusts are performed; the information applies to any allowed trust path.
The simplest example is authenticating to a service on a domain which has a direct trust with the local domain. The trust that grandchild1.child1.semperis.lab has with child1.semperis.lab is an example. After obtaining the initial TGT, the first step in obtaining a service ticket for an account in grandchild1.child1.semperis.lab to a service in child1.semperis.lab is to obtain a referral for child1.semperis.lab.

Figure 6: Referral Request For child1.semperis.lab
The request was made to a DC (SGC1DC1.grandchild1.child1.semperis.lab) within the domain (grandchild1.child1.semperis.lab) local to the authenticating user (lowpriv). The request was made for the service krbtgt/child1.semperis.lab, and the fact that the ServiceRealm (srealm) is the local domain (grandchild1.child1.semperis.lab) within the resulting ticket shows that this ticket is a referral.

Figure 7: Referral Request
This referral can now be used to request service tickets (STs) from the foreign domain.

Figure 8: Example Usage of Referral
Here an ST was requested from the foreign DC (SC1DC1.child1.semperis.lab) for the service host/SC1DC1.child1.semperis.lab using the referral retrieved previously.

Figure 9: Requesting ST Using Referral
To take this one step further, if a service on the forest root domain (semperis.lab) is required, a referral for this domain cannot be directly requested from the local (grandchild1.child1.semperis.lab) domain.

Figure 10: Referral Request For semperis.lab
A referral for krbtgt/semperis.lab was requested from the local DC sgc1dc1.grandchild1.child1.semperis.lab. However, the ticket returned by the DC was for the service krbtgt/child1.semperis.lab, meaning that this is a referral for the domain child1.semperis.lab, not semperis.lab.

Figure 11: Requesting Referral For semperis.lab
This can be shown explicitly by trying to use this ticket to request a ST for the semperis.lab domain.

Figure 12: Root Domain Service Ticket Request
This results in an AP_ERR_BAD_INTEGRITY error. The referral ticket is encrypted with the trust key for the grandchild1.child1.semperis.lab --> child1.semperis.lab trust. The DCs in the root domain semperis.lab do not have knowledge of this key and so are not able to decrypt the ticket.

Figure 13: Requesting ST From semperis.lab
To request a service ticket for the root domain semperis.lab, a referral for semperis.lab must first be requested from a DC in the domain child1.semperis.lab using this referral.

Figure 14: Referral Request For semperis.lab
Here a request was made to the foreign DC (sc1dc1.child1.semperis.lab) using the referral for the domain child1.semperis.lab to request a further referral for the root domain semperis.lab. In order to request this ticket, the /targetdomain argument is required. By default Rubeus will use the domain within the ticket passed to it to fill in the domain in the TGS-REQ; in this case that would be grandchild1.child1.semperis.lab, which would result in an ERR_WRONG_REALM error as the domain local to the DC is child1.semperis.lab. This detail is important in the next section.

Figure 15: Requesting Referral For semperis.lab
Lastly, this resulting referral for semperis.lab can be used to request STs for the semperis.lab domain.

Figure 16: Service Ticket Request For semperis.lab
This ST request from the user [redacted] made to the DC SDC1.semperis.lab for the SPN host/SDC1.semperis.lab was successful even though the two domains involved do not have a direct trust, because the trust path is allowed.

Figure 17: ST Request For host/sdc1.semperis.lab
This method of requesting referrals for trusting domains can be followed to request STs for any service within any domain for which the trust path is allowed.
Making the non-transitive transitive
The domains semperisaz.lab and grandchild1.child1.semperis.lab have a bidirectional external trust. This means that after retrieving a TGT for any account within the domain semperisaz.lab, it is possible to request a referral for grandchild1.child1.semperis.lab.

Figure 18: Referral To granchild1.child1.semperis.lab

Figure 19: Request Referral For grandchild1.child1.semperis.lab
This referral can be used to request STs for services on the domain grandchild1.child1.semperis.lab, but trying to obtain a referral to other domains within the same forest (for example child1.semperis.lab) returns an ERR_PATH_NOT_ACCEPTED error, which is expected.

Figure 20: Path Not Accepted Error
This is because the semperisaz.lab --> granchild1.child1.semperis.lab trust is non-transitive, so the path from semperisaz.lab to child1.semperis.lab is not allowed.

Figure 21: Requesting Referral For child1.semperis.lab
However, a "local" TGT for grandchild1.child1.semperis.lab can be requested.

Figure 22: Requesting "local" TGT For grandchild1.child1.semperis.lab
It is called a "local" TGT because, unlike the referral, which has a ServiceRealm (srealm) of semperisaz.lab, the ServiceRealm is grandchild1.child1.semperis.lab.

Figure 23: Requesting "local" TGT
Using this "local" TGT, a referral for child1.semperis.lab can now be requested.

Figure 24: Referral For child1.semperis.lab

Figure 25: "local" TGT To Request Referral For child1.semperis.lab
We now have a usable referral which can be used to request STs for child1.semperis.lab using any account from the semperisaz.lab domain and without making any changes to trusts or accounts within AD.

Figure 26: Requesting ST For DC In child1.semperis.lab
In Figure 26, a ST was requested from the DC sc1dc1.child1.semperis.lab for the service host/sc1dc1.child1.semperis.lab as the user [redacted].

Figure 27: Requesting ST For host/sc1dc1.child1.semperis.lab
This method can be used to hop around any domain within the same forest that grandchild1.child1.sermperis.lab exists in. This is demonstrated by requesting a referral to the root domain semperis.lab.

Figure 28: Requesting Referral For semperis.lab
A referral was requested for semperis.lab from the DC sc1dc1.child1.semperis.lab as the user [redacted].

Figure 29: Requesting Referral To semperis.lab
Hopping across further trusts outside of the forest (external or forest trusts) is not possible using this method. The root domain semperis.lab has a bidirectional external trust with treetest.lab, and this trust can be used to demonstrate that limitation.

Figure 30: Requesting Referral For treetest.lab
This stops an attacker using this method of trust hopping from hopping into another forest.

Figure 31: Requesting Referral For treetest.lab
Hopping further
While it is not possible to hop further using this specific method, the researcher had previously written about the ability to create machine accounts across trusts, and this situation is another example of that.
Using the referral retrieved for semperis.lab, it is possible to request a ticket for the LDAP service on a DC in semperis.lab.

Figure 32: Request ST For LDAP
Here a ST for ldap/sdc1.semperis.lab was requested using the referral for semperis.lab as the user [redacted].

Figure 33: Request ST For ldap/sdc1.semperis.lab
This ST can be injected and used to create a machine account directly in semperis.lab, given the configuration allows Authenticated Users, as is default.

Figure 34: Create Machine Account In semperis.lab
This causes the DC sdc1.semperis.lab to create the machine account TestComp within the semperis.lab domain.

Figure 35: Create Machine Account TestComp
This newly created TestComp machine account is a local account within the domain semperis.lab. Now that there is a machine account that exists within semperis.lab, a TGT can be retrieved for that account.

Figure 36: Machine Account TGT
Requesting the machine account TGT looks as follows.

Figure 37: Requesting TGT For TestComp
This machine account TGT is allowed to request a referral to the trusting domain treetest.lab.

Figure 38: Requesting Referral For treetest.lab
Here the machine account's TGT was used to request a referral for the treetest.lab domain from the DC SDC1.semperis.lab.

Figure 39: Request Referral For treetest.lab
Lastly, the issue described in this post can again be used to gain access to the inaccessible dsptest.lab domain. First by requesting a "local" TGT for treetest.lab.

Figure 40: Requesting Local TGT For treetest.lab
The "local" TGT is requested using the referral for treetest.lab as the account [email protected] from the DC TDC1.treetest.lab.

Figure 41: Requesting "local" TGT For treetest.lab
Then using this "local" TGT to request a referral for dsptest.lab.

Figure 42: Requesting Referral For dsptest.lab
Here a referral was requested for the domain dsptest.lab from the DC TDC1.treetest.lab as the user [email protected].

Figure 43: Requesting Referral For dsptest.lab
Using the combination of these two methods makes it possible to hop very deep into AD enterprise infrastructures, using any low privileged account on a domain which has an external trust to any domain within a forest.
Root cause
The report does not explain the underlying mechanism; it demonstrates that a "local" TGT obtained across an external trust can be used to request referrals to other domains in the same forest.
Microsoft's description of non-transitive trusts, and the trust creation dialogue that uses it, therefore overstate the isolation the trust provides. Microsoft confirmed the behaviour in June 2022 and later determined that it does not affect security.
Impact
Any account within a domain that has an external trust with a domain inside a forest can authenticate against any domain within that whole forest. No changes to trusts or accounts within AD are required. This lets an attacker query domain information from domains that administrators may believe are disallowed, including more sensitive domains or domains with weaker security, and perform attacks such as Kerberoasting or NTLM authentication coercion on those domains.
Hopping across further trusts outside of the forest (external or forest trusts) is not possible using this specific method. However, combined with the ability to create machine accounts across trusts, the researcher was able to reach the inaccessible dsptest.lab domain, so the limitation can be bypassed by creating a machine account across the trust, which the default configuration allows.
Fix
Microsoft did not fix the issue. The researcher states that the only way to avoid what is described is not to use external trusts at all. If external trusts cannot be removed, detection is possible.
The relevant Windows events are 4769s (A Kerberos service ticket was requested). The first indication is that a "local" TGT is requested from an account in a different forest.

Figure 44: 4769 For Local TGT
Here the Account Domain field is a domain that belongs to a different forest and the Service Name is krbtgt. This event is followed by another 4769 requesting a referral.

Figure 45: 4769 For Referral
Here the Account Domain is a domain within a different forest and the Service Name is another domain within the local forest. These two events can be on different DCs within the same domain; they do not have to reside on the same DC. Any service tickets requested (4769s) using this referral will have an Account Domain that contains a domain that should not be allowed to authenticate to the local domain. Plans to consume these events and detect this attack were planned for Directory Services Protector (DSP).
The researcher also highlights the importance of disallowing Authenticated Users from creating machine accounts. Not doing so puts domains within the forest at higher risk, and also puts any domains, and the whole forest within which they reside, that have an external trust with any domain within the forest at higher risk, because machine accounts can be created across trusts even while using this technique to authenticate against domains that should be disallowed.
Variants to test
- External trust into a multi-domain forest. From an account in a domain that has an external trust with a child domain, request a referral to the trusted child, then a "local" TGT for that child, then a referral to a sibling or root domain. A positive result is a referral for a domain other than the directly trusted one, followed by a successful ST request.
- Root domain service access. Use the referral chain to request an ST for a service on the forest root, such as host/SDC1.semperis.lab. A positive result is a valid ST for a domain that has no direct trust with the source domain.
- LDAP service ticket and machine account creation. Request an ST for ldap/ on a DC in the target domain and inject it to create a machine account. A positive result is a new machine account in the target domain, which can then be used to obtain a TGT and request referrals to further trusting domains.
- Cross-forest hop via machine account. Use the machine account TGT to request a referral to a domain that trusts the forest, then a "local" TGT for that domain, then a referral to a further domain. A positive result is a referral for a domain that was previously unreachable, as with dsptest.lab.
- Detection coverage. Check whether 4769 events show a Service Name of krbtgt with an Account Domain from a different forest, followed by a referral 4769 with a Service Name in the local forest. A positive result is both events being logged, possibly on different DCs.
What happened, in plain words
Imagine a large company made of several offices. Each office has its own front door, its own list of staff, and its own set of keys. Some offices trust each other: if you work in office A, the staff in office B will let you in, because the two offices signed a trust agreement. That is roughly how Microsoft Active Directory works. Active Directory (AD) is Microsoft's system for managing users, computers and permissions on a Windows network. A "domain" is one such managed area, for example semperis.lab. A "forest" is a group of domains that belong together and share the same overall structure.
When two domains in different forests want to let each other's users in, an administrator can create an "external trust". Microsoft describes an external trust as "non-transitive", which is supposed to mean: only the two domains that signed the agreement can let each other's users in, and nobody beyond them. The researcher in this write-up found that this is not true. A user in a domain that has an external trust with one domain inside a forest can reach other domains in that same forest, which the trust description says should be impossible.
The researcher reported this to Microsoft. Microsoft confirmed the behaviour but decided it does not affect security and were not planning on fixing it. The only way to avoid the problem, as the researcher puts it, is not to use external trusts at all.
This article walks through the whole thing slowly. It explains what each piece of the Windows login system does, why each step in the attack was taken, and what the screenshots show. You do not need any security background to follow it: if you can use a browser, you can follow the ideas here.
Trusts and transitivity
Before the attack, we need three ideas: domains, forests, and trusts.
- A domain is a collection of users, computers and rules managed together. Think of it as one office with one staff list.
- A forest is a group of domains that share the same overall directory. Think of it as a company that owns several offices. The top domain of the forest is called the forest root.
- A trust is an agreement between two domains that lets users from one log in to the other. Think of it as two offices agreeing to accept each other's staff badges at the door.
Trusts come in different types. The write-up mentions two:
- Forest trusts are agreements between two whole forests. They are transitive, which means trust spreads: a user from any domain in the trusted forest can log in to any domain in the trusting forest.
- External trusts are agreements between two specific domains. Microsoft describes them as non-transitive, which should mean that only users in the trusted domain can log in to only the trusting domain, and no further.

Figure 2 shows the intended picture of an external non-transitive trust: two domains, one arrow between them, and nothing beyond.
Microsoft's own documentation says this about transitivity:
Transitivity determines whether a trust can be extended outside of the two domains with which it was formed.
- A transitive trust can be used to extend trust relationships with other domains.
- A non-transitive trust can be used to deny trust relationships with other domains.
That wording is clear. For a non-transitive trust, only the two domains involved should be able to authenticate to each other, and not beyond. The researcher's point is that this is not what actually happens. The description is, in his words, at best misleading, and it leaves systems administrators with a false sense of security: they believe a boundary exists where none does.

Figure 1 shows Microsoft's response to the report. Microsoft did not consider the behaviour to affect security, so no fix was planned.
Lab setup
To show the problem, you need more than two domains. You need several forests, each with several domains, and external trusts between them. The researcher built a lab like this:

Figure 3 shows the whole lab. It involves three forests. Two of them contain three domains each, and the third contains two domains. Two external trusts connect them:
- The domains semperis.lab and treetest.lab have a bidirectional non-transitive external trust. "Bidirectional" means the trust works in both directions: users from either side can log in to the other.

Figure 4 shows this first external trust.
- The domains grandchild1.child1.semperis.lab and semperisaz.lab also have a bidirectional non-transitive external trust.

Figure 5 shows the second external trust.
Notice the naming. semperis.lab is a forest root. child1.semperis.lab is a domain inside that forest, and grandchild1.child1.semperis.lab is a domain inside child1.semperis.lab. The dots read like a path: grandchild, then child, then the root. This nesting matters, because the attack is about walking up and across that tree.
The tickets in the walkthrough are requested with a tool called Rubeus. Rubeus is a command-line program that talks to Active Directory's login service and asks for tickets. The authenticating user in the first part is lowpriv, an ordinary low-privilege account. The domain controllers involved include SGC1DC1.grandchild1.child1.semperis.lab, SC1DC1.child1.semperis.lab and SDC1.semperis.lab. A domain controller (DC) is the server in a domain that checks logins and hands out tickets.
How Kerberos cross-trust authentication works
Windows logins in AD use a protocol called Kerberos. Kerberos is a ticket system. Instead of sending your password to every server you use, you prove who you are once, and you receive a ticket. You then show that ticket to each service you want to use. Think of a theme park: you show your ID once at the gate, get a wristband, and then every ride checks the wristband rather than your ID.
The tickets have names:
- A TGT (Ticket Granting Ticket) is the first ticket you get after proving who you are. It is your wristband. It proves your identity to the ticket office.
- A service ticket (ST) is a ticket for one specific service, such as a file share or a database. You get it by showing your TGT to the ticket office and asking for it.
- A referral (or referral TGT) is a special ticket you get when the service you want lives in another domain. Your local ticket office cannot issue tickets for a foreign domain, so it gives you a referral: a ticket that says "go ask the ticket office over there".
A service principal name (SPN) is the name of a service in the ticket system. It looks like service/host, for example host/SC1DC1.child1.semperis.lab. The part before the slash is the kind of service, and the part after is the machine that runs it.
Two more terms appear in the tickets:
- The ServiceRealm (abbreviated srealm) is the domain that the ticket is meant for. It tells you which ticket office issued it and which domain will accept it.
- The krbtgt account is the special account that the ticket office itself uses. A ticket for
krbtgt/<domain>is a ticket for the ticket office of that domain, which is exactly what a referral is.
The walkthrough focuses on the semperis.lab forest, which is enough to show how ticket requests across trusts work. The same ideas apply to any trust path that is allowed.
The simplest case is a domain that has a direct trust with your local domain. The trust between grandchild1.child1.semperis.lab and child1.semperis.lab is an example. After you have your initial TGT, the first step to get a service ticket for a service in child1.semperis.lab is to ask for a referral for child1.semperis.lab:

Figure 6 shows that request. It was made to a DC (SGC1DC1.grandchild1.child1.semperis.lab) inside the domain that is local to the authenticating user (lowpriv), which is grandchild1.child1.semperis.lab. The request was for the service krbtgt/child1.semperis.lab. The resulting ticket has a ServiceRealm (srealm) of the local domain (grandchild1.child1.semperis.lab), and that is what marks it as a referral rather than a normal service ticket.

Figure 7 draws the same request as a diagram: your local ticket office hands you a note that the next ticket office will recognise.
With that referral in hand, you can now ask the foreign domain for service tickets:

Figure 8 shows an example of using the referral. A service ticket was requested from the foreign DC (SC1DC1.child1.semperis.lab) for the service host/SC1DC1.child1.semperis.lab, using the referral retrieved just before.

Figure 9 shows the same service ticket request in the tool's output.
Now take it one step further. Suppose you want a service on the forest root domain, semperis.lab. You cannot ask your local domain (grandchild1.child1.semperis.lab) for a referral to it directly:

Figure 10 shows a referral request for semperis.lab. A referral for krbtgt/semperis.lab was requested from the local DC sgc1dc1.grandchild1.child1.semperis.lab. But the ticket that came back was for the service krbtgt/child1.semperis.lab. That means the DC gave back a referral for child1.semperis.lab, not for semperis.lab. The local ticket office only knows about its direct neighbour, so it hands you a note for the neighbour instead of the root.

Figure 11 shows this referral request and its result.
You can prove the ticket is not for the root by trying to use it to request a service ticket for the semperis.lab domain:

Figure 12 shows the root domain service ticket request. It fails with an AP_ERR_BAD_INTEGRITY error. That error means the receiving server could not make sense of the ticket. The reason is that the referral ticket is encrypted with the trust key for the grandchild1.child1.semperis.lab --> child1.semperis.lab trust. The DCs in the root domain semperis.lab do not know that key, so they cannot decrypt the ticket. Think of a sealed envelope addressed to the wrong office: the office that receives it does not have the stamp that opens it.

Figure 13 shows the attempt to request a service ticket from semperis.lab and the failure.
To get a service ticket for the root domain semperis.lab, you first ask a DC in child1.semperis.lab for a referral to semperis.lab, using the referral you already have:

Figure 14 shows this referral request. The request went to the foreign DC (sc1dc1.child1.semperis.lab), using the referral for child1.semperis.lab, to ask for a further referral for the root domain semperis.lab. One detail matters here: the /targetdomain argument is required. By default Rubeus fills in the domain from the ticket you pass to it, which here would be grandchild1.child1.semperis.lab. That would produce an ERR_WRONG_REALM error, because the domain local to the DC you are talking to is child1.semperis.lab. In plain words: you have to tell the tool which domain you are actually asking about, or it will ask the wrong office for the wrong thing. This detail becomes important in the next section.

Figure 15 shows the referral request for semperis.lab succeeding.
Finally, the referral for semperis.lab can be used to request service tickets for the semperis.lab domain:

Figure 16 shows the service ticket request for semperis.lab.
This service ticket request from the user [redacted] to the DC SDC1.semperis.lab, for the SPN host/SDC1.semperis.lab, succeeded even though the two domains do not have a direct trust. It worked because the trust path is allowed: each hop is a trust that exists, and the chain of referrals carries you along it.

Figure 17 shows the service ticket request for host/sdc1.semperis.lab.
This method of asking for referrals to trusting domains can be repeated to get service tickets for any service in any domain whose trust path is allowed. That is the normal, intended behaviour. The next section shows what happens when the path should not be allowed.
Making the non-transitive transitive
Now the interesting part. As Figure 3 shows, the domains semperisaz.lab and grandchild1.child1.semperis.lab have a bidirectional external trust. That means that after getting a TGT for any account in semperisaz.lab, you can ask for a referral to grandchild1.child1.semperis.lab:

Figure 18 shows the referral to grandchild1.child1.semperis.lab.

Figure 19 draws this referral request as a diagram.
That referral lets you request service tickets for services in grandchild1.child1.semperis.lab. But if you try to get a referral to another domain in the same forest, for example child1.semperis.lab, you get an ERR_PATH_NOT_ACCEPTED error. That error is expected: the system is telling you the path is not allowed.

Figure 20 shows the path not accepted error.
The reason is that the semperisaz.lab --> granchild1.child1.semperis.lab trust is non-transitive, so the path from semperisaz.lab to child1.semperis.lab is not allowed. So far, the trust is behaving exactly as advertised.

Figure 21 shows the attempt to request a referral for child1.semperis.lab.
But there is a way around it. You can ask for a "local" TGT for grandchild1.child1.semperis.lab:

Figure 22 shows the request for a "local" TGT for grandchild1.child1.semperis.lab.
Why "local" in quotes? Because unlike the referral, which has a ServiceRealm (srealm) of semperisaz.lab, this ticket has a ServiceRealm of grandchild1.child1.semperis.lab. In other words, unlike the referral, its ServiceRealm is the trusted domain itself.

Figure 23 shows the "local" TGT request.
With this "local" TGT, you can now ask for a referral to child1.semperis.lab:

Figure 24 shows the referral for child1.semperis.lab.

Figure 25 draws the whole sequence: the "local" TGT is used to request the referral for child1.semperis.lab.
You now have a usable referral for child1.semperis.lab, obtained with any account from semperisaz.lab, and without making any changes to trusts or accounts in AD. Nothing was modified. The trust was simply used in a way its description says should not work.

Figure 26 shows a service ticket request for a DC in child1.semperis.lab.
In Figure 26, a service ticket was requested from the DC sc1dc1.child1.semperis.lab for the service host/sc1dc1.child1.semperis.lab, as the user [redacted].

Figure 27 shows the service ticket request for host/sc1dc1.child1.semperis.lab.
The same method can be used to hop around any domain in the same forest that grandchild1.child1.sermperis.lab belongs to. To demonstrate, request a referral to the root domain semperis.lab:

Figure 28 shows the request for a referral to semperis.lab.
A referral was requested for semperis.lab from the DC sc1dc1.child1.semperis.lab, as the user [redacted].

Figure 29 shows the referral to semperis.lab.
Fortunately for security, hopping across further trusts outside the forest (external or forest trusts) is not possible with this method. The root domain semperis.lab has a bidirectional external trust with treetest.lab, and that trust can be used to show the limitation:

Figure 30 shows the request for a referral to treetest.lab.
This at least stops an attacker using this method of trust hopping from hopping into another forest.

Figure 31 shows the same referral request for treetest.lab.
So the technique lets you move freely inside one forest, but not out of it. That is still serious: it lets an attacker query domain information from domains that administrators may believe are disallowed, including more sensitive domains or domains with weaker security. It also makes attacks such as Kerberoasting or NTLM authentication coercion possible on those domains. Kerberoasting is a technique for requesting service tickets and cracking the passwords behind them offline. NTLM authentication coercion is a way of making a machine authenticate to an attacker-controlled server so its credentials can be captured. Both become possible on domains that were supposed to be out of reach.
Hopping further
This specific method cannot cross into another forest. But the researcher had previously written about creating machine accounts across trusts, and this situation is another example of that.
A machine account is an account that represents a computer rather than a person. By default, ordinary authenticated users are allowed to create machine accounts in AD. That default is what makes the next step possible.
Using the referral retrieved for semperis.lab, you can request a ticket for the LDAP service on a DC in semperis.lab. LDAP is the protocol used to read and write the directory: users, groups, computers and so on. A ticket for LDAP on a DC is effectively permission to talk to the directory of that domain.

Figure 32 shows the service ticket request for LDAP.
Here a service ticket for ldap/sdc1.semperis.lab was requested using the referral for semperis.lab, as the user [redacted].

Figure 33 shows the service ticket for ldap/sdc1.semperis.lab.
That service ticket can be injected into a session and used to create a machine account directly in semperis.lab, provided the configuration allows Authenticated Users, which is the default:

Figure 34 shows the creation of a machine account in semperis.lab.
This causes the DC sdc1.semperis.lab to create the machine account TestComp in the semperis.lab domain:

Figure 35 shows the creation of the TestComp machine account.
The new TestComp machine account is a local account in semperis.lab. Now that there is a machine account that exists in semperis.lab, you can retrieve a TGT for it:

Figure 36 shows the machine account TGT.
Requesting the machine account TGT looks like this:

Figure 37 shows the request for a TGT for TestComp.
This machine account TGT is allowed to request a referral to the trusting domain treetest.lab:

Figure 38 shows the request for a referral to treetest.lab.
Here the machine account's TGT was used to request a referral for the treetest.lab domain from the DC SDC1.semperis.lab.

Figure 39 shows the referral request for treetest.lab.
Finally, the issue described in this post can be used again to reach the inaccessible dsptest.lab domain. First, request a "local" TGT for treetest.lab:

Figure 40 shows the request for a local TGT for treetest.lab.
The "local" TGT is requested using the referral for treetest.lab, as the account [email protected], from the DC TDC1.treetest.lab. The dollar sign at the end of TestComp$ is how AD marks a machine account.

Figure 41 shows the "local" TGT request for treetest.lab.
Then use this "local" TGT to request a referral for dsptest.lab:

Figure 42 shows the request for a referral to dsptest.lab.
Here a referral was requested for the domain dsptest.lab from the DC TDC1.treetest.lab, as the user [email protected].

Figure 43 shows the referral request for dsptest.lab.
Combining these two methods makes it possible to hop very deep into AD enterprise infrastructures, using any low-privilege account on a domain that has an external trust to any domain in a forest. The first method gets you into the forest; the machine account trick then lets the same issue be used again to reach dsptest.lab.
Detection
Microsoft did not fix the issue. The researcher's position is that the only way to avoid what is described is not to use external trusts at all. If external trusts cannot be removed, detection is possible.
The relevant Windows events are 4769s, which are logged when a Kerberos service ticket is requested. The first sign is a "local" TGT being requested from an account in a different forest:

Figure 44 shows a 4769 event for a local TGT. In it, the Account Domain field is a domain that belongs to a different forest, and the Service Name is krbtgt. In plain words: a user from outside the forest asked for a ticket for the local ticket office itself, which is not normal.
That event is followed by another 4769 requesting a referral:

Figure 45 shows a 4769 event for a referral. Here the Account Domain is a domain in a different forest, and the Service Name is another domain in the local forest. In plain words: the same outside user then asked to be passed along to a neighbouring domain.
These two events can be on different DCs in the same domain; they do not have to be on the same DC. After that, any service tickets requested (4769s) using this referral will have an Account Domain that contains a domain that should not be allowed to authenticate to the local domain. Plans to consume these events and detect this attack were planned for Directory Services Protector (DSP).
The researcher also stresses the importance of disallowing Authenticated Users from creating machine accounts. Leaving that default in place puts domains in the forest at higher risk, and also puts any domain, and the whole forest it lives in, that has an external trust with any domain in the forest at higher risk. That is because machine accounts can be created across trusts, even while using this technique to authenticate against domains that should be disallowed.
Conclusion
The biggest problem is Microsoft's description of non-transitive trusts, which is at best misleading to systems administrators. The problem is made worse by Microsoft's refusal to accept that it affects security. As things stand, by creating an external "non-transitive" trust, a company must accept that any account in the trusted domain can authenticate against any domain in the whole forest where the trusting domain lives.
The "Hopping further" section shows why it matters that Authenticated Users can create machine accounts by default. Not changing that default puts domains in the forest at higher risk, and also puts any domain, and the whole forest it lives in, that has an external trust with any domain in the forest at higher risk. More on the machine account quota and how to prevent low-privilege machine account creation can be found in Kevin Robertson's post "MachineAccountQuota is USEFUL Sometimes".
If nothing else, the post is meant to inform systems administrators of the real forest-wide risk of external trusts. After all, how can administrators be expected to secure their environments properly while believing authentication is impossible where it actually is?
Timeline
- 2022/05/04: MSRC case created.
- 2022/05/12: Case status changed to "Review/Repro".
- 2022/06/17: Case status changed to "Develop", with an email stating "We confirmed the behaviour you reported. We'll continue our investigation and determine how to address this issue."
- 2022/06/17: Case status changed to "Complete - Resolved".
- 2022/08/24: Comment left on the case to find out the status.
- 2022/09/02: A follow-up comment left on the case to find out the status.
- 2022/09/14: A follow-up email sent to find out the status of the case.
- 2022/09/29: Email received explaining the issue was not determined to affect security.
- 2023/03/14: Public disclosure, blog post released.
Acknowledgements
- Will Schroeder, for creating Rubeus, without which this research very well may not have been done.
- Everyone who reviewed the post and provided feedback, including Elad Shamir, Harjinder Nijjar, Andrew Schwartz and Jonny Johnson.
Glossary
- Active Directory (AD): Microsoft's directory service for Windows networks. It stores users, computers, groups and permissions, and decides who can do what.
- Domain: one managed area inside AD, with its own users, computers and domain controllers, for example
semperis.lab. - Forest: a group of AD domains that share the same overall directory. The top domain is the forest root.
- Forest root: the top-level domain of a forest, for example
semperis.lab. - Trust: an agreement between two domains or forests that lets users from one authenticate to the other.
- Transitive trust: a trust that extends beyond the two parties, so users from other trusted domains can also authenticate.
- Non-transitive trust: a trust that is supposed to apply only to the two domains involved and not beyond.
- External trust: a trust between two specific domains in different forests, described by Microsoft as non-transitive.
- Forest trust: a trust between two whole forests, transitive in nature.
- Bidirectional trust: a trust that works in both directions, so users on either side can authenticate to the other.
- Domain controller (DC): the server in a domain that checks logins and issues Kerberos tickets.
- Kerberos: the authentication protocol used by AD. You prove your identity once and receive tickets that you show to services.
- TGT (Ticket Granting Ticket): the first ticket you get after proving your identity. It is used to ask for other tickets.
- Service ticket (ST): a ticket for one specific service, obtained by presenting a TGT.
- Referral (referral TGT): a ticket that points you to the ticket office of another domain, used when the service you want lives elsewhere.
- Service principal name (SPN): the name of a service in the ticket system, written as
service/host, for examplehost/SC1DC1.child1.semperis.lab. - ServiceRealm (srealm): the domain a ticket is meant for. It shows which domain issued the ticket and which domain will accept it.
- krbtgt: the special account that the ticket office of a domain uses. A ticket for
krbtgt/<domain>is a ticket for that domain's ticket office, which is what a referral is. - "Local" TGT: in this post, a TGT whose ServiceRealm is the trusted domain itself, so the domain's DCs treat it as a local ticket rather than a visitor's.
- Rubeus: a command-line tool for requesting and manipulating Kerberos tickets.
- LDAP: the protocol used to read and write the AD directory, such as users, groups and computers.
- Machine account: an AD account that represents a computer rather than a person. Its name ends with a dollar sign, for example
TestComp$. - Authenticated Users: a default AD group containing all logged-in users. By default it is allowed to create machine accounts.
- AP_ERR_BAD_INTEGRITY: a Kerberos error meaning the receiving server could not decrypt or validate the ticket, often because it does not hold the key the ticket was encrypted with.
- ERR_WRONG_REALM: a Kerberos error meaning the request named the wrong domain for the DC being asked.
- ERR_PATH_NOT_ACCEPTED: a Kerberos error meaning the trust path between the domains is not allowed.
- 4769 event: a Windows security event logged when a Kerberos service ticket is requested. Useful for spotting unusual ticket activity.
- Kerberoasting: an attack that requests service tickets and cracks the passwords behind them offline.
- NTLM authentication coercion: a technique that makes a machine authenticate to an attacker-controlled server so its credentials can be captured.
- Directory Services Protector (DSP): a Semperis product for monitoring and protecting AD; the post says plans existed to consume these events and detect the attack in an upcoming release.