Skip to content

Commit bbb767c

Browse files
Scotttekton-robot
Scott
authored andcommitted
Remove creds-init intContainer
Creds-init is an initContainer that writes credential files (like .ssh) to /tekton/home. One side-effect of relying on an initContainer to write these files is that they receive the UID / Group ID of the initContainer's process. This side-effect breaks any Step in the Task that relies on these credentials but runs with a different UID. An example of where this can happen is on OpenShift, where the UID of the user is randomized for each container in order to limit the fallout of malicious process breaking out. This commit removes the creds-init initContainer from all TaskRun Pods. I haven't removed the creds-init binary from our build process in this changeset. Doing so generates a lot of extra line noise which distracts from the core modification being presented here. This commit introduces an example YAML that successfully exercises creds-init with vanilla git commands both when the disable-home-env-overwrite flag is "false" (the current default) and when it's "true". In addition the example demonstrates working with creds-init credentials when a non-root securityContext is set on a Step.
1 parent f01b977 commit bbb767c

File tree

22 files changed

+681
-322
lines changed

22 files changed

+681
-322
lines changed

cmd/creds-init/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818
import (
1919
"flag"
2020

21+
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
2122
"github.com/tektoncd/pipeline/pkg/credentials"
2223
"github.com/tektoncd/pipeline/pkg/credentials/dockercreds"
2324
"github.com/tektoncd/pipeline/pkg/credentials/gitcreds"
@@ -37,7 +38,7 @@ func main() {
3738

3839
builders := []credentials.Builder{dockercreds.NewBuilder(), gitcreds.NewBuilder()}
3940
for _, c := range builders {
40-
if err := c.Write(); err != nil {
41+
if err := c.Write(pipeline.CredsDir); err != nil {
4142
logger.Fatalf("Error initializing credentials: %v", err)
4243
}
4344
}

cmd/entrypoint/main.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
"time"
2727

2828
"github.com/tektoncd/pipeline/pkg/credentials"
29+
"github.com/tektoncd/pipeline/pkg/credentials/dockercreds"
30+
"github.com/tektoncd/pipeline/pkg/credentials/gitcreds"
2931
"github.com/tektoncd/pipeline/pkg/entrypoint"
3032
"github.com/tektoncd/pipeline/pkg/termination"
3133
)
@@ -41,8 +43,22 @@ var (
4143
)
4244

4345
func main() {
46+
// Add credential flags originally used in creds-init.
47+
gitcreds.AddFlags(flag.CommandLine)
48+
dockercreds.AddFlags(flag.CommandLine)
49+
4450
flag.Parse()
4551

52+
// Copy creds-init credentials from secret volume mounts to /tekton/creds
53+
// This is done to support the expansion of a variable, $(credentials.path), that
54+
// resolves to a single place with all the stored credentials.
55+
builders := []credentials.Builder{dockercreds.NewBuilder(), gitcreds.NewBuilder()}
56+
for _, c := range builders {
57+
if err := c.Write("/tekton/creds"); err != nil {
58+
log.Printf("Error initializing credentials: %s", err)
59+
}
60+
}
61+
4662
e := entrypoint.Entrypointer{
4763
Entrypoint: *ep,
4864
WaitFiles: strings.Split(*waitFiles, ","),
@@ -56,7 +72,7 @@ func main() {
5672
Results: strings.Split(*results, ","),
5773
}
5874

59-
// Copy any creds injected by creds-init into the $HOME directory of the current
75+
// Copy any creds injected by the controller into the $HOME directory of the current
6076
// user so that they're discoverable by git / ssh.
6177
if err := credentials.CopyCredsToHome(credentials.CredsInitCredentials); err != nil {
6278
log.Printf("non-fatal error copying credentials: %q", err)

docs/auth.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@ This is required because while Tekton does set the $HOME environment variable
121121
to `/tekton/home` by default, `ssh` ignores that environment variable and only
122122
considers the user's home as that described in `/etc/passwd`.
123123

124-
**Note:** This additional symlink is not required if you are using the
124+
**Note:** The additional symlink is not required if you are using the
125125
[`git-clone` catalog Task](https://github.com/tektoncd/catalog/tree/v1beta1/git)
126126
or Git PipelineResource.
127127

128+
For an example of vanilla git commands using the SSH credentials described
129+
above, see the
130+
[authenticating-git-commands example](../examples/v1beta1/taskruns/authenticating-git-commands.yaml).
131+
128132
## Basic authentication (Git)
129133

130134
1. Define a `Secret` containing the username and password that the `Run` should
@@ -375,6 +379,28 @@ Credential annotation keys must begin with `tekton.dev/docker-` or
375379
`tekton.dev/git-`, and the value describes the URL of the host with which to use
376380
the credential.
377381

382+
## Using credentials as non-root user
383+
384+
For a number of reasons you may need to use the credentials described in this
385+
doc in non-root contexts:
386+
387+
- Your platform may randomize the user and/or groups that your containers run as.
388+
- The Steps of Tasks that you use may define a non-root `securityContext`.
389+
- Tasks themselves may specify non-root `securityContext`s applied to all `Steps`.
390+
391+
Running as a non-root user has several effects that need to be accounted for
392+
when using the credentials mounted with the process described above:
393+
394+
1. Certain credential types (SSH/git) require that the user have a valid home
395+
directory defined in `/etc/passwd`. Just having a random UID but no home directory
396+
will result in SSH erroring out.
397+
2. Credentials may need to be moved or symlinked from the `$HOME` directory that
398+
Tekton defines (`/tekton/home`) to the correct `home` directory for your user.
399+
This is true for SSH, which ignores the `$HOME` environment variable completely.
400+
401+
For an example of using SSH credentials in a non-root `securityContext`, see the
402+
[authenticating-git-commands example](../examples/v1beta1/taskruns/authenticating-git-commands.yaml).
403+
378404
## Implementation details
379405

380406
### Docker `basic-auth`

docs/variables.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This page documents the variable substitions supported by `Tasks` and `Pipelines
2929
| `workspaces.<workspaceName>.path` | The path to the mounted `Workspace`. |
3030
| `workspaces.<workspaceName>.claim` | The name of the `PersistentVolumeClaim` specified as a volume source for the `Workspace`. Empty string for other volume types. |
3131
| `workspaces.<workspaceName>.volume` | The name of the volume populating the `Workspace`. |
32-
| `credentials.path` | The path to the credentials written by the `creds-init` init container. |
32+
| `credentials.path` | The path to credentials injected from Secrets with matching annotations. |
3333
| `context.taskRun.name` | The name of the `TaskRun` that this `Task` is running in. |
3434
| `context.task.name` | The name of this `Task`. |
3535

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# This example demonstrates usage of creds-init credentials to issue
2+
# git commands without a Git PipelineResource or git-clone catalog task.
3+
#
4+
# In order to exercise creds-init a sidecar is used to run a
5+
# git server fronted by SSH. The sidecar does the following things:
6+
# - Generates a host key pair, providing the public key to Steps for their known_hosts file
7+
# - Accepts a public key generated from creds-init credentials and uses that for an authorized_keys file
8+
# - Creates a bare git repo for the test git commands to run against
9+
# - Starts sshd and tails its log, waiting for the git commands to come in over SSH
10+
#
11+
# Two separate Steps then perform authenticated git actions against the sidecar
12+
# git server using the credentials mounted by creds-init:
13+
14+
# The first step makes a git clone of the bare repository and populates it
15+
# with a file.
16+
#
17+
# The second step makes a git clone of the populated repository and checks
18+
# the contents of the repo match expectations. This step runs as a non-root
19+
# user in order to exercise creds-init credentials when a securityContext
20+
# is set.
21+
#
22+
# Notice that in each Step there is different code for handling creds-init
23+
# credentials when the disable-home-env-overwrite flag is "false" and when
24+
# it's "true".
25+
apiVersion: v1
26+
kind: Secret
27+
type: kubernetes.io/ssh-auth
28+
metadata:
29+
name: ssh-key-for-git
30+
annotations:
31+
tekton.dev/git-0: localhost
32+
data:
33+
# This key was generated for this test and isn't used for anything else.
34+
ssh-privatekey: LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUJsd0FBQUFkemMyZ3RjbgpOaEFBQUFBd0VBQVFBQUFZRUF5T1g3ZG5OWlFBZVk4cHNMOXlaUnp3NXNDVG1yWGh6Zld1YTZuZ2VDQ0VRRTY4YjVUSThTCkNlbEhlNG9oTUtBdXZ0ZTE4YXJMK2EvVldpeFN6a2tBMmFIZVhkdUJ1bStkS2R2TlVVSUhNc1dOUythcENQYmE4R3ZGaHYKdG81Tkx0bWpxT2M0WjJkK1RPS3AvakMrS3pvUDFHQWdRL25QMitMTldabzlvTTc4TzQ3Z1dSem9FNlFKeGJqbFlPMHRMbwp4YXUxdTNrbUtsNSthbUxsNHpGN25wdmV1dGlSWDhmY2hGam5Ka2dqK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RG0KWTFuaTRUOGJjdzY2dmFzamthcjFZekptM1VidEVnSzQ2VVllNGJac2NXbWt4dngwMEFBQURCQVA4UysyTmtheWkvb3NzVApTQXpJMi9QU2tJMDVEY1lTYnNOQjZ4a3pobzdKaDlHeUNvbW5xZ1IxR2ZBOTBqV3AxVks0TG43TmtYYWJaVmJPc0xoT21DCkdBbVRZTHRjaTB0bkhhYk5HTEZ3ZmdiUitqRzZNQ2p4cEh5anM5MDlKSHhtYmswbElpczdPN1N3VThERGcrSEVxc0EvNUoKQ1VMTWU3em9mNERhUnZXdFhTRks2ZW5LNnpGaHBINjVQY29TN0o0NjJhNzdUMDVGQXhMemNaRkc5VWZ5WUdMa1ZmdHRTTApNVDhudW9LaW5XTGNLSlVQeis1MjJlM3lIcis4c3pVUUFBQU1FQXlhQ28xSnRBcjRpczY0YTBuZTFUV0o0dXcyT3FDdUlDCm9acG1QN2UyRnh3bVRCSWMrbzZkSEVNVHo2c2ZZSkFxU2l4ZzYydXYzWlRTc25STWljaDZ0b1k0SVI4cWFMa1prLzU5cmEKQWFONFlvTkdpQTZxY0Jzc3NLMmZuM2YxRFJhckxPbWZHTnpTMU41S1RvSFVlUkVGWDExdHVNM1pqOGxTelFBOWZSakk1OQpFWmFnOWJaOXRJOEg5dmEvTGRMK3U3dTZZWkVRSEJCS1MxMW1tOVVXd1pDMkdUV3ZnNzRlTnRmemtZeDQxdlhIeTZBbW9ECmxuOHo2N3lvWEZzbEpUQUFBQURuTmpiM1IwUUcxbFkyZ3ViR0Z1QVFJREJBPT0KLS0tLS1FTkQgT1BFTlNTSCBQUklWQVRFIEtFWS0tLS0tCg==
35+
# This known_hosts file doesn't actually get used; we overwrite it with the public key
36+
# of our temporary test git server. But it's required here because otherwise creds-init
37+
# calls ssh-keyscan which in turn tries to reach out over the network, will fail to make
38+
# contact with the localhost SSH server because it isn't running yet, and the TaskRun
39+
# will end in failure.
40+
known_hosts: Cg==
41+
---
42+
apiVersion: v1
43+
kind: ServiceAccount
44+
metadata:
45+
name: ssh-key-service-account
46+
secrets:
47+
- name: ssh-key-for-git
48+
---
49+
apiVersion: tekton.dev/v1beta1
50+
kind: TaskRun
51+
metadata:
52+
name: authenticating-git-commands
53+
spec:
54+
serviceAccountName: ssh-key-service-account
55+
taskSpec:
56+
volumes:
57+
- name: messages
58+
emptyDir: {}
59+
sidecars:
60+
- name: server
61+
image: alpine/git:v2.24.3
62+
securityContext:
63+
runAsUser: 0
64+
volumeMounts:
65+
- name: messages
66+
mountPath: /messages
67+
script: |
68+
#!/usr/bin/env ash
69+
70+
# Generate a private host key and give the Steps access to its public
71+
# key for their known_hosts file.
72+
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
73+
chmod 0600 /etc/ssh/ssh_host_rsa_key*
74+
HOST_PUBLIC_KEY=$(cat /etc/ssh/ssh_host_rsa_key.pub | awk '{ print $2 }')
75+
echo "localhost ssh-rsa $HOST_PUBLIC_KEY" > /messages/known_hosts
76+
77+
# Wait for a Step to supply the server a public key generated from creds-init
78+
# credentials.
79+
while [ ! -f /messages/authorized_keys ] ; do
80+
sleep 1
81+
done
82+
83+
# Allow Steps to SSH login as root to this server.
84+
mkdir /root/.ssh
85+
cp /messages/authorized_keys /root/.ssh/
86+
87+
# "Unlock" the root account, allowing SSH login to succeed.
88+
sed -i s/root:!/"root:*"/g /etc/shadow
89+
90+
# Create the git repo we're going to test against.
91+
cd /root/
92+
mkdir repo
93+
cd repo
94+
git init . --bare
95+
96+
# Start the sshd server.
97+
/usr/sbin/sshd -E /var/log/sshd
98+
touch /messages/sshd-ready
99+
tail -f /var/log/sshd
100+
steps:
101+
- name: setup
102+
# This Step is only necessary as part of the test, it's not something you'll
103+
# ever need in a real-world scenario involving an external git repo.
104+
image: alpine/git:v2.24.3
105+
securityContext:
106+
runAsUser: 0
107+
volumeMounts:
108+
- name: messages
109+
mountPath: /messages
110+
script: |
111+
#!/usr/bin/env ash
112+
113+
# Generate authorized_keys file from the creds-init private key and give
114+
# it to the sidecar server so that Steps can successfully SSH login
115+
# using creds-init credentials.
116+
ssh-keygen -y -f $(credentials.path)/.ssh/id_ssh-key-for-git > /messages/authorized_keys
117+
118+
# Wait for sshd to start on the git server.
119+
while [ ! -f /messages/sshd-ready ] ; do
120+
sleep 1
121+
done
122+
- name: git-clone-and-push
123+
image: alpine/git:v2.24.3
124+
securityContext:
125+
runAsUser: 0
126+
workingDir: /root
127+
volumeMounts:
128+
- name: messages
129+
mountPath: /messages
130+
script: |
131+
#!/usr/bin/env ash
132+
set -xe
133+
134+
if [ -d /tekton/home/.ssh ] ; then
135+
# When disable-home-env-overwrite is "false", creds-init credentials
136+
# will be copied to /tekton/home/.ssh by the entrypoint. But we need
137+
# them in /root/.ssh.
138+
139+
# Overwrite the creds-init known_hosts file with that of our test
140+
# git server. You wouldn't need to do this in any kind of real-world
141+
# scenario involving an external git repo.
142+
cp /messages/known_hosts $(credentials.path)/.ssh/
143+
144+
# Symlink /tekton/creds/.ssh to /root/.ssh because this script issues
145+
# vanilla git commands of its own. Git PipelineResources and the git-clone
146+
# catalog task handle this for you.
147+
ln -s $(credentials.path)/.ssh /root/.ssh
148+
else
149+
# When disable-home-env-overwrite is "true", creds-init credentials
150+
# will be copied to /root/.ssh by the entrypoint. We just need to
151+
# overwrite the known_hosts file with that of our test git server.
152+
cp /messages/known_hosts /root/.ssh/known_hosts
153+
fi
154+
155+
git clone root@localhost:/root/repo ./repo
156+
cd repo
157+
git config user.email "[email protected]"
158+
git config user.name "Example"
159+
echo "Hello, world!" > README
160+
git add README
161+
git commit -m "Test commit!"
162+
git push origin master
163+
- name: git-clone-and-check
164+
image: gcr.io/tekton-releases/dogfooding/alpine-git-nonroot:mario
165+
# Because this Step runs with a non-root security context, the creds-init
166+
# credentials will fail to copy into /tekton/home. This happens because
167+
# our previous step _already_ wrote to /tekton/home and ran as a root
168+
# user. So there will be warning messages reporting "unsuccessful cred
169+
# copy". These can be safely ignored and instead this Step will copy
170+
# the credentials out of /tekton/creds to nonroot's HOME directory.
171+
securityContext:
172+
runAsUser: 1000
173+
workingDir: /home/nonroot
174+
volumeMounts:
175+
- name: messages
176+
mountPath: /messages
177+
script: |
178+
#!/usr/bin/env ash
179+
set -xe
180+
181+
if [ -d /tekton/home/.ssh ] ; then
182+
# When disable-home-env-overwrite is "false", creds-init credentials
183+
# will be copied to /tekton/home/.ssh by the entrypoint. But we need
184+
# them in /home/nonroot/.ssh.
185+
186+
# Overwrite the creds-init known_hosts file with that of our test
187+
# git server. You wouldn't need to do this in any kind of real-world
188+
# scenario involving an external git repo.
189+
cp /messages/known_hosts $(credentials.path)/.ssh/
190+
191+
# Symlink /tekton/creds/.ssh to /home/nonroot/.ssh because this script issues
192+
# vanilla git commands of its own and we're running as a non-root user.
193+
# Git PipelineResources and the git-clone catalog task handle this for you.
194+
ln -s $(credentials.path)/.ssh /home/nonroot/.ssh
195+
else
196+
# When disable-home-env-overwrite is "true", creds-init credentials
197+
# will be copied to /home/nonroot/.ssh by the entrypoint. We just need to
198+
# overwrite the known_hosts file with that of our test git server.
199+
cp /messages/known_hosts /home/nonroot/ssh/known_hosts
200+
fi
201+
202+
git clone root@localhost:/root/repo ./repo
203+
cd repo
204+
cat README | grep "Hello, world!"

pkg/apis/pipeline/paths.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ const (
2323
DefaultResultPath = "/tekton/results"
2424
// HomeDir is the HOME directory of PipelineResources
2525
HomeDir = "/tekton/home"
26+
// CredsDir is the directory where credentials are placed to meet the creds-init contract
27+
CredsDir = "/tekton/creds"
2628
)

pkg/credentials/dockercreds/creds.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ var config basicDocker
3737
var dockerConfig string
3838
var dockerCfg string
3939

40+
// AddFlags adds CLI flags that dockercreds supports to a given flag.FlagSet.
41+
func AddFlags(flagSet *flag.FlagSet) {
42+
flags(flagSet)
43+
}
44+
4045
func flags(fs *flag.FlagSet) {
4146
config = basicDocker{make(map[string]entry)}
4247
fs.Var(&config, "basic-docker", "List of secret=url pairs.")
4348
fs.StringVar(&dockerConfig, "docker-config", "", "Docker config.json secret file.")
4449
fs.StringVar(&dockerCfg, "docker-cfg", "", "Docker .dockercfg secret file.")
4550
}
4651

47-
func init() {
48-
flags(flag.CommandLine)
49-
}
50-
5152
// As the flag is read, this status is populated.
5253
// basicDocker implements flag.Value
5354
type basicDocker struct {
@@ -148,8 +149,8 @@ func (*basicDockerBuilder) MatchingAnnotations(secret *corev1.Secret) []string {
148149
return flags
149150
}
150151

151-
func (*basicDockerBuilder) Write() error {
152-
dockerDir := filepath.Join(os.Getenv("HOME"), ".docker")
152+
func (*basicDockerBuilder) Write(directory string) error {
153+
dockerDir := filepath.Join(directory, ".docker")
153154
basicDocker := filepath.Join(dockerDir, "config.json")
154155
if err := os.MkdirAll(dockerDir, os.ModePerm); err != nil {
155156
return err

0 commit comments

Comments
 (0)