Kubelet 인증 및 권한 부여
Tip
AWS 해킹 학습 및 실습:
HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 학습 및 실습:HackTricks Training GCP Red Team Expert (GRTE)
Az 해킹 학습 및 실습:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 플랜을 확인하세요!
- 참여하세요 💬 Discord group 또는 telegram group에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- PR을 제출하여 해킹 트릭을 공유하세요: HackTricks 및 HackTricks Cloud github repos.
Kubelet 인증
기본적으로, 다른 구성된 인증 방법들에 의해 거부되지 않는 kubelet의 HTTPS 엔드포인트로의 요청은 익명 요청으로 처리되며, username of system:anonymous 및 group of system:unauthenticated 가 부여됩니다.
인증 방법은 총 3가지입니다:
- Anonymous (기본값): 파라미터
--anonymous-auth=true또는 구성에서 설정:
"authentication": {
"anonymous": {
"enabled": true
},
- Webhook: 이는 kubectl API bearer tokens를 인증 수단으로 활성화합니다 (유효한 토큰이라면 모두 허용됩니다). 허용하려면:
- API 서버에서
authentication.k8s.io/v1beta1API 그룹이 활성화되어 있는지 확인하십시오 - kubelet을
--authentication-token-webhook및--kubeconfig플래그로 시작하거나 다음 설정을 사용하십시오:
"authentication": {
"webhook": {
"cacheTTL": "2m0s",
"enabled": true
},
Note
kubelet는 구성된 API 서버에서
TokenReviewAPI를 호출하여 bearer tokens로부터 사용자 정보를 파악합니다
- X509 client certificates: X509 클라이언트 인증서를 통해 인증할 수 있습니다
- see the apiserver authentication documentation for more details
- kubelet을
--client-ca-file플래그로 시작하여 클라이언트 인증서를 검증할 CA 번들을 제공합니다. 또는 다음 설정으로:
"authentication": {
"x509": {
"clientCAFile": "/etc/kubernetes/pki/ca.crt"
}
}
Kubelet 권한
성공적으로 인증된 모든 요청(익명 요청 포함)은 권한이 부여됩니다. 기본 권한 부여 모드는 **AlwaysAllow**로, 이는 모든 요청을 허용합니다.
하지만 다른 가능한 값은 **webhook**입니다(실제로 대부분 이 값을 보게 될 것입니다). 이 모드는 인증된 사용자의 권한을 검사하여 작업을 허용하거나 거부합니다.
Warning
설사 익명 인증이 활성화되어 있더라도, 익명 접근은 어떤 작업도 수행할 권한이 없을 수 있습니다.
Webhook을 통한 권한 부여는 **param --authorization-mode=Webhook**을 사용하거나 구성 파일을 통해 다음과 같이 설정할 수 있습니다:
"authorization": {
"mode": "Webhook",
"webhook": {
"cacheAuthorizedTTL": "5m0s",
"cacheUnauthorizedTTL": "30s"
}
},
The kubelet calls the SubjectAccessReview API on the configured API server to determine whether each request is authorized.
kubelet은 구성된 API 서버에서 SubjectAccessReview API를 호출하여 각 요청에 대해 권한이 있는지 판단합니다.
The kubelet authorizes API requests using the same request attributes approach as the apiserver:
kubelet은 apiserver와 동일한 request attributes 방식을 사용하여 API 요청을 인가합니다:
-
Action
-
동작
| HTTP verb | request verb |
|---|---|
| POST | create |
| GET, HEAD | get (for individual resources), list (for collections, including full object content), watch (for watching an individual resource or collection of resources) |
| PUT | update |
| PATCH | patch |
| DELETE | delete (for individual resources), deletecollection (for collections) |
-
The resource talking to the Kubelet api is always nodes and subresource is determined from the incoming request’s path:
-
Kubelet API와 통신하는 resource는 항상 nodes이며, subresource는 들어오는 요청의 경로에서 결정됩니다:
| Kubelet API | resource | subresource |
|---|---|---|
| /stats/* | nodes | stats |
| /metrics/* | nodes | metrics |
| /logs/* | nodes | log |
| /spec/* | nodes | spec |
| all others | nodes | proxy |
Note
WebSocket-based
/exec,/run,/attach, and/portforwardfall into the default proxy subresource and are authorized using the initial HTTP GET handshake. A principal with onlynodes/proxyGET can still exec containers if it connects directly tohttps://<node_ip>:10250over WebSockets. See the nodes/proxy GET -> Kubelet /exec verb confusion abuse for details.
Note
WebSocket 기반의
/exec,/run,/attach, 및/portforward는 기본 proxy subresource에 해당하며 초기 HTTP GET 핸드셰이크로 인가됩니다.nodes/proxyGET 권한만 있는 주체라도 WebSockets를 통해https://<node_ip>:10250에 직접 연결하면 컨테이너를 exec할 수 있습니다. 자세한 내용은 nodes/proxy GET -> Kubelet /exec verb confusion abuse를 참조하세요.
For example, the following request tried to access the pods info of kubelet without permission:
예를 들어, 다음 요청은 kubelet의 pods 정보를 권한 없이 접근하려고 시도했습니다:
curl -k --header "Authorization: Bearer ${TOKEN}" 'https://172.31.28.172:10250/pods'
Forbidden (user=system:node:ip-172-31-28-172.ec2.internal, verb=get, resource=nodes, subresource=proxy)
- 우리는 Forbidden 응답을 받았으므로 요청이 passed the Authentication check. 그렇지 않았다면 단순히
Unauthorised메시지만 받았을 것이다. - 우리는 username을 볼 수 있다(이 경우 token에서)
- resource가 nodes이고 subresource가 proxy였음을 확인하라(이는 앞의 정보와 일치한다)
참고자료
- https://kubernetes.io/docs/reference/access-authn-authz/kubelet-authn-authz/
- nodes/proxy GET -> kubelet exec via WebSocket bypass
Tip
AWS 해킹 학습 및 실습:
HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 학습 및 실습:HackTricks Training GCP Red Team Expert (GRTE)
Az 해킹 학습 및 실습:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 플랜을 확인하세요!
- 참여하세요 💬 Discord group 또는 telegram group에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- PR을 제출하여 해킹 트릭을 공유하세요: HackTricks 및 HackTricks Cloud github repos.
HackTricks Cloud

