> For the complete documentation index, see [llms.txt](https://otter.gitbook.io/red-teaming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://otter.gitbook.io/red-teaming/notes/forest-trust-abuse/foreign-acl-principals.md).

# Foreign ACL Principals

Foreign ACL Pricipals are users or groups in the child domain that have rights over ACLs (GenericAll, WriteDacl and so on) in the parent domain.

To enumerate these users we can use PowerView, BloodHound or any other ACL visualization tool.

{% code overflow="wrap" fullWidth="false" %}

```powershell
Import-Module .\PowerView.ps1
$sid = Convert-NameToSid otter
Get-DomainObjectAcl -ResolveGUIDs -Identity * -domain domain.com | ? {$_.SecurityIdentifier -eq $sid}

AceType               : AccessAllowed
ObjectDN              : CN=SomeGroup,CN=Users,DC=DOMAIN,DC=COM
ActiveDirectoryRights : GenericAll
OpaqueLength          : 0
ObjectSID             : S-1-5-21-2879935145-656083549-3766571964-2110
InheritanceFlags      : None
BinaryLength          : 36
IsInherited           : False
IsCallback            : False
PropagationFlags      : None
SecurityIdentifier    : S-1-5-21-2901893446-2198612369-2488268719-2103
AccessMask            : 983551
AuditFlags            : None
AceFlags              : None
AceQualifier          : AccessAllowed  
```

{% endcode %}

This dummy output shows how the `otter` user has `GenericAll` over the `SomeGroup` group in the parent domain. From this position we could, for example, add `otter` to `SomeGroup` and abuse the permissions of that group to move further in the domain.

The following is a snipped of PowerShell code that can enumerate all foreign ACL rights from a child domain to a parent one.

```powershell
$Domain = "domain.com"
$DomainSid = Get-DomainSid $Domain

Get-DomainObjectAcl -Domain $Domain -ResolveGUIDs -Identity * | Where-Object { 
    ($_.ActiveDirectoryRights -match 'WriteProperty|GenericAll|GenericWrite|WriteDacl|WriteOwner') -and `
    ($_.AceType -match 'AccessAllowed') -and `
    ($_.SecurityIdentifier -match '^S-1-5-.*-[1-9]\d{3,}$') -and `
    ($_.SecurityIdentifier -notmatch $DomainSid)
} | ForEach-Object {
    $convertedSid = ConvertFrom-Sid $_.SecurityIdentifier
    Write-Host "User: $convertedSid"
    $_
}
```

Now we can run it with

```powershell
Import-Module .\PowerView.ps1
.\getAllForeignAcls.ps1
```

and look for interesting permissions to abuse.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://otter.gitbook.io/red-teaming/notes/forest-trust-abuse/foreign-acl-principals.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
