Skip to content

Commit ba41363

Browse files
authored
Merge pull request kubernetes#1598 from zshihang/permission
proposal for file permission handling in projected service account volume
2 parents b26294a + 73188e8 commit ba41363

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

keps/sig-storage/20180515-svcacct-token-volumes.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ authors:
44
- "@smarterclayton"
55
- "@liggitt"
66
- "@mikedanese"
7+
- "@zshihang"
78
owning-sig: sig-storage
89
participating-sigs:
910
- sig-auth
@@ -14,7 +15,7 @@ approvers:
1415
- "@saad-ali"
1516
editor: "@zshihang"
1617
creation-date: 2018-05-15
17-
last-updated: 2020-03-09
18+
last-updated: 2020-03-27
1819
status: implemented
1920
see-also:
2021
- "https://github.com/kubernetes/community/blob/e3a6b8172fec9506b15520549e52be683e30cbfb/contributors/design-proposals/storage/svcacct-token-volume-source.md"
@@ -29,6 +30,9 @@ see-also:
2930
- [Motivation](#motivation)
3031
- [Proposal](#proposal)
3132
- [Token Volume Projection](#token-volume-projection)
33+
- [File Permission](#file-permission)
34+
- [Proposed heuristics](#proposed-heuristics)
35+
- [Alternatives considered](#alternatives-considered)
3236
- [Alternatives](#alternatives)
3337
- [Graduation Criteria](#graduation-criteria)
3438
<!-- /toc -->
@@ -65,7 +69,6 @@ With this feature, we hope to provide a backwards compatible replacement for
6569
service account tokens that strengthens the security and improves the
6670
scalability of the platform.
6771

68-
6972
## Proposal
7073

7174
Kubernetes should implement a ServiceAccountToken volume projection that
@@ -142,7 +145,6 @@ sources:
142145
fieldRef: metadata.namespace
143146
```
144147
145-
146148
This fixes one scalability issue with the current service account token
147149
deployment model where secret GETs are a large portion of overall apiserver
148150
traffic.
@@ -159,6 +161,55 @@ sources:
159161
audience: ca.istio.io
160162
```
161163
164+
### File Permission
165+
166+
The secret projections are currently written with world readable (0644,
167+
effectively 444) file permissions. Given that file permissions are one of the
168+
oldest and most hardened isolation mechanisms on unix, this is not ideal.
169+
We would like to opportunistically restrict permissions for projected service
170+
account tokens as long we can show that they won’t break users if we are to
171+
migrate away from secrets to distribute service account credentials.
172+
173+
#### Proposed heuristics
174+
175+
+ *Case 1*: The pod has an fsGroup set. We can set the file permission on the
176+
token file to 0600 and let the fsGroup mechanism work as designed. It will
177+
set the permissions to 0640, chown the token file to the fsGroup and start
178+
the containers with a supplemental group that grants them access to the
179+
token file. This works today.
180+
+ *Case 2*: The pod’s containers declare the same runAsUser for all containers
181+
(ephemeral containers are excluded) in the pod. We chown the token file to
182+
the pod’s runAsUser to grant the containers access to the token. All
183+
containers must have UID either specified in container security context or
184+
inherited from pod security context. Preferred UIDs in container images are
185+
ignored.
186+
+ *Fallback*: We set the file permissions to world readable (0644) to match
187+
the behavior of secrets.
188+
189+
This gives users that run as non-root greater isolation between users without
190+
breaking existing applications. We also may consider adding more cases in the
191+
future as long as we can ensure that they won’t break users.
192+
193+
#### Alternatives considered
194+
195+
+ We can create a volume for each UserID and set the owner to be that UserID
196+
with mode 0400. If user doesn't specify runAsUser, fetching UserID in image
197+
requires a re-design of kubelet regarding volume mounts and image pulling.
198+
This has significant implementation complexity because:
199+
+ We would have to reorder container creation to introspect images (that
200+
might declare USER or GROUP directives) to pass this information to the
201+
projected volume mounter.
202+
+ Further, images are mutable so these directives may change over the
203+
lifetime of the pod.
204+
+ Volumes are shared between all pods that mount them today. Mapping a
205+
single logical volume in a pod spec to distinct mount points is likely a
206+
significant architectural change.
207+
+ We pick a random group and set fsGroup on all pods in the service account
208+
admission controller. It’s unclear how we would do this without conflicting
209+
with usage of groups and potentially compromising security.
210+
+ We set token files to be world readable always. Problems with this are
211+
discussed above.
212+
162213
### Alternatives
163214
164215
1. Instead of implementing a service account token volume projection, we could
@@ -173,7 +224,6 @@ sources:
173224
users needing to install this extension.
174225
1. Complicates installation for the majority of users.
175226
176-
177227
## Graduation Criteria
178228
179229
TBD

0 commit comments

Comments
 (0)