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 risk (?): Backticks in descriptions are attempted to eval! #91

Open
Enrico2 opened this issue Mar 30, 2020 · 3 comments
Open

Comments

@Enrico2
Copy link

Enrico2 commented Mar 30, 2020

We had a description defined like this with backticks:

description = "Runs dbmigrator --migrate on database started by `run-db-local` (eg via `:db:local:run`)."

Then in bash, I did

gradle :db:migrations[tab]

and saw:

$ gradle :db:migrations:-bash: run-db-local: command not found
-bash: :db:local:run: command not found
-bash: run-db-local: command not found
-bash: :db:local:run: command not found

Seems like this could be some attack vector, where a description could contain some malicious bash command.

@mikesamuel
Copy link

Could the problem be here?

if [[ -z "$cur" ]]; then
cached_tasks=( $(grep -v "^:" "$cache_dir/$cached_checksum") )
else
cached_tasks=( $(grep "^$cur" "$cache_dir/$cached_checksum") )
fi

IIUC that filters text like

assemble  - Assembles the outputs of this project.
bar:assemble  - Assembles the outputs of this project.
:bar:assemble  - Assembles the outputs of this project.
foo:assemble  - Assembles the outputs of this project.
:foo:assemble  - Assembles the outputs of this project

by prefix. Since it does

$( grep ... )

instead of

"$( grep ... )"

expansion may evaluate shell meta-characters.

@mikesamuel
Copy link

My bash is kind of weak right now though.

@apflieger
Copy link

Ahhh I see these things in my prompt for month now and I finally figured out this.
The gradle plugin for building IntelliJ plugin have multiple tasks that includes backticks so I get this

./gradlew -bash: robot-server: command not found
-bash: robot-server: command not found
-bash: plugin.xml: command not found
-bash: plugin.xml: command not found
-bash: plugin.xml: command not found
-bash: plugin.xml: command not found

It comes from the following tasks descriptions

downloadRobotServerPlugin - Download robot-server plugin.

and

patchPluginXml - Patches plugin.xml files with values provided to the task.

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