

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 識別預先簽署的請求
<a name="identifying-requests"></a>

## 識別使用預先簽署 URL 的要求
<a name="requests"></a>

Amazon S3 提供[兩種內建機制，用於監控請求層級的](https://docs.aws.amazon.com/AmazonS3/latest/userguide/logging-with-S3.html)使用情況：Amazon S3 伺服器存取日誌和 AWS CloudTrail 資料事件。 這兩種機制都可以識別預先簽署的 URL 用法。 

若要篩選預先簽署 URL 使用情況的記錄檔，您可以使用驗證類型。對於伺服器存取日誌，請檢查「[身份驗證類型」欄位](https://docs.aws.amazon.com/AmazonS3/latest/userguide/LogFormat.html#:~:text=Authentication%20Type)，在 Amazon A [thena 表格中定義時，該欄位通常稱為 authtype](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-s3-access-logs-to-identify-requests.html#:~:text=authtype)。對於 CloudTrail，請[AuthenticationMethod](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cloudtrail-logging-understanding-s3-entries.html#:~:text=AuthenticationMethod)在`additionalEventData`欄位中檢查。在這兩種情況下，使用預先簽署 URL 的要求的欄位值都是`QueryString`，而`AuthHeader`大多數其他要求的值則為。

`QueryString`使用情況並不總是與預先簽署的 URL 相關聯。若要將搜尋限制為僅使用預先簽署的 URL，請尋找包含查詢字串參數`X-Amz-Expires`的要求。對於伺服器存取記錄檔，[請檢查要求 URI](https://docs.aws.amazon.com/AmazonS3/latest/userguide/LogFormat.html#:~:text=Request%2DURI)，並尋找查詢字串中具有`X-Amz-Expires`參數的要求。 對於 CloudTrail，檢查`requestParameters`元素的`X-Amz-Expires`元素。

```
{"Records": [{…, "requestParameters": {…, "X-Amz-Expires": "300"}}, …]}
```

下列 Athena 查詢會套用此篩選器：

```
SELECT * FROM {athena-table} WHERE
  authtype = 'QueryString' AND 
  request_uri LIKE '%X-Amz-Expires=%';
```

對於 AWS CloudTrail Lake，下列查詢會套用此篩選器：

```
SELECT * FROM {data-store-event-id} WHERE 
  additionalEventData['AuthenticationMethod'] = 'QueryString' AND 
  requestParameters['X-Amz-Expires'] IS NOT NULL
```

## 識別其他類型的預先簽署請求
<a name="other"></a>

POST 請求也具有唯一的身份驗證類型`HtmlForm`，在 Amazon S3 伺服器存取日誌和 CloudTrail. 此驗證類型較不常見，因此您可能無法在環境中找到這些要求。

下列 Athena 查詢會套用篩選器`HtmlForm`：

```
SELECT * FROM {athena-table} WHERE 
  authtype = 'HtmlForm';
```

對於 CloudTrail Lake，下列查詢會套用篩選條件：

```
SELECT * FROM {data-store-event-id} WHERE 
  additionalEventData['AuthenticationMethod'] = 'HtmlForm'
```

## 識別請求模式
<a name="patterns"></a>

您可以使用上一節中討論的技巧來尋找預先簽署的要求。但是，為了使該數據有用，您需要查找模式。查詢的簡單`TOP 10`結果可能會提供深入分析，但如果這還不夠，請使用下表中的分組選項。


| **分組選項** | **伺服器存取記錄** | **CloudTrail湖** | **Description** | 
| --- | --- | --- | --- | 
| **使用者代理** | `GROUP BY useragent` | `GROUP BY userAgent` | 此分組選項可幫助您找到請求的來源和目的。用戶代理是用戶提供的，並且作為身份驗證或授權機制不可靠。但是，如果您正在尋找模式，它可能會顯示很多信息，因為大多數客戶端使用至少部分人類可讀的唯一字符串。 | 
| **要求者** | `GROUP BY requester` | `GROUP BY userIdentity['arn']` | 此分組選項可協助尋找簽署請求的 IAM 主體。如果您的目標是封鎖這些要求或為現有要求建立例外狀況，這些查詢會針對此目的提供足夠的資訊。當您按照 IAM 最佳實務使用角色時，該角色具有明確識別的擁有者，您可以使用這些資訊來瞭解更多資訊。 | 
| **來源 IP 位址** | `GROUP BY remoteip` | `GROUP BY sourceIPAddress` | 在到達 Amazon S3 之前，此選項會按最後一個網路翻譯躍點進行分組。[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)<br />如果您的目標是強加網路控制，則此資料非常有用。您可能必須將此選項與諸如`endpoint`（用於服務器訪問日誌）或`vpcEndpointId`（用於 CloudTrail Lake）之類的數據結合使用以澄清來源，因為不同的網絡可能會複製私有 IP 地址。 | 
| **S3 儲存貯體名稱** | `GROUP BY bucket_name` | `GROUP BY requestParameters['bucketName']` | 此分組選項有助於尋找收到請求的值區。這可協助您識別例外狀況的需求。 | 