Properly escape shell commands

Bug #238165 reported by TAC one
254
Affects Status Importance Assigned to Milestone
Remote Apache Management tool
Fix Released
High
TAC one

Bug Description

Bash commands are not properly escaped. This could (and will) lead to problems with filesystem paths containing spaces as well as big security holes that could lead in bash code injection (and mind - we run a lot of commands with root privileges).

How to get better:
 - review code and properly escape bash commands [1]
 - blacklist certain characters we don't plan to support in filesystem paths (double quotes - " - for example)
 - centralize bash commands execution into a specific class/pypackage to improve security mantainability
 - review code and make sure there are no unescaped user input sources anymore.

[1] From #python
(07:00:05 PM) rgl: is there some function that escapes shell arguments? (nb: I don't want to use the exec* functions, I want to run remote commands)
(07:00:27 PM) tacone: rgl: I am interested to know that too .-)
(07:00:46 PM) Yhg1s: rgl: commands.mkarg is the closest.
(07:00:57 PM) Yhg1s: but it really depends on this remote shell.
(07:01:06 PM) Yhg1s: since that defines how something should be escaped.
(07:01:16 PM) rgl: tacone, I already made one, but it only works for bash/sh. it only translates ' => '\''

Tags: need-help
Revision history for this message
KillerKiwi (killerkiwi2005) wrote :
Revision history for this message
TAC one (tacone) wrote :

(11:40:33 PM) KillerKiwi2005: subprocess.call(["gksudo", "/bin/stupid command $%^$%^$ here"])

Revision history for this message
KillerKiwi (killerkiwi2005) wrote :

even better if you need it

subprocess.list2cmdline(["ls","/opt/wi$$!rd path's should be avoided/bin"])

TAC one (tacone)
Changed in rapache:
importance: Undecided → High
milestone: none → stage0
status: New → Triaged
Revision history for this message
TAC one (tacone) wrote :

See also related entries:
- https://bugs.launchpad.net/bugs/237180 (error level reading)
- https://bugs.launchpad.net/bugs/237177 (gksudo cancelled by the user)

Revision history for this message
TAC one (tacone) wrote :

CommandHandler implemented. Now every command is escaped !
We have to figure out how to open a process in background (ie: nautilus)

Changed in rapache:
assignee: nobody → tacone
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.