Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions infra/cfn/coderhelm-log-reader-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ Resources:
- "ecr:BatchGetImage"
- "ecr:ListTagsForResource"
Resource: "*"
# When an AWS WAF alarm fires: which web ACL it watches, the
# requests its rule matched (WAF's sampled requests) and where the
# web ACL logs. Only user agents, accept languages, header names, paths and countries
# are kept; never client addresses, cookies or other header values.
- Sid: ReadFirewallRequests
Effect: Allow
Action:
- "wafv2:ListWebACLs"
- "wafv2:GetSampledRequests"
- "wafv2:GetLoggingConfiguration"
Resource: "*"
# Settings only, so a review can check a fact instead of asking: a
# bucket's default encryption, its bucket policy and whether that
# policy makes it public; a KMS key's description and key policy.
Expand Down
17 changes: 17 additions & 0 deletions infra/cfn/coderhelm-log-reader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@ Resources:
- "ecr:BatchGetImage"
- "ecr:ListTagsForResource"
Resource: "*"
- PolicyName: FirewallRequestsReadOnly
PolicyDocument:
Version: "2012-10-17"
Statement:
# When an AWS WAF alarm fires: which web ACL it watches, the
# requests its rule matched (WAF's sampled requests) and where
# the web ACL logs, so a fix to the rule is based on what
# clients sent. CoderHelm keeps only user agents, header names,
# paths and countries from them; never client addresses,
# cookies or other header values. Nothing is changed.
- Sid: ReadFirewallRequests
Effect: Allow
Action:
- "wafv2:ListWebACLs"
- "wafv2:GetSampledRequests"
- "wafv2:GetLoggingConfiguration"
Resource: "*"
- PolicyName: BucketAndKeySettingsReadOnly
PolicyDocument:
Version: "2012-10-17"
Expand Down
5 changes: 5 additions & 0 deletions infra/lib/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ export const BOUNDARY_SERVICES = [
"ecs:List*",
"ecr:BatchGetImage",
"ecr:List*",
// The requests an AWS WAF alarm's rule matched and where its web ACL logs
// (ListWebACLs, GetSampledRequests, GetLoggingConfiguration), read-only. It
// reaches an install only through the access stack an AWS admin applies.
"wafv2:Get*",
"wafv2:List*",
"apigateway:*",
// Infrastructure vulnerabilities, Amazon Inspector findings and AWS Health
// events in the install's own account: the reads only a switch of the AWS
Expand Down
2 changes: 1 addition & 1 deletion infra/scripts/deploy-role-sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
SERVICE_OF = {"ApiGatewayV2": "apigateway", "CertificateManager": "acm", "CloudFront": "cloudfront", "CloudWatch": "cloudwatch", "CodeBuild": "codebuild",
"Cognito": "cognito-idp", "DynamoDB": "dynamodb", "Events": "events", "IAM": "iam", "KMS": "kms", "Lambda": "lambda", "Logs": "logs",
"Route53": "route53", "S3": "s3", "SES": "ses", "SNS": "sns", "SQS": "sqs", "SSM": "ssm", "Scheduler": "scheduler",
"SecretsManager": "secretsmanager", "CloudFormation": "cloudformation"}
"SecretsManager": "secretsmanager", "CloudFormation": "cloudformation", "EC2": "ec2"}

SYNTH_JS = r"""
const fs = require("fs"), os = require("os"), path = require("path");
Expand Down
5 changes: 3 additions & 2 deletions infra/test/access.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ test("boundary: fits IAM's managed policy limit (6,144 characters without whites
const size = JSON.stringify(BOUNDARY).length;
// Measured with the longest names an install can have (a 20-character stage).
// About 140 characters to spare since Inspector's and Health's reads (own-account-read.ts, OWN_OPTIONS),
// about 60 since the private networks' (BOUNDARY_OPTION_READS.PrivateNetworks). Under 6,144 is IAM's own refusal.
assert.ok(size < 6100, `boundary is ${size} characters`);
// about 60 since the private networks' (BOUNDARY_OPTION_READS.PrivateNetworks), about 25 since AWS WAF's
// reads (wafv2:Get*, wafv2:List*), which leaves about 20. Under 6,144 is IAM's own refusal.
assert.ok(size < 6125, `boundary is ${size} characters`);
});

test("boundary: only the deploy role may set or remove the gateway and worker tag", () => {
Expand Down
2 changes: 2 additions & 0 deletions infra/test/fixtures/deploy-role.json
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,8 @@
"ecs:List*",
"ecr:BatchGetImage",
"ecr:List*",
"wafv2:Get*",
"wafv2:List*",
"apigateway:*",
"autoscaling:Describe*",
"ec2:DescribeI*",
Expand Down
156 changes: 133 additions & 23 deletions infra/test/fixtures/native-sim.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions infra/test/native-access.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ const sha = (v: unknown) => crypto.createHash("sha256").update(canon(v)).digest(
* release notes; the dashboard then offers it as one optional item.
*/
const ACCESS_DOCS = {
// Private networks (access.ts BOUNDARY_OPTION_READS.PrivateNetworks, PRIVATE_NETWORK_DEPLOY_*).
boundary: "2a0bcf74a7dc5704294b908c9afba48626c2fbce5fbfc2dd3cf8e2b10e888154",
// Private networks (access.ts BOUNDARY_OPTION_READS.PrivateNetworks, PRIVATE_NETWORK_DEPLOY_*),
// then AWS WAF's reads for alarm investigations (wafv2:Get*, wafv2:List*).
boundary: "9b357fb381000b22452ca2a44d34bd1a61ef81bbe05755b6731250139e9e8c36",
deployRole: "c55fb9759c36f7df55c4d8d25de2ebd792238d91a144fcd82ca5e765566a5117",
};

Expand Down
4 changes: 4 additions & 0 deletions infra/test/native-sim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const REFUSED: Record<string, Verdict> = {
"logs:PutIndexPolicy": "implicitDeny",
"logs:DeleteIndexPolicy": "implicitDeny",
"logs:PutBearerTokenAuthentication": "implicitDeny",
// AWS's registry now lists these in a Lambda function's handlers for container image
// functions; every CoderHelm function is a zip, so CloudFormation never makes them.
"ecr:BatchGetImage": "implicitDeny",
"ecr:GetDownloadUrlForLayer": "implicitDeny",
};

const pairs = () => (F.rows as any[]).flatMap((r) => Object.entries(r.actions as Record<string, Verdict>).map(([action, verdict]) => ({ action, verdict, resource: r.resource, context: r.context })));
Expand Down
26 changes: 26 additions & 0 deletions services/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions services/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ aws-sdk-redshiftdata = { version = "1", default-features = false, features = ["d
aws-sdk-cloudwatchlogs = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
# live: CloudWatch metrics and Airflow (MWAA) through the team's log reader role
aws-sdk-cloudwatch = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
# alarm_evidence: what an AWS WAF alarm's rule matched (sampled requests, read-only)
aws-sdk-wafv2 = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
# log_repo: which repo a log group's code lives in (read-only lookups)
aws-sdk-ecs = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-sdk-lambda = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
Expand Down
Loading
Loading