☰
WEB SECURITY / PRACTICE

Protecting WordPress from SSRF Requests: URL, DNS, and Outbound Connection Validation

Protecting WordPress from SSRF Requests: URL, DNS, and Outbound Connection Validation

SSRF (Server-Side Request Forgery) is a vulnerability that allows an attacker to make a server send an HTTP request to an address that the server can typically access more directly than an external user can. In WordPress, this issue often occurs in content import, preview generation, image downloading, Elementor integrations, webhooks, and forms that accept URLs.

A malicious request may target not an ordinary external website, but localhost, an internal hosting panel, Redis, a Docker service, or a cloud infrastructure metadata service. Therefore, it is necessary to validate not only user permissions, but also the URL itself, the address returned by DNS resolution, redirects, and the server’s ability to establish outbound connections.

How SSRF Occurs in WordPress and Elementor

A typical scenario looks simple: a user enters a URL, and the site passes it to the WordPress HTTP API or a third-party HTTP client. The server downloads the resource and returns the result to the administration panel, editor, or form. If the URL is not restricted, an attacker can specify the address of an internal service.

The risk is not limited to forms that are publicly accessible. A compromised administrator account, a stolen integration token, or a vulnerable plugin can also become an entry point. That is why the rule “administrators can be trusted” is not sufficient protection.

Pay particular attention to functions that accept URLs for importing pages, RSS or XML, downloading images, validating webhook addresses, creating screenshots, previewing pages, and synchronizing with APIs.

  • localhost and loopback addresses: 127.0.0.1, ::1, and the corresponding ranges;
  • private IPv4 and IPv6 networks, where internal panels or databases may be running;
  • link-local addresses, including ranges used by local services and cloud metadata APIs;
  • internal names of containers, Kubernetes services, or local network hosts;
  • addresses of Redis, Elasticsearch, internal administration panels, and unauthenticated services.

First, Identify Every Function That Makes HTTP Requests

Protection begins with an inventory. Review plugins, custom theme modules, Elementor widgets, and integrations where a user or administrator can enter a URL. Check not only obvious “import URL” fields, but also webhook settings, callback addresses, image sources, and external APIs.

Maintain a separate list showing who can invoke each function, whether a nonce is required, which HTTP methods are used, whether redirects are supported, where the downloaded file is stored, and whether the response is returned to the user. This helps distinguish ordinary downloading of a public resource from a potential proxy into the internal network.

In the WordPress HTTP API and third-party clients, do not rely on default settings. Check timeouts, maximum response size, the number of redirects, IPv6 support, repeated DNS resolution, and error handling. Excessively long timeouts can turn SSRF into a simple way to exhaust server resources.

  • check plugin code for wp_remote_get, wp_remote_post, wp_safe_remote_get, cURL, and similar clients;
  • determine whether a user can influence the URL directly or through JSON, XML, a shortcode, or an Elementor field;
  • limit response size and waiting time before the download begins;
  • do not return the full HTTP client, DNS, or internal-network error text to the user.

Allow Only the Required Schemes, Domains, and Ports

The most reliable model for import or webhook functionality is an allowlist: an explicit list of permitted domains. If an integration needs only api.example.com, do not allow every domain ending in example.com without analyzing the subdomains. Define separately whether all subdomains are required and which ports are permitted.

For most web integrations, HTTPS is sufficient. HTTP should be prohibited if it is not functionally necessary. Also reject URLs containing embedded credentials, unusual ports, parser-bypass fragments, and characters that different libraries may interpret differently.

Validate URLs with a structured parser rather than a collection of simple regular expressions. After normalization, make sure the hostname actually belongs to the allowlist rather than merely containing an allowed string. For example, evil-example.com must not pass validation for example.com.

If the domain list can be changed from the administration panel, protect this setting with a nonce, capability checks, and change auditing. The allowlist field itself must not allow an arbitrary editor or compromised user to add an internal host.

  • allow only HTTPS unless there is a justified need for another scheme;
  • validate the hostname after URL decoding and normalization;
  • prohibit usernames, passwords, and unexpected ports in URLs;
  • compare domains exactly or according to a clearly defined subdomain rule;
  • do not use a blacklist as the only protection: a list of prohibited addresses is easy to make incomplete.
Validation algorithm: parse the URL → allow only https → validate the hostname against the allowlist → reject credentials and unexpected ports → perform DNS resolution → validate every IP address → make the request with redirects disabled or controlled.

Block Private IPs and Protect Against DNS Rebinding

Checking the domain name is not enough. An attacker may register an apparently safe domain that resolves to a private address, or use DNS rebinding: the domain first returns an allowed IP address and then returns an internal address during a subsequent request.

After DNS resolution, validate every IPv4 and IPv6 address returned. Reject loopback, private, link-local, multicast, unspecified, and reserved ranges. Also reject non-standard IPv4 representations, IPv4-mapped IPv6 addresses, and addresses that become internal after decoding.

The validated address must be the one used for the actual connection. If the HTTP client resolves the hostname again on its own, a simple DNS check before the request may not be sufficient. For critical integrations, use a controlled outbound proxy or a mechanism that pins the resolution result and validates the address immediately before connecting.

Repeat the complete validation cycle after every redirect: scheme, hostname, port, and IP. A redirect from an allowed domain to 127.0.0.1 or an internal hostname must not be allowed.

  • validate the IP after DNS resolution, not only the textual domain name;
  • handle IPv4 and IPv6 with the same level of strictness;
  • disable automatic redirects when they are not needed;
  • if redirects are required, set a low redirect limit and validate every hop;
  • do not assume that a DNS record remains safe indefinitely: it may change between two requests.

Apply Protection in WordPress, Elementor, and Custom Code

In WordPress, check access rights for every operation, use nonces for administrative actions, and sanitize values only as an additional measure. String sanitization does not replace an allowlist, scheme validation, DNS checks, or IP validation.

For Elementor and integrations, review all dynamic fields, webhook actions, custom widgets, and server-side form handlers. Protect not only the standard interface, but also the REST endpoint or AJAX handler that actually performs the request. A check implemented only in JavaScript is easily bypassed with a direct HTTP request to the server.

If a function downloads an external file, restrict its type, size, and storage location. Do not pass downloaded content to executable handlers without validation, do not allow PHP files to be uploaded into a web-accessible directory, and do not store integration secrets in URLs.

For complex scenarios, it is better to move external requests to a separate service or outbound proxy. It can have its own allowlist, restricted network access, response-size limits, and centralized logging.

  • check authorization and capabilities on the server, not only in the interface;
  • protect REST and AJAX handlers with a nonce, permission callback, or another appropriate control;
  • do not allow users to specify HTTP headers, proxies, or ports themselves;
  • limit the timeout, response size, number of redirects, and number of concurrent requests;
  • keep WordPress, Elementor, plugins, and libraries updated, but do not treat updates as a replacement for your own validation.

Restrict Outbound Traffic at the Server Level

Code-level protection may be bypassed by a new plugin vulnerability, so a second layer—network restrictions—is required. A WordPress server should not have unrestricted access to every internal segment and port.

At the firewall or security-group level, allow only necessary destinations: for example, DNS through a designated resolver, HTTPS to required external services, and access to specific internal resources if they are genuinely needed. Block access to metadata endpoints, private subnets, administration panels, and database ports.

Firewall rules must not be the only protection: incorrect configuration, a proxy, or an allowed service may still leave a path into the internal network. However, even basic outbound restrictions significantly reduce the consequences of a plugin error.

  • block outbound access to private and service subnets;
  • restrict access to database ports, Redis, the Docker API, and administrative services;
  • consider using a separate system user and a container with minimal network permissions;
  • check IPv6 rules: protecting IPv4 does not automatically protect IPv6;
  • review the rules regularly after changes to the hosting environment or architecture.

Log Requests and Test the Protection

Without logs, it is difficult to distinguish an ordinary integration error from an attempt to probe the internal network. Log the time, user or process identifier, endpoint, normalized hostname, DNS validation result, final status, reason for rejection, and operation duration.

Do not record passwords, tokens, cookies, or complete URLs if query strings may contain secrets. For diagnostics, a masked URL, domain, port, and error code are sufficient. Associate the event with a request ID so it can be correlated with web server, firewall, and proxy logs.

Test more than 127.0.0.1. Check the IPv6 loopback address, private ranges, link-local addresses, DNS names of internal services, domains with redirects, URLs containing credentials, unusual ports, and different encoding variants. Perform testing on staging or with written authorization so that you do not create an incident in production.

  • verify that a blocked request does not reach the internal service;
  • make sure a redirect to a private IP address is blocked;
  • check behavior for DNS errors, timeouts, and large responses;
  • configure alerts for repeated attempts to reach internal addresses;
  • review logs after installing new plugins and integrations.

Frequently asked questions

Is it enough to allow requests only for administrators?

No. An administrator account may be compromised, and a vulnerable plugin may make requests without direct user involvement. URL, DNS, and IP validation, redirect controls, and network restrictions are still required.

Can I protect against SSRF by blocking only 127.0.0.1?

No. You must also block ::1, private IPv4 and IPv6 ranges, link-local, reserved, and service addresses. Check the DNS result and every redirect separately.

Is a URL with an allowed domain safe?

Not always. An allowed domain may redirect to an internal address or begin returning a dangerous IP through DNS rebinding. The domain, IP, and every redirect must be checked while the request is being performed.

Is SSRF protection necessary if only an administrator enters the URL?

Yes. A compromised administrator account, stolen token, or plugin vulnerability can turn this feature into a channel for accessing internal services.

What should I do if an integration requires requests to an internal API?

Do not disable validation completely. Add a narrow allowlist of specific hosts and ports, separate authentication, firewall rules, and a controlled proxy. Internal addresses should be permitted only for clearly defined scenarios.

Conclusion

SSRF in WordPress should be treated as a whole-system issue, not merely a problem with a single URL field. Reliable protection combines domain allowlists, HTTPS, IP validation after DNS resolution, redirect controls, a server firewall, and logging.

Pay particular attention to Elementor forms, imports, webhooks, custom REST/AJAX handlers, and all plugins that download external resources. If a function does not require arbitrary URLs, the best option is to replace them with a fixed list of approved integrations.

← All web security materials