@exabugs/dynamodb-client 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.5.2] - 2026-10-04
11
+
12
+ ### Security
13
+
14
+ - **IAM認証バイパスの脆弱性を修正**: `authHandler.ts`が`x-amz-date`/`x-amz-content-sha256`等のヘッダーの「見た目」だけでIAM認証とみなし、実際の署名検証を行っていなかった問題を修正
15
+ - Function URLをAWS_IAM認証で保護した専用エイリアス(`iam`)を新設し、サーバー間呼び出しはそちらを使う
16
+ - 認証判定は`event.requestContext.authorizer.iam`(AWSが検証済みの場合にのみ付与され、クライアントから偽装不可)の有無に変更
17
+ - 既存のNONE認証Function URLからはIAM認証の分岐を削除し、Cognito JWTのみを受け付ける
18
+ - 詳細は`docs/adr/0001-fix-iam-auth-bypass.md`参照
19
+ - **Cognito JWTのaud検証が無効だった問題を修正**: `COGNITO_CLIENT_ID`環境変数が未設定のため`aud`クレームの検証が常にスキップされていた。新規`cognito_client_id`Terraform変数を追加し配線
20
+
21
+ ### Added
22
+
23
+ - `terraform/main.tf`: `aws_lambda_alias.iam`(AWS_IAM認証用エイリアス)、`aws_lambda_function_url.records_iam`を追加
24
+ - `terraform/outputs.tf`: `iam_function_url`・`iam_alias_arn`を追加
25
+ - `terraform/variables.tf`: `cognito_client_id`(オプション)を追加
26
+
10
27
  ## [1.5.0] - 2026-08-23
11
28
 
12
29
  ### Added
@@ -1,5 +1,5 @@
1
- // @exabugs/dynamodb-client v1.5.1
2
- // Built: 2026-09-27T04:40:22.568Z
1
+ // @exabugs/dynamodb-client v1.5.2
2
+ // Built: 2026-10-04T07:52:04.926Z
3
3
  "use strict";
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
@@ -34493,30 +34493,21 @@ var logger22 = createLogger({
34493
34493
  level: process.env.LOG_LEVEL || "info"
34494
34494
  });
34495
34495
  async function handleAuthentication(event, requestId) {
34496
- const authHeader = event.headers.authorization || event.headers.Authorization;
34497
- const hasAmzDate = event.headers["x-amz-date"] || event.headers["X-Amz-Date"];
34498
- const hasAmzContentSha = event.headers["x-amz-content-sha256"] || event.headers["X-Amz-Content-Sha256"];
34499
- const hasAwsSigV4Auth = authHeader?.startsWith("AWS4-HMAC-SHA256");
34500
- logger22.debug("Authentication check", {
34501
- requestId,
34502
- hasAuthHeader: !!authHeader,
34503
- hasAmzDate: !!hasAmzDate,
34504
- hasAmzContentSha: !!hasAmzContentSha,
34505
- hasAwsSigV4Auth: !!hasAwsSigV4Auth,
34506
- authHeaderPrefix: authHeader?.substring(0, 20)
34507
- });
34508
- const isIAMAuth = hasAwsSigV4Auth || !!(hasAmzDate && hasAmzContentSha);
34509
- if (isIAMAuth) {
34510
- await handleIAMAuthentication(event, requestId);
34511
- } else {
34512
- await handleCognitoAuthentication(authHeader, requestId);
34496
+ const iam = event.requestContext.authorizer?.iam;
34497
+ if (iam) {
34498
+ handleIAMAuthentication(iam, requestId);
34499
+ return;
34513
34500
  }
34501
+ const authHeader = event.headers.authorization || event.headers.Authorization;
34502
+ await handleCognitoAuthentication(authHeader, requestId);
34514
34503
  }
34515
34504
  __name(handleAuthentication, "handleAuthentication");
34516
- async function handleIAMAuthentication(event, requestId) {
34505
+ function handleIAMAuthentication(iam, requestId) {
34517
34506
  logger22.info("IAM authenticated request", {
34518
34507
  requestId,
34519
- sourceIp: event.requestContext.http.sourceIp
34508
+ userArn: iam.userArn,
34509
+ accountId: iam.accountId,
34510
+ callerId: iam.callerId
34520
34511
  });
34521
34512
  }
34522
34513
  __name(handleIAMAuthentication, "handleIAMAuthentication");
@@ -34717,7 +34708,7 @@ async function handler(event) {
34717
34708
  return createCorsResponse(HTTP_STATUS.OK);
34718
34709
  }
34719
34710
  if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
34720
- const version = "1.5.1";
34711
+ const version = "1.5.2";
34721
34712
  return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
34722
34713
  }
34723
34714
  if (event.requestContext.http.method !== "POST") {