OSV 1.4.0 · github-reviewed · 修改于 2026-07-31 05:23
发布时间
2026-07-31 00:26
GitHub 审查时间
2026-07-31 00:26
NVD 发布时间
2026-07-31 01:16
源文件
advisories/github-reviewed/2026/07/GHSA-cg4g-m8jx-vjv2/GHSA-cg4g-m8jx-vjv2.json
is_url_safe in v1.0.3 contains an SSRF bypass. remove_at_symbol_in_string is applied to the raw URL string before new URL() parses it. This strips the @ that separates userinfo from host, corrupting the hostname so internal IPs are never checked.
In helpers.ts, is_url_safe does:
u = remove_at_symbol_in_string(u); // strips ALL '@' from the raw string
// ...
const parsed = new URL(u);
const hostname = parsed.hostname; // resolved from the corrupted string
Input: http://[email protected]/
remove_at_symbol_in_string → http://evil.com127.0.0.1/new URL(...) → hostname = "evil.com127.0.0.1"is_hostname_resolve_to_internal_ip("evil.com127.0.0.1") → NXDOMAIN → returns falsetrue (safe) — but any HTTP client using the original URL connects to 127.0.0.1import nock from 'nock';
import { got } from 'got';
import { is_url_safe } from 'dssrf';
// Simulate an internal server at 10.0.0.1 that returns secret data
nock('http://10.0.0.1:80').persist().get('/').reply(200, 'SECRET_DATA');
const BYPASS_URL = 'http://[email protected]/';
const PLAIN_URL = 'http://10.0.0.1/';
// dssrf should block both — it only blocks the plain one
console.log('--- dssrf validator ---');
console.log(`is_url_safe('${PLAIN_URL}') =`, await is_url_safe(PLAIN_URL), '← correctly blocked');
console.log(`is_url_safe('${BYPASS_URL}') =`, await is_url_safe(BYPASS_URL), '← ⚠️ BYPASSED (should be false)');
// HTTP client with the bypass URL — gets SECRET_DATA back from 10.0.0.1
console.log('\n--- HTTP client ---');
try {
const res = await got(BYPASS_URL, { retry: { limit: 0 } });
console.log(`got('${BYPASS_URL}') response:`, res.body, '← ⚠️ VULNERABLE');
} catch (e) {
console.log(`got('${BYPASS_URL}') blocked:`, e.message);
}
@ in a URL separates userinfo (credentials) from host. Stripping it from the raw string before parsing destroys that boundary. The fix is to reject any URL that contains a userinfo component after parsing.
Remove the remove_at_symbol_in_string call from is_url_safe and add a userinfo check after new URL():
const parsed = new URL(u);
// Reject userinfo — '@' in authority is a classic SSRF bypass vector
if (parsed.username !== "" || parsed.password !== "") {
return false;
}
A working patch verified against 15 vectors (all internal IPv4 ranges, IMDS, IPv6 via userinfo, and legitimate public URLs) is ready to submit as a PR.
169.254.169.254), any internal hostname via userinfo prefix1.0.3) should be updated since this vector was not covered by that fixUsers are strongly advised to upgrade to dssrf 1.0.4