Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(security): bound the host length in the node oob matcher (#122955)

Tom Piccirello9bfbac633807
diff --git a/nodejs/src/common/utils/oob-domains.test.ts b/nodejs/src/common/utils/oob-domains.test.ts
index 4f9ef38d7f7b..c50f6add0f4f 100644
--- a/nodejs/src/common/utils/oob-domains.test.ts
+++ b/nodejs/src/common/utils/oob-domains.test.ts
@@ -24,6 +24,10 @@ describe('oob-domains', () => {
['an uppercase host', 'ABC.OAST.ME', 'oast.me'],
['an absolute host carrying the DNS root dot', 'abc.oast.me.', 'oast.me'],
['a host carrying more than one trailing dot', 'abc.oast.me..', 'oast.me'],
+ ['the longest name DNS carries', `${'a'.repeat(245)}.oast.me`, 'oast.me'],
+ ['the longest name with its root dot', `${'a'.repeat(245)}.oast.me.`, 'oast.me'],
+ ['a host longer than a DNS name', `${'a'.repeat(246)}.oast.me`, null],
+ ['a listed host followed by a long run of dots', `abc.oast.me${'.'.repeat(300)}`, null],
['a fullwidth host that IDNA maps onto a listed one', 'oast.me', 'oast.me'],
['a host that only ends in the same letters', 'notoast.me', null],
['a listed name used as a prefix', 'oast.me.evil.example', null],
diff --git a/nodejs/src/common/utils/oob-domains.ts b/nodejs/src/common/utils/oob-domains.ts
index 2e68c53a7244..c92744d41f40 100644
--- a/nodejs/src/common/utils/oob-domains.ts
+++ b/nodejs/src/common/utils/oob-domains.ts
@@ -56,6 +56,8 @@ function firstSightInWindow(key: string, now: number): boolean {
return true
}
+const MAX_DNS_NAME_LENGTH = 253
+
// A host of letters, digits, dots, hyphens and underscores needs no IDNA pass, because
// domainToASCII would only lowercase it.
const PLAIN_HOST_RE = /^[A-Za-z0-9._-]+$/
@@ -89,6 +91,10 @@ export function matchedOobDomain(host: string | null | undefined): string | null
if (!host || host.includes('@') || host.includes('/')) {
return null
}
+ if ((host.endsWith('.') ? host.length - 1 : host.length) > MAX_DNS_NAME_LENGTH) {
+ // A longer name never resolves, and a match keeps the host in the dedupe map and the log line.
+ return null
+ }
const canonical = canonicalizeHost(host)
if (canonical === null) {
return null