GCP에 대한 공격을 고려하다.권한 프로모션 정보

개시하다


이전 글에서는 인증 정보를 획득하고 GCP에 대한 초기 액세스를 수행하는 방법을 주제로 다루었습니다.
GCP에 대한 공격을 고려하다.인증 정보 도난 (gcloud 명령) 편
https://zenn.dev/fire_fire_2/articles/e7484c7ca3702b
그렇다면 여기서 얻은 인증 정보의 권한, 높은 권한도 있지만, 대부분의 경우 그렇게 권한이 없는 것이 많다고 생각합니다.따라서 공격자가 다음 공격을 할 수 있도록 하고 싶은 것은 승격 권한이다.
GCP 초기 방문 후 공격자가 진행할 정보 열거, 권한 향상, 침해 목적 달성에 대한 개론을 깃랩 레드팀의 크리스 모버리가 블로그에 소개했다.
Tutorial on privilege escalation and post exploitation tactics in Google Cloud Platform environments | GitLab
https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/

권한 프로모션이란


간단하게 권한 상승을 설명하자면 낮은 권한만 부여된 계정에서 부여된 권한과 시스템의 취약성을 남용하여 다른 계정의 인증 정보를 얻고 자신에게 높은 권한을 부여하는 것을 말한다.
GCP의 경우 계정에 할당된 역할에 대한 권한이 남용됩니다.

권한이 부여된 확인 방법


GCP 계정에 어떤 권한이 할당됐는지, 자신의 역할을 확인하고 해당 역할에 어떤 권한이 할당됐는지 확인하십시오.
$ gcloud projects get-iam-policy <PROJECT_ID>
$ gcloud iam roles describe <ROLE_NAME>
단, 이 확인을 하려면 프로젝트의 Resource 관리자와 iam 관련 권한을 열람해야 합니다.
권한이 없는 계정의 경우 각 API에 대해 사용 가능한 권한을 테스트해야 합니다.
권한 테스트 | Cloud IAM 설명서 | Google Cloud

권한 승급 방법 및 남용 가능 권한


그렇다면 어떤 권한이 부여되면 권한으로 승격될 수 있다는 점(선인들의 보도)을 소개해 드리겠습니다.
이런 보안 정보를 공개하기로 유명한Rhino Security LabsGiithub에 악용할 수 있는 권한 일람표를 공개했다.
https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation
각자의 수법에 대해 상세하게 검증한 보고서를 블로그에 공개하면 참고할 수 있다.

Cloud Build 시스템


GCP Penetration Testing Working-As-Intended: RCE to IAM Privilege Escalation in GCP Cloud Build
https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/
# 権限
cloudbuild.builds.create

IAM 시스템


Privilege Escalation in Google Cloud Platform – Part 1 (IAM)
https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/
# 権限
deploymentmanager.deployments.create
iam.roles.update
iam.serviceAccounts.getAccessToken
iam.serviceAccountKeys.create
iam.serviceAccounts.implicitDelegation
iam.serviceAccounts.signBlob
iam.serviceAccounts.signJwt
cloudfunctions.functions.create
cloudfunctions.functions.update
compute.instances.create
run.services.create
cloudscheduler.jobs.create

비 IAM 계열


Privilege Escalation in Google Cloud Platform – Part 2 (Non-IAM)
https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/
# 権限
orgpolicy.policy.set
storage.hmacKeys.create
serviceusage.apiKeys.create
serviceusage.apiKeys.list

클라우드 스토리지 시스템


Google Cloud Platform (GCP) Bucket Enumeration and Privilege Escalation
https://rhinosecuritylabs.com/gcp/google-cloud-platform-gcp-bucket-enumeration/

경품: GKE 계열


GKE Kubelet TLS Bootstrap Privilege Escalation
https://rhinosecuritylabs.com/cloud-security/kubelet-tls-bootstrap-privilege-escalation/

승격 스캐너


권한이 있는 계정을 열거할 수 있는 스캐너도 공개됐다.
https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/tree/master/PrivEscScanner
사용법은 간단하다.
# アクセストークンの取得
$ gcloud auth print-access-token
# 権限一覧JSONの取得(アクセストークンは上記で取得したものを入力)
$ python enumerate_member_permissions.py --project-id <PROJECT_ID>
# 上記JSONと同じフォルダ内で実行
$ python check_for_privesc.py

총결산


이번에는 악용될 수 있는 권한과 업그레이드 권한을 악용하는 방법을 공개한 사이트를 소개했다.
또 스캐너가 이 권한을 부여받았는지의 사용 방법도 소개했다.시스템이 실행됐기 때문에 갑자기 권한을 취소할 수 없는 경우도 있을 것 같아서 어느 계좌에 승진 권한이 있는지 가능성을 확인하는 의미에서 자신의 환경에서도 체크하는 게 좋을 것 같다.
그리고 그중의 한 가지 수법을 실제로 검증했으니 다음에는 그것으로 쓰고 싶어요.

참고 문헌


Blog - Rhino Security Labs
https://rhinosecuritylabs.com/blog/?category=gcp

좋은 웹페이지 즐겨찾기