Skip to content
Closed
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
8 changes: 8 additions & 0 deletions review-enrichment/src/analyzers/iac-misconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ const COOP_UNSAFE_NONE_RE =
/\bCross-Origin-Opener-Policy\b[^\n]*\bunsafe-none\b/i;
const COEP_UNSAFE_NONE_RE =
/\bCross-Origin-Embedder-Policy\b[^\n]*\bunsafe-none\b/i;
const CORP_UNSAFE_NONE_RE =
/\bCross-Origin-Resource-Policy\b[^\n]*\bunsafe-none\b/i;

function* patchLines(patch: string): Generator<string> {
let start = 0;
Expand Down Expand Up @@ -557,6 +559,12 @@ export function scanPatchForIacMisconfig(
) {
return findings;
}
if (
CORP_UNSAFE_NONE_RE.test(body) &&
pushFinding(findings, seen, path, newLine, "corp-unsafe-none", maxFindings)
) {
return findings;
}

newLine++;
}
Expand Down
2 changes: 2 additions & 0 deletions review-enrichment/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ export function renderBrief(
return "sets `Cross-Origin-Opener-Policy: unsafe-none`, allowing cross-origin pages to retain opener access";
case "coep-unsafe-none":
return "sets `Cross-Origin-Embedder-Policy: unsafe-none`, disabling cross-origin isolation requirements for embedded resources";
case "corp-unsafe-none":
return "sets `Cross-Origin-Resource-Policy: unsafe-none`, allowing any origin to load this resource without isolation";
}
};

Expand Down
3 changes: 2 additions & 1 deletion review-enrichment/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ export interface IacMisconfigFinding {
| "referrer-policy-leak"
| "cookie-not-httponly"
| "coop-unsafe-none"
| "coep-unsafe-none";
| "coep-unsafe-none"
| "corp-unsafe-none";
}

/** A newly-added dependency whose install compiles native code (npm node-gyp addon) or has no prebuilt wheel
Expand Down
4 changes: 3 additions & 1 deletion review-enrichment/test/iac-misconfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ test("scanPatchForIacMisconfig flags insecure HTTP security-header settings", ()
["+ httpOnly: false", "cookie-not-httponly"],
["+ add_header Cross-Origin-Opener-Policy \"unsafe-none\";", "coop-unsafe-none"],
["+ add_header Cross-Origin-Embedder-Policy \"unsafe-none\";", "coep-unsafe-none"],
["+ add_header Cross-Origin-Resource-Policy \"unsafe-none\";", "corp-unsafe-none"],
];
for (const [added, kind] of cases) {
const findings = scanPatchForIacMisconfig(
Expand All @@ -486,7 +487,8 @@ test("scanPatchForIacMisconfig does not flag secure HTTP header values (incl. Ca
"+ httpOnly: true",
"+ add_header Cross-Origin-Opener-Policy \"same-origin\";",
"+ add_header Cross-Origin-Embedder-Policy \"require-corp\";",
// A bare `unsafe-none` config key without a COOP/COEP header token must NOT fire either rule.
"+ add_header Cross-Origin-Resource-Policy \"same-origin\";",
// A bare `unsafe-none` config key without a COOP/COEP/CORP header token must NOT fire any of those rules.
"+ unsafe-none = false",
];
for (const added of safe) {
Expand Down
Loading