Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(redact): mask temporary AWS access key IDs (ASIA)

kevinc745e178bc77
diff --git a/server/redact.test.ts b/server/redact.test.ts
index c40e89d569..7297f5a47e 100644
--- a/server/redact.test.ts
+++ b/server/redact.test.ts
@@ -143,6 +143,7 @@ describe("redactSecretsInText", () => {
[`fine-grained ${"github_" + "pat_"}11ABCDEFG0${alpha}`, /github_pat_/],
[`slack ${"xox" + "b-"}${"123456789012"}-${"1234567890123"}-${alpha.slice(0, 24)}`, /xoxb-/],
[`aws ${"AKIA" + "IOSFODNN7EXAMPLE"} and more`, /IOSFODNN7EXAMPLE/],
+ [`aws temporary ${"ASIA" + "IOSFODNN7EXAMPLE"} and more`, /IOSFODNN7EXAMPLE/],
[`google ${"AIza" + "SyA-"}${alpha.slice(0, 32)}`, /AIza/],
[`npm ${"npm" + "_"}${alpha}`, /npm_[a-z]/],
[`xai ${"xai-"}${alpha}`, /xai-/],
@@ -290,7 +291,7 @@ describe("holdsCredential", () => {
it("knows a provider key or a private key block, never a name, a placeholder or code that reads one", () => {
for (const text of [
'{"apiKey": "sk-ant-api03-0123456789abcdefABCD"}', "GITHUB_TOKEN=ghp_0123456789abcdefghij0123", "-----BEGIN OPENSSH PRIVATE KEY-----\nabc\n",
- "aws_access_key_id = AKIAABCDEFGHIJKLMNOP", `git clone https://oauth2:${"glp" + "at-"}[email protected]/x.git`, `runner token ${"glr" + "tr-"}0123456789abcdefABCD`, `stripe.secret = "${"sk_" + "live_"}0123456789abcdefABCD"`,
+ "aws_access_key_id = AKIAABCDEFGHIJKLMNOP", `temporary aws key ${"ASIA" + "ABCDEFGHIJKLMNOP"}`, `git clone https://oauth2:${"glp" + "at-"}[email protected]/x.git`, `runner token ${"glr" + "tr-"}0123456789abcdefABCD`, `stripe.secret = "${"sk_" + "live_"}0123456789abcdefABCD"`,
]) expect(holdsCredential(text), text).toBe(true);
for (const text of [
"token = os.environ['GITHUB_TOKEN']", "API_KEY=your-key-here", "Authorization: Bearer YOUR_TOKEN_HERE", "Keep credentials out of the repo.",
diff --git a/shared/redact.ts b/shared/redact.ts
index dc3be7ef51..d07e415d15 100644
--- a/shared/redact.ts
+++ b/shared/redact.ts
@@ -26,7 +26,7 @@ const KEY_PREFIXES: RegExp[] = [
/\bgithub_pat_[A-Za-z0-9_]{20,}/g, // github fine-grained
/\bgl(?:pat|dt|rtr?)-[A-Za-z0-9_-]{20,}(?:\.[A-Za-z0-9_-]+)*/g, // gitlab personal, deploy and runner tokens (routable ones carry .-parts)
/\bxox[abposr]-[A-Za-z0-9-]{20,}/g, // slack
- /\bAKIA[0-9A-Z]{16}\b/g, // aws access key id
+ /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g, // aws access key id, long-term (AKIA) or temporary STS (ASIA)
/\bAIza[0-9A-Za-z_-]{30,}/g, // google api key
/\bnpm_[A-Za-z0-9]{20,}/g, // npm
/\bwhsec_[A-Za-z0-9_-]{20,}/g, // webhook secrets, alone or in an automation's address