Repository navigation
Closed
Description
(This issue's a WIP; just want to log this somewhere.)
I'd like to document Concourse's usage in running untrusted code, e.g. via pull requests. There's a pretty neat Pull Request resource already, but I can't in good conscience recommend using it until we have answers for the following attack vectors (some of which we already do).
In no particular order:
- DOS the host machine, forcing it to reboot (e.g.
echo b > /proc/sysrq-trigger). - Consume crazy amounts of memory/disk/bandwidth/etc. for extended periods of time.
- Reach arbitrary sensitive information within the worker's private or local network.
- Reach sensitive data on the worker's disk.
- Access pipeline credentials.
- Escalate task capabilities beyond normal.
- Affect (by killing) other processes running on the worker.
And here's how Concourse currently fares:
- OK. This should be safe as long as the containers don't run privileged. Of course, barring any kernel bugs or CVEs come out. We're talking fundamentals here.
- Not OK, but maybe not critical. We currently don't apply any memory, disk, or bandwidth limits on any containers. I don't want to force people to think about it, and having even optional configuration for this is dangerous (people will just forget to set it). I'm not sure if people expect this; maybe we should investigate what kind of limits Travis enforces?
- CRITICAL. By default, containers have unlimited access to the host machine's private network. Each worker currently binds on their external IP via TCP, so if the attacker can guess your worker IPs, they can reach your Garden servers and do bad things. This is fixable by setting network restrictions on the worker (
--allowNetworks,--denyNetworksflags), but it may be a better idea to just have auth in front of Garden. - OK, again barring CVEs. This one's pretty basic and is part of the point of running everything in containers.
- OK, as long as resources don't leak their credentials or something.
- OK;
privilegedlives in the pipeline config, not the task config, for this very reason. - OK aside from points 3 (kill containers via Garden API) and 2 (OOM/other resources). The rest is basic containerization (PID namespaces).
Any others?
Reacted by Marco Molteni
Activity
concourse-bot commentedon Apr 11, 2016
Hi there!
We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.
The current status is as follows:
This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.
bump a *bunch* of dependencies
stela commentedon Jun 6, 2018
@vito
5. is NOT OK, some resources do leak credentials, it's very easy to dump all your team's credentials, e.g. for deployment to production or git, even if the credentials are stored on CredHub or Vault. So far I found two paths to achieve this.
A. If a developer has access to Concourse, the developer can set a new pipeline like:
B. If a developer can commit a "child" build.yml pipeline to version control and have Concourse execute it:
main-pipeline.yaml
build.yml:
This is a shame, as Concourse is so close to getting this right, running resource types like git and cf out-of-reach from the main source code build, and only exposing explicitly passed ((variables)).
B could be resolved by disabling variable-expansion in child-build.yml files, either completely or by flagging "developer-safe" variables in the main-pipeline.
A could be resolved by either having fine-grained authorization of whom is permitted to execute set-pipeline, or better, I believe, by only permitting variable-expansion for trusted non-leaky resource types like git (I think?) but disable it for developer-controlled types like docker-image. However even deployment-resources like e.g. cf (Cloud Foundry) could be sensitive if the developer reroutes logins to a developer-controlled URL, the raw original password is sent (i.e. e.g. PAKE is not used).
vito commentedon Jun 6, 2018
@stela This issue is primarily concerned with "B". You bring up a good point. We should maybe just disallow variable expansion, or only allow it during
fly execute. It'll make some people sad since they use it forimage_resourcecredentials. But security comes first.I think RBAC is the solution to "A" - I really don't want to get into preferential treatment of resource types. There's really nothing about
gitthat should make it any safer thandocker-image, especially in light of CVEs. If someone can "set-pipeline" that's pretty much the keys to the kingdom. We're working on RBAC so you can control who can and can't - see #1317 and its precursor issue, #1888 (along with theepic/userslabel in general).stela commentedon Jun 6, 2018
@vito thanks, disallowing variable expansion would probably be enough to make it secure against arbitrary developer commits. What you could get away with though for
image_resourcecredentials and such, would be to somehow set those credentials declaratively by naming convention, e.g. if there's a vault/credhub key namedteamname/pipelinename/docker_image/docker-registry-hostname/passwordor similar, it would automatically be assigned as a docker password value to matching docker-image resources?Or allow defining named docker repositories in the main pipeline.yml and then only allow the build.yml to refer to them and provide repository and tag values?
vito commentedon Jun 6, 2018
@stela I like the conventional paths approach but it might be a bit constraining; we've already received feedback from users that want to be able to break from Concourse's enforced convention and use their own paths and fine-grained Vault permissions/etc.
One thing people can do without any task interpolation is use a pipeline-provided resource:
...which people could do forever, but they seemed dissatisfied. Hmm.
dstufft commentedon Jul 5, 2018
If a deployment is only concerned about people committing things (particularly in untrusted pull requests), then "B" above is the only case we care about right?
vito commentedon Jul 5, 2018
@dstufft yep!
dstufft commentedon Jul 5, 2018
Is there currently any way to work around it? I've been poking at Concourse again, and I think maybe if the pipeline doesn't use any child tasks and stores all tasks in the pipeline itself it should be ok?
vito commentedon Jul 26, 2018
@dstufft (sorry for the delay) - yeah, as long as your pipeline doesn't load tasks from untrusted repositories (PRed repos) you should be safe. You could either inline them with
config:or take them from some other repo that only you control.bump etree tsa handlers mux clockwork goxmldsig genproto grpc
willmurphyscode commentedon Apr 18, 2019
@vito One mitigation I was planning to try was having the pipeline use a regular git resource pointed at master for pipeline code, and a GitHub PR resource only for application and test code. For example, something like:
Then all the task configs are read off files like
file: master/ci/tasks/units.ymlfor example. Does that seem like an adequate mitigation? That way, if a PR does change a task config file, the pipeline would continue to use master's version of that file.This fix really separates trusted from untrusted code by branch, not be repository, so I wanted to double check, but they seem equivalent to me.
vito commentedon May 14, 2019
@willmurphyscode 🐢 Yep, that seems sensible!
ci (prs): use trusted task configs
stale commentedon Jul 16, 2019
Beep boop! This issue has been idle for long enough that it's time to check
in and see if it's still important.
If it is, what is blocking it? Would anyone be interested in submitting a
PR or
continuing the discussion to help move things forward?
If no activity is observed within the next week, this issue will be
exterminatedclosed, in accordance with our stale issueprocess.