# Secrets Manager

Secrets Manager는 AWS에서 제공하는 비밀 관리형 서비스로 데이터베이스 연결 정보 등과 같은 크리덴셜을 백엔드 소스코드에 하드코딩하지 않고도 연결할 수 있도록 지원합니다.&#x20;

이 서비스를 통해 관리되는 모든 정보는 기본적으로 AWS KMS를 통해 암호화가 되며, 저장 외에도 자동으로 주기적 패스워드 변경 서비스도 지원합니다.

## Abuse

환경 구성 : [Secrets Manager](/home-lab/aws/secrets-manager.md)

<pre class="language-bash"><code class="lang-bash"><strong># 현재 연결된 IAM 사용자 ARN 확인
</strong>aws sts get-caller-identity

<strong># Secrets Manager와 관련된 IAM 권한 확인
</strong>aws iam simulate-principal-policy --policy-source-arn '&#x3C;arn>' --action-names secretsmanager:GetSecretValue secretsmanager:ListSecrets

<strong># AWS Secrets Manager 열거
</strong>aws secretsmanager list-secrets --query 'SecretList[*].[Name, Description, ARN]' --output json

<strong># 열거된 보안 암호에 저장된 값 출력
</strong>aws secretsmanager get-secret-value --secret-id '&#x3C;보안 암호 이름>' --query SecretString --output text | jq
</code></pre>

{% hint style="info" %}
해당 시나리오는 다음과 같은 권한이 요구됩니다.

1. GetCallerIdentity
2. iam:SimulatePrincipalPolicy
3. secretsmanager:ListSecrets
4. secretsmanager:GetSecretValue
   {% endhint %}

Secrets Manager을 사용하여 자격증명을 안전하게 보관하면 파일 다운로드 공격과 같이 웹 서버의 소스코드를 탈취하는 공격으로부터는 비교적 안전할 수 있지만 웹 서버가 장악당한다면 소스코드를 수정하여 자격증명을 탈취할 수 있습니다.

## Demo

<figure><img src="/files/SL2rR7Bee6v67ULpL4Ek" alt=""><figcaption></figcaption></figure>

## References

{% embed url="<https://somaz.tistory.com/183>" %}

{% embed url="<https://docs.aws.amazon.com/IAM/latest/APIReference/API_SimulatePrincipalPolicy.html>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pentestwiki.com/cloud/aws/undefined-1/secrets-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
