agentejo / cockpit

Add content management functionality to any site - plug & play / headless / api-first CMS
http://getcockpit.com
MIT License
5.4k stars 524 forks source link

RCE via Read Collections Function #1468

Open serWazito0 opened 3 years ago

serWazito0 commented 3 years ago

Hi Cockpit Team,

I found that i Can Execute get RCE via php code injection at read rules. This attack can be executed with authentication and without authentication

Steps [auth]

  1. Go to dashboard then Click on Create Collection

    Screen Shot 2021-09-10 at 7 45 50 AM
  2. enter any dummy data

  3. at the permission part enable the read rule and modify it with the php payload.

    Screen Shot 2021-09-10 at 7 48 32 AM
  4. Go to the Collections

    Screen Shot 2021-09-10 at 7 50 48 AM
  5. Click On the Created Collection

    Screen Shot 2021-09-10 at 7 52 23 AM
  6. pass a value to the missing parameter

Screen Shot 2021-09-10 at 7 53 57 AM

Note That the file Created At storage/collections/rules

Screen Shot 2021-09-10 at 7 54 30 AM

[without auth] You Can Access it without authentication at /storage/collections/rules/RCE.read.php?cmd=id

Screen Shot 2021-09-10 at 7 58 49 AM
aheinze commented 3 years ago

Yes, you can write php code, and this should only be done by admins. You should only give admins the right to create|edit collections.I'll try to find a solution for the direct un-authenticated access

serWazito0 commented 3 years ago

BTW how can u let the admin execute a PHP code !! if I add this CMS to my website then I gave an admin access to someone he can easily access my server, files, etc.... !!

aheinze commented 3 years ago

Why would you give someone admin rights whom you don't trust? he can also delete your account then and take over the cms etc. Just don't give anyone admin rights 🤷‍♂️

serWazito0 commented 3 years ago

I'm not talking as my side it's an example. Sometimes The Website owner doesn't change the default Credentials for the CMS, so if the attacker tries it he will log in as admin then execute the PHP code. 🤷‍♂️🤷‍♂️

serWazito0 commented 3 years ago

Can u just explain to me why u allow the admin to execute PHP code?

aheinze commented 3 years ago

This meant for configuring complex content access rules (see comment: https://github.com/agentejo/cockpit/issues/675#issuecomment-367120881)