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

"IP address" parameter type #136

Closed
CyrilKuzmin opened this issue Oct 24, 2018 · 8 comments
Closed

"IP address" parameter type #136

CyrilKuzmin opened this issue Oct 24, 2018 · 8 comments

Comments

@CyrilKuzmin
Copy link

Hi guys,

the app is really wonderful! ..And I have 1,5 questions:
1/ Did someone faced with the necessity to verify if entered parameter is valid IPv4/IPv6 address? :)
I'm checking it by the separate py script, but I think it's worthy to be a parameter type...
1.5/ What is the best way to exclude the possibility of using "&&" operator? for example: "some_thing && kill -9 $(pgrep -f python)"

Thank you!

@bugy
Copy link
Owner

bugy commented Oct 24, 2018

Hi @xxlaefxx,

IP address type makes sense and a nice idea, thanks! I'll add it

Regarding && operator (and any other bash operators): script server protects from it, a bit more details here: Shell commands injection. It will always be passed as a positional argument to your script and not executed on its own (even if you put it in script_path)

@bugy bugy added the feature label Oct 24, 2018
@CyrilKuzmin
Copy link
Author

1/ Thank you in advance for IP addresses and this quick response! :)

1.5/ Yes, I read it and added double quotes (everywhere), but I got something like that in the beginning:

> 2018-10-24 23:47:12,425 [script_server.execution_service.INFO] Calling script #52: /opt/script-server/scripts/SimpleScript.sh -ip 192.168.1.19 && wall "I pwned myself"
> 2018-10-24 23:47:12,437 [tornado.access.INFO] 200 POST /scripts/execution (192.168.1.19) 62.43ms
> 2018-10-24 23:47:12,453 [tornado.access.INFO] 101 GET /scripts/execution/io/52 (192.168.1.19) 1.12ms
> 
> Broadcast message from nosudo@centostst3 (Wed Oct 24 23:47:14 2018):
> 
> I pwned myself
> 2018-10-24 23:47:15,073 [web_server.INFO] 192.168.1.19 disconnected
> 2018-10-24 23:47:15,076 [tornado.access.INFO] 200 POST /scripts/execution/cleanup/52 (192.168.1.19) 1.46ms

conf/runner/SimpleScript.json

  "parameters": [
    {
      "name": "IP address",
      "param": "-ip",
      "description": "Please enter a valid IP address"
    }
  ]

@bugy
Copy link
Owner

bugy commented Oct 25, 2018

Hi @xxlaefxx,

I don't know how you parse and use incoming arguments, I tried to reproduce it locally and I couldn't. The test script I was using (it's without -ip, just a positional argument):

#!/bin/bash

param_unsafe=$1
param="$1"

ping -c 1 "$1"
ping -c 1 "$param_unsafe"
ping -c 1 "$param"
ping -c 1 $param

All pings and parameters initializations worked fine, without processing &&.
Only the last ping failed, but it tried to ping the part after && for some reasons

@CyrilKuzmin
Copy link
Author

CyrilKuzmin commented Oct 26, 2018

Ok, the reason was CentOS 6 and "latest" python34 installed.
It works perfect with the latest python 3.7 on all another servers :)

Spasibo!

@bugy
Copy link
Owner

bugy commented Oct 26, 2018

Hi @xxlaefxx , thank you for getting back.
Could you still share the code (obfuscated if needed), how you work with parameters inside your script? Script server shouldn't allow such injections even on older distributions. If it does, then it's a critical issue.

@CyrilKuzmin
Copy link
Author

Hi, @bugy
Sorry, but I've already upgraded my test env and modified all my test scripts... I'll try to restore and reproduce it later and let you know.
Previously it was something like:

#!/bin/bash
#my functions
key="$1"
case $key in
    -ip)
    IP="$2"
    ;;
    -hostname)
    IP=NslookupFunction("$2")
    ;;
    *)
    echo "unknown option"
    ;;
esac
MainFunction($IP)

@bugy
Copy link
Owner

bugy commented Oct 26, 2018

Hi @xxlaefxx, thank you!

@bugy
Copy link
Owner

bugy commented Dec 28, 2018

Added new parameter types:

  • ip - IPv4 or IPv6
  • ip4 - IPv4
  • ip6 - IPv6

Validation is done on server and client side.

The dev build is available at https://github.com/bugy/script-server/releases/download/dev/script-server.zip

@bugy bugy closed this as completed Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants