T08 · Insecure Dependencies
Error
- Location
- update.js:100
- Finding
- Unverified Third-Party Host Mappings Are Installed into the Privileged System Hosts File## Vulnerability Details **File Location**: `update.js:100-123`, `update.js:210-229`, `update.js:240-261`, `update.js:299-320`, and `update.js:643-655` **Vulnerability Type**: Unverified remote configuration supply chain **Risk Level**: High The application retrieves mutable host mappings from third-party services and installs data from the fastest responsive source into the system hosts file. The downloaded mappings are not authenticated through signatures, pinned digests, source consensus, trusted address ranges, or post-download user approval. ### Vulnerable Code The remote sources are mutable third-party endpoints: ```js const HOSTS_SOURCES = [ { name: 'HelloGitHub', url: 'https://raw.hellogithub.com/hosts', enabled: true, priority: 1 }, { name: 'GitLab-ineo6', url: 'https://gitlab.com/ineo6/hosts/-/raw/master/hosts', enabled: true, priority: 2 }, { name: 'Gitee-mirror', url: 'https://gitee.com/peng_zhihui/hosts/raw/master/hosts', enabled: true, priority: 3 }, { name: 'Fastly-JSDelivr', url: 'https://cdn.jsdelivr.net/gh/ineo6/hosts@master/hosts', enabled: true, priority: 4 } ]; ``` Redirects are followed without validating the redirect destination, protocol, hostname, or redirect depth: ```js const req = client.get(url, options, (res) => { if (res.statusCode === 301 || res.statusCode === 302) { fetchUrl(res.headers.location, timeout).then(resolve).catch(reject); return; } if (res.statusCode !== 200) { reject(new Error(`HTTP ${res.statusCode}`)); return; } let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => resolve(data)); }); ``` Downloaded entries are accepted based only on a loose IPv4-shaped expression and membership in the GitHub-domain list: ```js function parseGitHubHosts(content) { const entries = []; ...[truncated 5036 chars]
- Remediation
- ## Remediation Suggestions 1. **Authenticate downloaded mappings** - Require a cryptographic signature from a pinned maintainer key. - Alternatively, retrieve a versioned artifact and verify it against a trusted, pinned digest before parsing it. - Do not treat HTTPS transport alone as sufficient content authentication. 2. **Require agreement between independent sources** - Compare mappings from multiple independently administered sources. - Install a mapping only when a defined quorum agrees on the address. - Do not select security-sensitive configuration solely by response latency. 3. **Restrict redirects** - Accept only absolute HTTPS redirect URLs. - Enforce an explicit allowlist of permitted redirect hostnames. - Reject redirects to HTTP, loopback, private, link-local, or otherwise unexpected destinations. - Set a strict maximum redirect count. 4. **Strengthen input validation** - Validate IPv4 addresses with a proper address parser and enforce octets in the range 0–255. - Normalize and validate hostnames before comparison. - Use an explicit list of exact hostnames where possible rather than broad wildcard suffixes. - Reject duplicate, conflicting, malformed, loopback, private, multicast, unspecified, and reserved addresses unless expressly required. 5. **Add post-download approval** - Download and validate the data before requesting final confirmation. - Display the selected source and a complete diff of mappings that will be added, changed, or removed. - Require explicit approval after the user has reviewed that diff. - Consider disabling `--yes` for privileged writes or requiring a separate explicit unsafe-automation option. 6. **Reduce privileged operations** - Perform all fetching, parsing, comparison, and validation without elevated privileges. - Elevate only for the final atomic replacement of the hosts file. - Preserve ownership and ...[truncated 280 chars]
