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

Update security.md #697

Closed
wants to merge 1 commit into from
Closed

Update security.md #697

wants to merge 1 commit into from

Conversation

ahartma1
Copy link

@ahartma1 ahartma1 commented Jul 8, 2019

Arbitrary commands don't need to be embedded in terraform. One can run any command or set of commands from inside a terraform variable using the notation I show in my example. The Atlantis user itself should only be able run a small set of commands. I would suggest the permissions be limited to running terraform, reading and writing only to the data-dir, and only when the source is the git repository, and the other pieces of code used to interact with the Pull Request. I don't know how you would build this into the Altantis application, but if you would like, I can come up with an sh script to limit what I think are major vulnerabilities.

Arbitrary commands don't need to be embedded in terraform. One can run any command or set of commands from inside a terraform variable using the notation I show in my example. The Atlantis user itself should only be able run a small set of commands. I would suggest the permissions be limited to running terraform, reading and writing only to the data-dir, and only when the source is the git repository, and the other pieces of code used to interact with the Pull Request.
@codecov
Copy link

codecov bot commented Jul 8, 2019

Codecov Report

Merging #697 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #697   +/-   ##
=======================================
  Coverage   72.37%   72.37%           
=======================================
  Files          61       61           
  Lines        4658     4658           
=======================================
  Hits         3371     3371           
  Misses       1037     1037           
  Partials      250      250

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 595e1d4...891693f. Read the comment docs.

@lkysow
Copy link
Member

lkysow commented Jul 9, 2019

This wasn't intentional. We need to close this. Maybe we can limit comment args to safe characters.

Thanks for reporting this though. In the future please report future security issues to security [at] runatlantis.io (see https://github.com/runatlantis/atlantis/blob/master/CONTRIBUTING.md#reporting-security-issues)

@ahartma1
Copy link
Author

ahartma1 commented Jul 9, 2019

Ok as long as you are aware of the issue. I'm not sure this can be avoided by limiting to just safe characters. I could in theory inject( aws destroy whatever ) and do some pretty bad damage as well.

@ahartma1 ahartma1 closed this Jul 9, 2019
lkysow added a commit that referenced this pull request Jul 11, 2019
lkysow added a commit that referenced this pull request Jul 11, 2019
lkysow added a commit that referenced this pull request Jul 11, 2019
lkysow added a commit that referenced this pull request Jul 11, 2019
Remove extra quoting and instead add a backslach to each character in
the extra args before appending it to the command.
ex. atlantis plan -- -var key=val will result in:
  sh -c "atlantis plan \-\v\a\r \k\e\y\=\v\a\l"
Fixes #697.
lkysow added a commit that referenced this pull request Jul 11, 2019
Remove extra quoting and instead add a backslach to each character in
the extra args before appending it to the command.
ex. atlantis plan -- -var key=val will result in:
  sh -c "atlantis plan \-\v\a\r \k\e\y\=\v\a\l"
Fixes #697.
@lkysow
Copy link
Member

lkysow commented Jul 11, 2019

@ahartma1 what do you think about my fix in #699? I'm escaping every character in the extra args:
atlantis plan -- -var key=val => sh -c "atlantis plan \-\v\a\r \k\e\y\=\v\a\l"

@ahartma1
Copy link
Author

I think it fixes the issue of command injection. Some people might see it as losing functionality though. I know when I was provisioning Vault using terraform, I'd have to seed a System env var to later echo, or cat a file on the system, within the -var in order to get an LDAP password or something that I didn't want in code or shown in the merge request. Maybe a way around this is to simply point users with such a need to running custom commands via atlantis.yaml. Another option that would preserve the ability to use variables would by to escape everything except the $

@lkysow
Copy link
Member

lkysow commented Jul 11, 2019

Yeah I think closing the hole is a priority and then if folks like you have a special need for it then we can add in a workaround or encourage people to use the atlantis.yaml

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

Successfully merging this pull request may close these issues.

2 participants