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

[Security] Remote command execution #12

Open
edoardottt opened this issue Sep 22, 2022 · 6 comments
Open

[Security] Remote command execution #12

edoardottt opened this issue Sep 22, 2022 · 6 comments

Comments

@edoardottt
Copy link

Using the API /api/common/ping it's possible to achieve remote command execution on the host machine. This leads to complete control over the machine hosting the server.

To reproduce the vulnerability:

  • Download the repo
  • Execute node index.js
  • Login
  • Execute this request as shown below:

Screenshot from 2022-09-21 21-42-33

HTTP request:

POST /api/common/ping HTTP/1.1
Host: 0.0.0.0:8000
User-Agent: bla-bla-bla
Cookie: your-auth-cookie
Content-Length: 15

host=1.1.1.1;id

This is the vulnerable code:

	schema.addWorkflow('ping', function($) {
		var host = $.model.host.replace(/'|"|\n/g, '');
		Exec('ping -c 3 {0}'.format(host), $.done(true));
	});

Here the problem is the fact that the server doesn't sanitize correctly the input checking that the host provided is a legitimate one, allowing also characters like ;, | or &.

@petersirka
Copy link
Collaborator

With the code you can edit everything or you can run bash scripts directly. But I agree, this must be sanitised. I'll fix it.

@edoardottt
Copy link
Author

Awesome. Someone could disable functionalities, but that api isn't intended to provide rce.

Thanks @petersirka

Will-create added a commit to Will-create/code-editor that referenced this issue Sep 26, 2022
@petersirka petersirka reopened this Dec 7, 2023
@petersirka
Copy link
Collaborator

@Will-create can you look at this again? #20

@edoardottt
Copy link
Author

edoardottt commented Dec 7, 2023

if that field should accept only IPs, why not using a specific regex only for IPs?

@petersirka
Copy link
Collaborator

if that field should accept only IPs, why not using a specific regex only for IPs?

The domain name and IP address can be pinged. It is therefore impossible to have an IP validator alone.

@edoardottt
Copy link
Author

Got it. In general an allow-list is preferred over a block-list of entries. In this case the regex must check that only the allowed characters are entered: alphabetic characters (A-Z), numeric characters (0-9), the minus sign (-), and the period (.)

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

2 participants