Skip to content

Commit 3dc2604

Browse files
authored
Make the allowlisted DB host SSRF test independent of DNS (#1547)
1 parent 6dc1870 commit 3dc2604

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎packages/backend/src/connectors/engines/database.engine.ssrf.spec.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ describe('DatabaseEngine — SSRF guard', () => {
6060
});
6161

6262
it('allows a blocked host when explicitly allowlisted', async () => {
63-
process.env.SSRF_ALLOWED_HOSTS = 'db.internal';
64-
// Passes the SSRF guard (allowlisted) → fails later on the actual connection,
65-
// never with SsrfBlockedError.
63+
// Loopback is blocked by default; the allowlist lets it through. Port 1 is
64+
// closed, so the driver fails at once with ECONNREFUSED (no DNS lookup and
65+
// no connect timeout, which made a hostname like db.internal flaky in CI).
66+
process.env.SSRF_ALLOWED_HOSTS = '127.0.0.1';
6667
await expect(
67-
engine.execute(cfg('postgres://u:p@db.internal:5432/db'), query, params),
68+
engine.execute(cfg('postgres://u:p@127.0.0.1:1/db'), query, params),
6869
).rejects.not.toBeInstanceOf(SsrfBlockedError);
6970
});
7071

0 commit comments

Comments
 (0)