Skip to content

Instantly share code, notes, and snippets.

@n2dez
Created January 14, 2022 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n2dez/05d43c616f2b403e84ee55d4d7aab251 to your computer and use it in GitHub Desktop.
Save n2dez/05d43c616f2b403e84ee55d4d7aab251 to your computer and use it in GitHub Desktop.

Privilege Escalation via Improper Quoting Path Vulnerability

The Rapid7 Insight Agent v3.1.2.38 and earlier is not properly double-quoting with its use of runas, which allows a local adversary to execute code with system privileges.

Severity

7.8 HIGH

Analysis

  1. Windows 10 with Insight Agent installed and 'Honey Credentials' enabled under 'Deception Technology' within InsightIDR

deception-cred-enabled

  1. After a reboot, utilizing procmon boot-logging, we can see the call for 'Program.exe' via commandline utilizing Windows 'runas' only single-quoted
runas /user:patchadmin /netonly /env "C:\Program Files\Rapid7\Insight Agent\components\insight_agent\3.1.2.38\honeyhashx86.exe"

procmon-path-traversal

  1. The stack trace for this call can be seen here

stack

  1. Along with process tree outlining it's running with SYSTEM privileges

process-tree

Exploit

This can be exploited by creating the file 'c:\Program.exe' which would then be picked up by 'ir_agent.exe' invoked call to 'runas'. This would be called after every reboot.

Improper quoting allows for external modules to be called instead of intended module due to spaces within the path. This call is done with SYSTEM level privileges and attacker module would obtain this privilege when called. One can not assume all paths have been secured outside of application controlled directory.

More information on the topic:

Fix

Windows runas when used with spaces in the path needs to be double-quoted.

runas /user:patchadmin /netonly /env "\"C:\Program Files\Rapid7\Insight Agent\components\insight_agent\3.1.2.38\honeyhashx86.exe\""

Timeline

20220114 - initial disclosure to Rapid7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment