Skip to content

Commit f67a395

Browse files
committed
fix: validate universe domain input to prevent SSRF credential leak
1 parent ab10d6b commit f67a395

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ async function run() {
4949
const region = presence(getInput('region')) || 'us-central1';
5050
const universe = getInput('universe') || 'googleapis.com';
5151

52+
// Validate universe to prevent SSRF: an attacker-controlled value is
53+
// interpolated into the Cloud Functions endpoint URL, routing credentials
54+
// to an arbitrary host. Only googleapis.com and its subdomains are valid.
55+
if (!/^([a-z0-9-]+\.)*googleapis\.com$/.test(universe)) {
56+
throw new Error(
57+
`Invalid universe domain "${universe}": must be "googleapis.com" or a valid ` +
58+
`Trusted Partner Cloud subdomain (e.g. "us-central1.rep.googleapis.com").`,
59+
);
60+
}
61+
5262
// top-level inputs
5363
const name = getInput('name', { required: true });
5464
const description = presence(getInput('description'));

0 commit comments

Comments
 (0)