@proofgate-cdk/cdk-plugin 1.1.2 → 1.2.0
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/README.md +13 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +53 -6
- package/dist/index.js.map +1 -1
- package/lean/ProofGate/Model.lean +59 -7
- package/lean/ProofGate/Security.lean +70 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -25,7 +25,19 @@ Validations.of(app).addPlugins(
|
|
|
25
25
|
);
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
プラグインは`cdk synth`中に合成済みCloudFormationを読み取り、危険な権限昇格経路を`PG-IAM-004`、未対応構文やツールチェーン障害を`PG-IAM-003`として報告します。
|
|
28
|
+
プラグインは`cdk synth`中に合成済みCloudFormationを読み取り、危険な権限昇格経路を`PG-IAM-004`、ロールが自分でIAMを書き換えられる構成を`PG-IAM-005`、未対応構文やツールチェーン障害を`PG-IAM-003`として報告します。
|
|
29
|
+
検査する経路は、次の2つです。(1) `iam:PassRole`と起動サービス(Lambda、ECS、EC2、CodeBuild、Step Functionsなど)の操作の組み合わせで、渡したロールが保護対象バケットへ届くもの。(2) `iam:PassRole`なしで、保護対象バケットへ届くロールで動いている既存のLambda関数、CodeBuildプロジェクト、Step Functionsのステートマシンを変更できるもの(`lambda:UpdateFunctionCode`、`codebuild:StartBuild`など)。どちらも`PG-IAM-004`です。`allowedPassRoleTargets`に挙げたロールは、両方の経路で許可されます。(3) ロールが、自分のロールにポリシーを付けられる(`iam:PutRolePolicy`、`iam:AttachRolePolicy`)、バケットに届く別のロールの信頼ポリシーを書き換えられる(`iam:UpdateAssumeRolePolicy`)、ロールを作ってポリシーを付けられる(`iam:CreateRole`と付与)もの。これは`PG-IAM-005`で、`Action: "*"`の管理者ロールも入ります。意図してIAMを書き換えるロールは、論理IDを`allowedPolicyWriters`に入れると許可されます。
|
|
30
|
+
|
|
29
31
|
`Resource`にIAMポリシー変数(`${aws:username}`など)を含むStatementは、評価せず未対応として`PG-IAM-003`で拒否します。
|
|
30
32
|
|
|
33
|
+
## 導入の注意
|
|
34
|
+
|
|
35
|
+
- 保護対象バケットは、固定の名前(`bucketName`)とリテラルのARNで指定します。`bucket.bucketArn`はトークンなので使えません。
|
|
36
|
+
- 普段の`synth`に影響させないため、`if (process.env.PROOFGATE === "1")`の中で登録し、`PROOFGATE=1 npx cdk synth`で検査します。
|
|
37
|
+
- 読む管理ポリシーは7件だけです(`AWSLambdaBasicExecutionRole`、`AWSLambdaVPCAccessExecutionRole`、`AmazonAPIGatewayPushToCloudWatchLogs`、`AmazonSSMManagedInstanceCore`、`AWSGlueServiceRole`、Backupの2件)。ほかの管理ポリシーや、`Resource`のパラメータ、`Fn::ImportValue`は`PG-IAM-003`になります。
|
|
38
|
+
- IAMリソースのないテンプレートは受理します。検査するプリンシパルがないからで、「証明済み」という意味ではありません。
|
|
39
|
+
- SCP、Permissions Boundary、リソースポリシー、条件、スタックをまたぐ参照、CloudFormationのスタックロール、PassRoleの要らない経路のうち上の3種類以外のサービス(ECS、SSM、Glueなど)、IAMユーザーとグループ、ロールの連鎖は、モデルの外です。
|
|
40
|
+
|
|
41
|
+
English: the path is `iam:PassRole` plus a launch action of a service (Lambda, ECS, EC2, CodeBuild, Step Functions, and others) whose passed role reaches a protected bucket. Paths without `iam:PassRole` (changing an existing Lambda function, CodeBuild project, or state machine) are `PG-IAM-004` too. A role that can change IAM itself (self-grant, take-over, creation grant; administrator roles included) is `PG-IAM-005`; list a role that writes IAM on purpose in `allowedPolicyWriters`. Use a fixed bucket name and a literal ARN, and register the plugin under `PROOFGATE=1`. Only seven managed policies are read. A template without IAM resources is accepted because there is nothing to check, not because it was proved safe.
|
|
42
|
+
|
|
31
43
|
詳細な対応IAM構文と信頼境界は、[ProofGateリポジトリ](https://github.com/mashharuki/proofgate)を参照してください。
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProofGateConfig } from "@proofgate-cdk/model";
|
|
2
2
|
import type { IPolicyValidationContext, IPolicyValidationPlugin, PolicyValidationPluginReport } from "aws-cdk-lib";
|
|
3
3
|
/** CDKプラグインの設定です。leanDirectoryはテストや特殊な配置でだけ上書きします。 */
|
|
4
4
|
export interface ProofGateValidatorProps extends ProofGateConfig {
|
|
@@ -12,7 +12,7 @@ export declare class ProofGateValidator implements IPolicyValidationPlugin {
|
|
|
12
12
|
/** プラグイン名、ルールID、バージョンはCDKレポートに表示されます。 */
|
|
13
13
|
readonly name = "ProofGate";
|
|
14
14
|
readonly ruleIds: string[];
|
|
15
|
-
readonly version
|
|
15
|
+
readonly version: string;
|
|
16
16
|
private readonly leanDirectory;
|
|
17
17
|
private leanBuildError;
|
|
18
18
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { evaluate, generateLean } from "@proofgate-cdk/core";
|
|
6
|
+
import { evaluate, generateLean, unknownRoleFindings, unknownTrustFindings, } from "@proofgate-cdk/core";
|
|
7
7
|
import { extractStack } from "@proofgate-cdk/extractor";
|
|
8
|
+
import { RULE_ID, RULE_ID_POLICY_WRITE } from "@proofgate-cdk/model";
|
|
8
9
|
/**
|
|
9
10
|
* 未対応構文の理由に付ける、短いヒントです(spec proofgate-real-stack-validation, Task 12)。
|
|
10
11
|
* 文を足すだけで、理由の文と、受理・拒否の判定は変えません。ヒントは固定の区切りの後に置きます。
|
|
@@ -16,11 +17,11 @@ import { extractStack } from "@proofgate-cdk/extractor";
|
|
|
16
17
|
const HINTS = [
|
|
17
18
|
[
|
|
18
19
|
"Managed policies",
|
|
19
|
-
"ProofGate reads only the AWS managed
|
|
20
|
+
"ProofGate reads only the AWS managed policies AWSLambdaBasicExecutionRole, AWSLambdaVPCAccessExecutionRole, AmazonAPIGatewayPushToCloudWatchLogs, AmazonSSMManagedInstanceCore, AWSGlueServiceRole, AWSBackupServiceRolePolicyForBackup, and AWSBackupServiceRolePolicyForRestores. Other managed policies cannot be checked yet.",
|
|
20
21
|
],
|
|
21
22
|
[
|
|
22
23
|
"must be literal strings",
|
|
23
|
-
"ProofGate reads a Resource written as a literal, Fn::Join, the pseudo-parameters AWS::Partition, AWS::Region, AWS::AccountId, and AWS::URLSuffix, or Ref and Fn::GetAtt of a resource in the same template. Parameters, Fn::Sub, Fn::ImportValue, Fn::If, and other functions are not read. Action must be literal.",
|
|
24
|
+
"ProofGate reads a Resource written as a literal, Fn::Join, Fn::Sub without a variable map, the pseudo-parameters AWS::Partition, AWS::Region, AWS::AccountId, and AWS::URLSuffix, or Ref and Fn::GetAtt of a resource in the same template. Parameters, Fn::Sub with a variable map, Fn::ImportValue, Fn::If, and other functions are not read. Action must be literal.",
|
|
24
25
|
],
|
|
25
26
|
[
|
|
26
27
|
"IAM policy variables",
|
|
@@ -37,6 +38,11 @@ function withHint(text, reason) {
|
|
|
37
38
|
return text;
|
|
38
39
|
return `${text}${text.endsWith(".") ? "" : "."} Hint: ${hint}`;
|
|
39
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* このパッケージのpackage.jsonにある版です。CDKのレポートに表示する版を、公開する版と一致させます。
|
|
43
|
+
* The version in this package's package.json, so that the CDK report shows the published version.
|
|
44
|
+
*/
|
|
45
|
+
const PACKAGE_VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
40
46
|
/**
|
|
41
47
|
* 合成済みCloudFormationを検査し、CDK標準のValidation Reportを返します。
|
|
42
48
|
*/
|
|
@@ -44,8 +50,8 @@ export class ProofGateValidator {
|
|
|
44
50
|
props;
|
|
45
51
|
/** プラグイン名、ルールID、バージョンはCDKレポートに表示されます。 */
|
|
46
52
|
name = "ProofGate";
|
|
47
|
-
ruleIds = ["PG-IAM-003",
|
|
48
|
-
version =
|
|
53
|
+
ruleIds = ["PG-IAM-003", RULE_ID, RULE_ID_POLICY_WRITE];
|
|
54
|
+
version = PACKAGE_VERSION;
|
|
49
55
|
leanDirectory;
|
|
50
56
|
// undefinedは未実行、nullは成功、文字列は失敗診断を表します。同じsynth中の再ビルドを避けます。
|
|
51
57
|
leanBuildError;
|
|
@@ -119,6 +125,43 @@ export class ProofGateValidator {
|
|
|
119
125
|
}
|
|
120
126
|
if (!extraction.model)
|
|
121
127
|
continue;
|
|
128
|
+
// IAMリソースのないテンプレートは、検査するプリンシパルがないため、評価もLeanも実行せず、何も報告しません。
|
|
129
|
+
// 中身が空の証明を「証明済み」として扱わないためです(spec proofgate-brushup, 要件3)。
|
|
130
|
+
// No IAM resource: there is no principal to check, so neither the evaluator nor Lean runs and nothing is reported.
|
|
131
|
+
if (extraction.model.roles.length === 0)
|
|
132
|
+
continue;
|
|
133
|
+
// 渡せて保護バケットに届くロールが、起動アクションの表にないサービスを信頼しているときは、PG-IAM-003にします(design 5.4)。
|
|
134
|
+
// A passable, bucket-reaching role that trusts a service not in the launch table is reported as PG-IAM-003.
|
|
135
|
+
for (const finding of unknownTrustFindings(extraction.model, this.props)) {
|
|
136
|
+
violations.push({
|
|
137
|
+
ruleName: "PG-IAM-003",
|
|
138
|
+
description: `Unsupported IAM syntax: ${finding.reason}`,
|
|
139
|
+
fix: "Check whether this service can run code with the role, remove iam:PassRole for the role, or prevent the role from accessing the protected bucket.",
|
|
140
|
+
violatingResources: [
|
|
141
|
+
{
|
|
142
|
+
resourceLogicalId: logicalIdFromPath(finding.sourcePath),
|
|
143
|
+
templatePath,
|
|
144
|
+
locations: [finding.sourcePath],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// ロールを特定できないリソースを、主体が変更できるときは、PG-IAM-003にします(spec proofgate-implicit-role-paths, 設計6)。
|
|
150
|
+
// A resource whose role cannot be identified, and that a principal can change, is reported as PG-IAM-003.
|
|
151
|
+
for (const finding of unknownRoleFindings(extraction.model, this.props)) {
|
|
152
|
+
violations.push({
|
|
153
|
+
ruleName: "PG-IAM-003",
|
|
154
|
+
description: `Unsupported IAM syntax: ${finding.reason}`,
|
|
155
|
+
fix: "Give the resource a role of the same template (Fn::GetAtt of its Arn), or remove the permission to change it from every principal.",
|
|
156
|
+
violatingResources: [
|
|
157
|
+
{
|
|
158
|
+
resourceLogicalId: logicalIdFromPath(finding.sourcePath),
|
|
159
|
+
templatePath,
|
|
160
|
+
locations: [finding.sourcePath],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
}
|
|
122
165
|
const findings = evaluate(extraction.model, this.props);
|
|
123
166
|
const leanSource = generateLean(extraction.model, this.props);
|
|
124
167
|
const leanResult = this.runLean(leanSource);
|
|
@@ -151,7 +194,11 @@ export class ProofGateValidator {
|
|
|
151
194
|
violations.push({
|
|
152
195
|
ruleName: finding.ruleId,
|
|
153
196
|
description: finding.explanation,
|
|
154
|
-
fix:
|
|
197
|
+
fix: finding.ruleId === "PG-IAM-005"
|
|
198
|
+
? `Remove the permission to write IAM (iam:PutRolePolicy, iam:AttachRolePolicy, iam:UpdateAssumeRolePolicy, iam:CreateRole) from ${finding.principalLogicalId}, scope its Resource to roles that cannot reach the protected bucket, or list ${finding.principalLogicalId} in allowedPolicyWriters if it writes IAM on purpose.`
|
|
199
|
+
: finding.resourceLogicalId === undefined
|
|
200
|
+
? `Remove iam:PassRole or the launch action from ${finding.principalLogicalId}, remove the service from the trust policy of ${finding.targetRoleLogicalId}, or prevent that role from accessing the protected bucket.`
|
|
201
|
+
: `Remove the permission to change ${finding.resourceLogicalId} from ${finding.principalLogicalId}, scope it to resources whose role cannot reach the protected bucket, prevent ${finding.targetRoleLogicalId} from accessing the protected bucket, or list ${finding.targetRoleLogicalId} in allowedPassRoleTargets if the team accepts it.`,
|
|
155
202
|
violatingResources: [
|
|
156
203
|
{
|
|
157
204
|
resourceLogicalId: finding.principalLogicalId,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAwB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQ3F;;;;;;;GAOG;AACH,MAAM,KAAK,GAA2C;IACpD;QACE,kBAAkB;QAClB,mUAAmU;KACpU;IACD;QACE,yBAAyB;QACzB,yWAAyW;KAC1W;IACD;QACE,sBAAsB;QACtB,kFAAkF;KACnF;CACF,CAAC;AACF,2DAA2D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AG,SAAS,CAAC;QAChC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;CACF;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC;AACxC,CAAC"}
|
|
@@ -9,8 +9,10 @@ Leanで判定できる小さな有限モデルとして表現します。
|
|
|
9
9
|
-/
|
|
10
10
|
|
|
11
11
|
/--
|
|
12
|
-
あるIAM
|
|
13
|
-
|
|
12
|
+
あるIAMプリンシパルから、ロールを渡せる起動サービス(Lambda、ECS、EC2など)を経由して
|
|
13
|
+
保護対象リソースへ到達する権限昇格経路の候補です。
|
|
14
|
+
A candidate escalation path from an IAM principal, through a launch service that receives a passed role
|
|
15
|
+
(Lambda, ECS, EC2, and others), to a protected resource.
|
|
14
16
|
|
|
15
17
|
この構造体自体は経路が危険かどうかを断定しません。
|
|
16
18
|
4つの条件をすべて満たすかどうかは`ProofGate.isEscalation`が判定します。
|
|
@@ -18,18 +20,68 @@ Leanで判定できる小さな有限モデルとして表現します。
|
|
|
18
20
|
structure EscalationPath where
|
|
19
21
|
/-- 権限昇格の起点となるIAMプリンシパルのLogical ID。 -/
|
|
20
22
|
principal : String
|
|
21
|
-
/-- `iam:PassRole
|
|
23
|
+
/-- `iam:PassRole`で起動サービスへ渡される対象ロールのLogical ID。 -/
|
|
22
24
|
target : String
|
|
23
25
|
/-- アプリケーション設定で指定された保護対象リソース。 -/
|
|
24
26
|
protectedResource : String
|
|
27
|
+
/-- 経路が通る起動サービスのサービスプリンシパル(例: `lambda.amazonaws.com`)。説明用で、判定には使いません。
|
|
28
|
+
The service principal of the launch service on this path. For explanation only; not used by the decision. -/
|
|
29
|
+
service : String
|
|
25
30
|
/-- 起点プリンシパルが対象ロールを渡せる場合にtrue。 -/
|
|
26
31
|
canPassRole : Bool
|
|
27
|
-
/--
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
/-- 起点プリンシパルが、このサービスへロールを渡す起動アクションを持つ場合にtrue(以前の`canControlLambda`)。
|
|
33
|
+
True if the principal holds a launch action that hands a role to this service (was `canControlLambda`). -/
|
|
34
|
+
canLaunch : Bool
|
|
35
|
+
/-- 対象ロールのTrust Policyが、このサービスによる引き受けを許可する場合にtrue(以前の`targetIsLambdaAssumable`)。
|
|
36
|
+
True if the target role's trust policy lets this service assume it (was `targetIsLambdaAssumable`). -/
|
|
37
|
+
targetTrustsService : Bool
|
|
31
38
|
/-- 対象ロールが保護対象リソースへアクセスできる場合にtrue。 -/
|
|
32
39
|
targetCanAccess : Bool
|
|
33
40
|
deriving Repr, DecidableEq
|
|
34
41
|
|
|
42
|
+
/--
|
|
43
|
+
`iam:PassRole`を使わない経路の候補です。主体Pが、すでにロールTで動いているリソースRを変更でき、Tが保護対象リソースへ
|
|
44
|
+
アクセスできる場合に、危険な経路になります(spec proofgate-implicit-role-paths)。
|
|
45
|
+
`canPassRole`は持ちません。PassRoleのない経路に`canPassRole := true`と書くと、事実と違うためです。
|
|
46
|
+
A candidate path without `iam:PassRole`: principal P can change resource R, which already runs as role T, and T can access
|
|
47
|
+
the protected resource. There is no `canPassRole` field: it would be false to write `true` for a path with no PassRole.
|
|
48
|
+
-/
|
|
49
|
+
structure ImplicitPath where
|
|
50
|
+
/-- 起点となるIAMプリンシパルのLogical ID。 -/
|
|
51
|
+
principal : String
|
|
52
|
+
/-- 変更されるリソース(Lambda関数など)のLogical ID。 -/
|
|
53
|
+
resource : String
|
|
54
|
+
/-- そのリソースが引き受けているロールのLogical ID。 -/
|
|
55
|
+
target : String
|
|
56
|
+
/-- アプリケーション設定で指定された保護対象リソース。 -/
|
|
57
|
+
protectedResource : String
|
|
58
|
+
/-- 起点プリンシパルが、このリソースを変更する表のアクションを、このリソースに対して持つ場合にtrue。 -/
|
|
59
|
+
canChange : Bool
|
|
60
|
+
/-- このリソースが対象ロールで動く場合にtrue(候補はロールを特定できたリソースだけなので、常にtrueです)。 -/
|
|
61
|
+
runsAsTarget : Bool
|
|
62
|
+
/-- 対象ロールが保護対象リソースへアクセスできる場合にtrue。 -/
|
|
63
|
+
targetCanAccess : Bool
|
|
64
|
+
deriving Repr, DecidableEq
|
|
65
|
+
/--
|
|
66
|
+
ロール自身がIAMを書き換える経路の候補です(spec proofgate-self-escalation)。自分への付与、乗っ取り、作成して付与のいずれかで、
|
|
67
|
+
`shape`に名前を持ちます(説明用で、判定には使いません)。除外された組(`allowedPolicyWriters`など)も、`notExempt := false`の行として含みます。
|
|
68
|
+
A candidate path in which a role changes IAM itself (a self-grant, a take-over, or a creation grant). `shape` names it, for
|
|
69
|
+
explanation only. Exempt candidates are rows with `notExempt := false`, so that Lean checks the exemption too.
|
|
70
|
+
-/
|
|
71
|
+
structure PolicyWritePath where
|
|
72
|
+
/-- 書き換えるIAMプリンシパルのLogical ID。 -/
|
|
73
|
+
principal : String
|
|
74
|
+
/-- 書き換えられるロールのLogical ID(自分への付与と作成して付与では、プリンシパル自身)。 -/
|
|
75
|
+
target : String
|
|
76
|
+
/-- アプリケーション設定で指定された保護対象リソース。 -/
|
|
77
|
+
protectedResource : String
|
|
78
|
+
/-- 経路の形(`self-grant`、`creation-grant`、`take-over`)。説明用です。 -/
|
|
79
|
+
shape : String
|
|
80
|
+
/-- 起点プリンシパルが、この形の書き込みのアクションを、このロールに対して持つ場合にtrue。 -/
|
|
81
|
+
canWrite : Bool
|
|
82
|
+
/-- 書き込みの後に保護対象リソースへ届く場合にtrue(自分への付与と作成して付与では常にtrue。乗っ取りでは、対象ロールが今届く場合)。 -/
|
|
83
|
+
reachesAfterWrite : Bool
|
|
84
|
+
/-- 起点プリンシパルが`allowedPolicyWriters`になく、乗っ取りでは対象ロールが`allowedPassRoleTargets`にもない場合にtrue。 -/
|
|
85
|
+
notExempt : Bool
|
|
86
|
+
deriving Repr, DecidableEq
|
|
35
87
|
end ProofGate
|
|
@@ -12,15 +12,17 @@ namespace ProofGate
|
|
|
12
12
|
/--
|
|
13
13
|
候補経路が実際の権限昇格経路になるための4条件を検査します。
|
|
14
14
|
|
|
15
|
-
1.
|
|
16
|
-
2. Lambda
|
|
17
|
-
3.
|
|
15
|
+
1. 対象ロールを渡せる
|
|
16
|
+
2. 起動サービスへロールを渡す起動アクションを持つ(Lambdaでは、関数の作成または設定の更新)
|
|
17
|
+
3. 対象ロールをその起動サービスが引き受けられる
|
|
18
18
|
4. 対象ロールが保護対象リソースへアクセスできる
|
|
19
|
+
The four conditions: the role can be passed, the principal can launch the service with it,
|
|
20
|
+
the target trusts that service, and the target can access the protected resource.
|
|
19
21
|
|
|
20
22
|
4条件がすべてtrueの場合だけ、危険な経路と判定します。
|
|
21
23
|
-/
|
|
22
24
|
def isEscalation (path : EscalationPath) : Bool :=
|
|
23
|
-
path.canPassRole && path.
|
|
25
|
+
path.canPassRole && path.canLaunch && path.targetTrustsService && path.targetCanAccess
|
|
24
26
|
|
|
25
27
|
/--
|
|
26
28
|
候補経路をすべて調べ、危険な経路が1つも存在しない場合にtrueを返します。
|
|
@@ -42,16 +44,77 @@ theorem emptyModelIsSafeAtBooleanLevel : safe [] = true := by
|
|
|
42
44
|
4条件をすべて満たす経路が1つでも存在すれば、スタック全体を安全とは判定しないことを示します。
|
|
43
45
|
文字列の内容には依存せず、経路を構成する権限の組み合わせだけで結果が決まります。
|
|
44
46
|
-/
|
|
45
|
-
theorem completeEscalationIsUnsafe (principal target resource : String) :
|
|
47
|
+
theorem completeEscalationIsUnsafe (principal target resource service : String) :
|
|
46
48
|
safe [{
|
|
47
49
|
principal := principal
|
|
48
50
|
target := target
|
|
49
51
|
protectedResource := resource
|
|
52
|
+
service := service
|
|
50
53
|
canPassRole := true
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
canLaunch := true
|
|
55
|
+
targetTrustsService := true
|
|
53
56
|
targetCanAccess := true
|
|
54
57
|
}] = false := by
|
|
55
58
|
simp [safe, isEscalation]
|
|
56
59
|
|
|
60
|
+
/--
|
|
61
|
+
PassRoleの要らない候補経路が、危険な経路になる3条件の論理積です。
|
|
62
|
+
The conjunction of the three conditions of a path without `iam:PassRole`.
|
|
63
|
+
-/
|
|
64
|
+
def isImplicitEscalation (path : ImplicitPath) : Bool :=
|
|
65
|
+
path.canChange && path.runsAsTarget && path.targetCanAccess
|
|
66
|
+
/-- PassRoleの要らない候補経路がすべて安全のときにtrueを返します。 -/
|
|
67
|
+
def safeImplicit (paths : List ImplicitPath) : Bool :=
|
|
68
|
+
paths.all fun path => !(isImplicitEscalation path)
|
|
69
|
+
/-- 空リストに対するBoolean関数の基本性質です。空のモデルを安全と認めるという意味ではありません。 -/
|
|
70
|
+
theorem emptyImplicitModelIsSafeAtBooleanLevel : safeImplicit [] = true := by
|
|
71
|
+
native_decide
|
|
72
|
+
/-- 3条件をすべて満たす経路が1つでもあれば、安全とは判定しません。 -/
|
|
73
|
+
theorem completeImplicitEscalationIsUnsafe (principal resource target protectedResource : String) :
|
|
74
|
+
safeImplicit [{
|
|
75
|
+
principal := principal
|
|
76
|
+
resource := resource
|
|
77
|
+
target := target
|
|
78
|
+
protectedResource := protectedResource
|
|
79
|
+
canChange := true
|
|
80
|
+
runsAsTarget := true
|
|
81
|
+
targetCanAccess := true
|
|
82
|
+
}] = false := by
|
|
83
|
+
simp [safeImplicit, isImplicitEscalation]
|
|
84
|
+
/--
|
|
85
|
+
IAMを書き換える候補経路が、危険な経路になる3条件の論理積です(書き込める、書き込みの後に届く、除外されていない)。
|
|
86
|
+
The conjunction of the three conditions of a policy-write path.
|
|
87
|
+
-/
|
|
88
|
+
def isPolicyWriteEscalation (path : PolicyWritePath) : Bool :=
|
|
89
|
+
path.canWrite && path.reachesAfterWrite && path.notExempt
|
|
90
|
+
/-- IAMを書き換える候補経路がすべて安全のときにtrueを返します。 -/
|
|
91
|
+
def safePolicyWrite (paths : List PolicyWritePath) : Bool :=
|
|
92
|
+
paths.all fun path => !(isPolicyWriteEscalation path)
|
|
93
|
+
/-- 空リストに対するBoolean関数の基本性質です。空のモデルを安全と認めるという意味ではありません。 -/
|
|
94
|
+
theorem emptyPolicyWriteModelIsSafeAtBooleanLevel : safePolicyWrite [] = true := by
|
|
95
|
+
native_decide
|
|
96
|
+
/-- 3条件をすべて満たす経路が1つでもあれば、安全とは判定しません。 -/
|
|
97
|
+
theorem completePolicyWriteEscalationIsUnsafe (principal target protectedResource shape : String) :
|
|
98
|
+
safePolicyWrite [{
|
|
99
|
+
principal := principal
|
|
100
|
+
target := target
|
|
101
|
+
protectedResource := protectedResource
|
|
102
|
+
shape := shape
|
|
103
|
+
canWrite := true
|
|
104
|
+
reachesAfterWrite := true
|
|
105
|
+
notExempt := true
|
|
106
|
+
}] = false := by
|
|
107
|
+
simp [safePolicyWrite, isPolicyWriteEscalation]
|
|
108
|
+
/-- 除外された経路は、ほかの2条件が成り立っていても、危険とは判定しません。 -/
|
|
109
|
+
theorem exemptPolicyWriteIsSafe (principal target protectedResource shape : String) :
|
|
110
|
+
safePolicyWrite [{
|
|
111
|
+
principal := principal
|
|
112
|
+
target := target
|
|
113
|
+
protectedResource := protectedResource
|
|
114
|
+
shape := shape
|
|
115
|
+
canWrite := true
|
|
116
|
+
reachesAfterWrite := true
|
|
117
|
+
notExempt := false
|
|
118
|
+
}] = true := by
|
|
119
|
+
simp [safePolicyWrite, isPolicyWriteEscalation]
|
|
57
120
|
end ProofGate
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proofgate-cdk/cdk-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Lean-powered AWS CDK policy validation plugin for application-specific IAM safety rules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@proofgate-cdk/core": "^1.
|
|
52
|
-
"@proofgate-cdk/
|
|
53
|
-
"@proofgate-cdk/
|
|
51
|
+
"@proofgate-cdk/core": "^1.2.0",
|
|
52
|
+
"@proofgate-cdk/model": "^1.2.0",
|
|
53
|
+
"@proofgate-cdk/extractor": "^1.2.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"aws-cdk-lib": "^2.277.0"
|