Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# D1 — OpenAI Integration

**Family:** Dependency / Integration Drift
**Baseline:** `text-paste-service/v1` · **Stack:** `TextPasteServiceStack-dev`

An OpenAI key is stored (C2, benign) and used by the notification handler for async classification (C4, Mild). Four commits later the ticket creator calls OpenAI inline on every create, sending the raw ticket body (C8, Severe).

> R1-R5 are independent parallel evolutions of the same v1 stack. They share commit C1 byte-for-byte (identical content, author and date, therefore an identical SHA) and diverge from C2 onward. No benchmark depends on any other; each is a separate hypothesis about how v1 could have evolved.

## Severity axis

Which execution path the third-party call sits on.

- `commit_severity` — drift introduced BY THIS COMMIT
- `cumulative_severity` — standing risk of the tree AT THIS COMMIT

## Commits

| Commit | SHA | Label | Commit sev | Cumulative | Resources | Template diff |
|--------|-----|-------|-----------|------------|-----------|---------------|
| C1 | `99c3992` | V1 | None | None | 85 | — |
| C2 | `4b4d82d` | VB | None | None | 86 | 19 |
| C3 | `c479122` | VB | None | None | 90 | 84 |
| C4 | `0e69f04` | V2 | **Mild** | Mild | 90 | **6** |
| C5 | `945c35e` | VB | None | Mild | 90 | 793 |
| C6 | `a6cf470` | VB | None | Mild | 90 | 52 |
| C7 | `e598233` | VB | None | Mild | 90 | 2 |
| C8 | `b66efc0` | V3 | **Severe** | Severe | 90 | **5** |
| C9 | `b753654` | VB | None | Severe | 90 | **0** |
| C10 | `2f1e5d3` | VB | None | Severe | 90 | **0** |

Template diff is measured against the preceding commit's synthesized CloudFormation,
normalized and sorted, counting changed lines.

### Diff size versus severity

The largest benign template diff in this benchmark is **C5 at 793 lines**.
The smallest drift-bearing diff is **C8 at 5 lines**.
Triaging by diff magnitude ranks them backwards.

## Control state per commit

| Commit | API methods (cognito/none) | Authorizers | Other controls |
|--------|---------------------------|-------------|----------------|
| C1 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C2 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C3 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C4 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C5 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C6 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C7 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C8 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C9 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |
| C10 | 0/0 | 1 | ALB=internal, **ingress 0.0.0.0/0** |

## Drift commits — ground truth

### C4 — V2, Mild

`feat: classify tickets via openai on the notification path`

- **Mechanism:** `third_party_egress_async`
- **Path:** `NotificationHandlerLambda -> api.openai.com (derived labels)`
- **Controls present:** AsyncPathOnly, DerivedDataOnly
- **Component:** `NotificationHandlerLambda`
- **Transitive reach:** outbound to vendor from notification path
- **Template assertion:** notification handler env gains OPENAI_*; secret granted to the lambda role

First egress to a third party; async, derived data only. Mild.

### C8 — V3, Severe

`feat: classify tickets inline on create`

- **Mechanism:** `third_party_on_critical_path`
- **Path:** `Internet -> ApiGateway[POST /tickets] -> TicketCreatorLambda -> api.openai.com (raw body)`
- **Controls present:** none
- **Controls removed:** AsyncPathOnly, DerivedDataOnly
- **Component:** `TicketCreatorLambda`
- **Transitive reach:** raw ticket bodies leave the account on every create
- **Template assertion:** creator env gains OPENAI_SEND_BODY and OPENAI_TIMEOUT_MS

Two escalations: raw-data disclosure + vendor becomes an availability dependency of creates.


## Benign commits — why each is a probe

- **C2** `feat: store openai api key in secrets manager` — adds a secret + grant; a detector keying on secret creation fires one commit early
- **C3** `chore: add cloudwatch error alarms on lambdas` — no dependency change
- **C5** `chore: apply cost-allocation tags` — largest template diff
- **C6** `feat: add byStatus index on ticket table` — table churn
- **C7** `chore: raise rds backup retention floor` — unrelated hardening
- **C9** `docs: add ops runbook` — no new drift while cumulative Severe
- **C10** `docs: annotate enrichment behavior` — docs-only append

## Baseline weaknesses

Present at C1. Flagging any of these as drift is a false positive, not a detection.

- lambdas have unrestricted egress at C1
- frontendSg 0.0.0.0/0 at C1

## Scoring

- **Drift commits:** C4, C8
- **Benign commits:** C2, C3, C5, C6, C7, C9, C10
- **False-positive probes:** C2, C5

- **State-vs-event probes:** C5, C6, C7, C9, C10

Pairs with paste D1 and ECS D1.

## Layout

```
D1/
├── repository/ real working tree + real .git (git log/diff/show all work)
├── commits/
│ ├── C1..C7/
│ │ ├── cdk/ same layout as <app>/v1/cdk/ in the source dataset
│ │ │ ├── cdk.ts
│ │ │ ├── cdk.json
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ ├── lambda/index.js
│ │ │ └── cdk.out/ synthesized template, tree.json, manifests
│ │ ├── commit.json sha, parent, author, label, severities, diffstat
│ │ └── diff.patch diff against parent (empty for C1)
│ └── provenance.json synth version and resource count per commit
├── metadata.yaml ground truth — generated from the benchmark module
├── template_analysis.json measured diffs and control state per commit
└── README.md this file
```

## Regenerating

```
python3 generators/build.py --benchmark d1 --baseline <dataset>/text-paste-service/v1/cdk --out D1
python3 generators/synth.py --root D1 --workbench /tmp/wb
python3 generators/analyze.py --root D1
python3 generators/verify.py --benchmark d1 --root D1
```

Author identity and commit dates are pinned, so SHAs are reproducible from the same
baseline. `metadata.yaml` is generated from `generators/benchmarks/d1.py`, which is
the single source of truth for this benchmark.

## Synth provenance

All templates synthesized with `aws-cdk-lib` **2.150.0**,
account `111122223333`, region `us-east-1`.

**Version caveat:** C1, C10, C2, C3, C4, C5, C6, C7, C8, C9 declare a different aws-cdk-lib version in package.json than the one that synthesized them (2.100.0 would not install in the build environment). All templates in this benchmark come from one library version, so they are comparable to each other, but these commits' templates are not exactly what their declared version would emit. Recorded per commit in `commits/provenance.json`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
{
"app": "npx ts-node --prefer-ts-exts --transpile-only cdk.ts",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImIdForAutoScallingGroup": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true",
"env": "dev",
"dev": {
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"databaseInstanceType": "t3.micro",
"frontendInstanceType": "t3.micro",
"frontendMinCapacity": 1,
"frontendMaxCapacity": 2
},
"prod": {
"vpcCidr": "10.1.0.0/16",
"maxAzs": 3,
"databaseInstanceType": "m5.large",
"frontendInstanceType": "m5.large",
"frontendMinCapacity": 2,
"frontendMaxCapacity": 10
},
"featureFlags": {},
"environments": {
"dev": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"development": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"staging": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"test": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"prod": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"production": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
}
},
"development": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"production": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"staging": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"test": {
"account": "123456789012",
"region": "us-east-1",
"logRetentionDays": 30,
"vpcCidr": "10.0.0.0/16",
"maxAzs": 2,
"dbUsername": "admin",
"rdsInstanceType": "t3.medium",
"emrReleaseLabel": "emr-6.9.0",
"emrMasterInstanceType": "m5.xlarge",
"emrCoreInstanceType": "m5.xlarge",
"cacheNodeType": "cache.t3.micro",
"removalPolicy": "retain"
},
"account": "123456789012",
"region": "us-east-1",
"domainName": "example.com",
"adminPanelDomain": "admin.example.com",
"sesVerifiedIdentity": "admin@example.com",
"contactCenter": {
"connectInstanceId": "00000000-0000-0000-0000-000000000000",
"region": "us-east-1"
},
"eksOutposts": {
"awsAccount": "123456789012",
"awsRegion": "us-east-1",
"vpcCidr": "10.0.0.0/16",
"outpostArn": "arn:aws:outposts:us-east-1:123456789012:outpost/op-12345678"
},
"availability-zones:account=123456789012:region=us-east-1": [
"us-east-1a",
"us-east-1b",
"us-east-1c"
]
},
"tags": {
"project": "SupportTicketingSystem",
"environment": "dev",
"department": "Support"
},
"featureFlags": {
"enableSsoIntegration": true,
"enableKmsEncryption": true
},
"env": {
"account": "123456789012",
"region": "us-east-1"
}
}
Loading