Summary
A server-side request forgery vulnerability in Link Preview JS allows DNS rebinding to bypass hostname and IP validation during link preview requests. If an attacker controls DNS responses for a requested hostname, the server may connect to loopback or internal HTTP services after validation succeeds against a public address.
Affected context
The issue affects Link Preview JS deployments before version 4.0.4 when the application resolves a hostname for SSRF protection but later fetches the original hostname. The risk is present when attacker-controlled DNS responses can change between validation and the final connection, including during redirect processing.
Exploit preconditions
- Attack surface: Server-side link preview or metadata-fetching functionality
- Required access: Ability to submit or cause the application to process a URL
- Trigger point: DNS resolution followed by the preview HTTP request or redirect
- Why exploitation is possible: The application validates one resolved address but connects using the hostname, allowing DNS rebinding to substitute an internal or loopback address afterward
Why this happens
The vulnerability results from a time-of-check-to-time-of-use mismatch in SSRF defenses. The application checks a resolved IP address but does not bind the subsequent connection to that validated address, so a hostname can resolve to a public address during validation and to a private address during use. This maps to CWE-918: Server-Side Request Forgery, with the same trust-boundary failure extending to redirect handling.
Potential impact
- The server may access loopback services that are not externally exposed.
- An attacker could retrieve information from internal HTTP endpoints.
- Cloud or container metadata services could be targeted where reachable.
- Internal administrative interfaces may be exposed through response handling.
- Network reconnaissance or limited lateral movement could become possible.
General mitigation guidance
Mitigation generally focuses on making hostname validation and connection behavior consistent.
Common defensive patterns include:
- Resolve the hostname and connect only to the validated address, rather than resolving it again implicitly.
- Revalidate every redirect destination using the same SSRF policy.
- Reject loopback, link-local, private, reserved, and other non-routable address ranges according to the deployment threat model.
- Restrict outbound traffic with network policies, egress filtering, and service-level allowlists.
- Limit the preview service's network and identity privileges.
- Apply request timeouts, response-size limits, and protocol restrictions.
These controls reduce reliance on attacker-controlled DNS behavior and limit exposure if validation is bypassed.
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis for URL validation followed by separate hostname-based HTTP requests.
- Code review checks for DNS resolution and connection logic that do not preserve the validated address.
- Tests that simulate DNS changes between validation and connection.
- Review of redirect handling to confirm that every destination receives SSRF checks.
- Egress monitoring for preview services connecting to private, loopback, link-local, or metadata-service address ranges.
- Policy enforcement requiring outbound allowlists for server-side fetchers.
Automated security review tools may help flag SSRF sinks, unsafe redirect behavior, and inconsistent DNS validation.

