Repository navigation
Description
SimplePie allows loading feeds from local files. If a malicious user can provide URI to fetch and the library consumer exposes raw data on error, it can lead to exfiltration of privileged information (e.g. /etc/passwd). This is also known as Server-Side Request Forgery.
Affected classes
- I consider
Fileclass to be a low-level API mostly meant for SimplePie itself so it is probably should not be considered a security issue. It will be deprecated soon anyway. - On the other hand the
SimplePieclass is high-level API and as such, it would make sense for it to be safe-by-default (for example, we already escape every string for HTML-special characters by default). - The new PSR-18 wrappers are also low-level.
Severity
I am not that concerned, generally, only a trusted user should be able to provide the URL (citation needed, we do not have formal security model AFAIK). And even if a malicious user can inject a local URI, the file will most likely not parse as RSS, and the error message will not leak the content in recommended usage:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$feed = new \SimplePie\SimplePie();
$feed->set_feed_url('/etc/passwd');
$feed->set_cache_duration(0);
$feed->init();
var_dump($feed->error()); // "/etc/passwd is invalid XML, likely due to invalid characters. XML error: Not well-formed (invalid token) at line 1, column 6601"
var_dump($feed->get_title()); // NULL
var_dump($feed->get_items()); // []It would require something like the following:
var_dump($feed->get_raw_data()); // this would leak the dataOf course, there might be other ways to leak the data I am not aware of, which would make it more serious.
Problematic URIs
Local files (without URI scheme) as well as addresses like localhost or other private addresses.
At least SimplePie::set_feed_url() only allows http and https schemes and local files (with empty scheme).
Line 774 in 4f59520
| $this->feed_url = $this->registry->call(Misc::class, 'fix_protocol', [$url, 1]); |
Line 180 in 4f59520
| return Misc::fix_protocol(Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); |
So PHP protocols/wrappers will not be an issue.
Possible solutions
We could add local IP and path allowlist and deny all URIs that resolve to local IPs/paths not allowed. It would be a BC break but having it opt-in would make it too easy to be insecure by accident.
Ideally, we would use https://github.com/j0k3r/httplug-ssrf-plugin but that would require switching from plain PSR-18 to HTTPlug. And it would probably be too involved for Composer-averse people.
Activity
Alkarex commentedon May 25, 2026
Downstream PR:
But we have a bunch of other PRs waiting to be merged, so waiting for them first, and then feel free to say whether there is interest.
Add CURLOPT_RESOLVE and safer following of HTTP redirections (#76)
ziegenberg commentedon Sep 23, 2026
We hit this issue from a different angle while implementing the switch to a PSR-18 client for SimplePie in Moodle.
The issue, as written, focuses on the direct
set_feed_url()vector, but the same vanilla configuration is also exploitable through feed autodiscovery candidate URLs, which the issue does not enumerate. Since that vector is arguably easier to reach (it does not require the attacker to control the configured feed URL, only the fetched page), I want to record it here.Disclaimer: This report was compiled with the help of AI.
Autodiscovery candidate URL vector
With the default
SimplePie::LOCATOR_ALL(SimplePie::$autodiscovery) and a PSR-18 client set viaset_http_client(),SimplePie::init()hands the client to theLocatorwhen the fetched document is not itself a feed (seeSimplePie\SimplePie::fetch_data()):The
Locatorthen requests every<link rel="alternate|feed">,<a>and<area>href parsed from the remote page. Unlikeget_links()(which restricts schemes tohttps?|feed|''before building the candidate lists), the autodiscovery path applies no scheme check — it only absolutises the hrefand fetches it (see
SimplePie\Locator::search_elements_by_tag()):An absolute
file://href survivesabsolutize_url()unchanged.Psr18Client::request()routes anything that is nothttp(s)://torequestLocalFile()and never invokes the injected PSR-18 client (SimplePie\HTTP\Psr18Client::request()):requestLocalFile()runsis_readable()+file_get_contents()on the (possiblyfile://-prefixed) path and returns the content as aRawTextResponse. The discovered candidate is accepted becauseLocator::is_feed()treats any local file as a feed (SimplePie\Locator::is_feed()), and the acceptance condition atsrc/Locator.php:272lets local responses through unconditionally:!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 …).So a single remote page someone subscribed to (or that a configured feed redirects to / is compromised) containing:
makes the server read an arbitrary readable local file. Content is exposed when it parses as XML/RSS (via the item APIs /
get_raw_data()); for non-XML files, the read still happens server-side, and any path the process can read is in scope.Wider implications
Psr18Clientperforms its own local-file fallback beforesendRequest()is ever called. A consumer that hardens its HTTP layer (URL allowlists, proxy filtering, a custom client that rejects non-HTTP(s) URIs) still cannot intercept these requests, becauserequestLocalFile()bypasses the injected client entirely. The abstraction gives a false sense of a network boundary.FileClient(as Moodle did) had their requests proxied through the consumer's transport layer; swapping in a PSR-18 client changes which code actually issues the read with no change to SimplePie's external behaviour.Suggestion
At minimum the autodiscovery candidate path should apply the same scheme restriction that
get_links()already applies (https?|feed|''), and the local-file fallback inPsr18Client::request()(and by extension the equivalent path inFileClient) should be explicit opt-in rather than the default behavior.That keeps the legacy local-file feature available while making the safe default hold for everyone who does not ask for it.
Happy to turn this into a patch if the scheme-filtering approach is welcome.
ziegenberg commentedon Sep 23, 2026
Hi @jtojnar,
I created a fix. You might wanna release that sooner rather than later.
Greetings,
Daniel
jtojnar commentedon Sep 23, 2026
I am starting to think this might need to be handled by the consumer since they control the PSR-18 client. For example, if they pass
GuzzleHttp\Clientwith redirects enabled, it would bypass our checks anyway. Maybe we should stop trying to do everything and just suggest a suitable library client can use like https://github.com/j0k3r/httplug-ssrf-plugin.ziegenberg commentedon Sep 23, 2026
That would not help, cause SimplePie fetches lokal stuff before it even reaches any PSR18-client. Cause that's what I tried to do first and I realised I would need to override parts of SimplePie to fix it for good.
See second bullet point of "Wider implications" in my first comment.
ziegenberg commentedon Oct 16, 2026
Any news on this?
Alkarex commentedon Oct 16, 2026
We have worked quite a lot on SSRF downstream in https://github.com/FreshRSS/simplepie and can happily send PRs upstream if maintainers spot parts of interest. For instance:
disallow_uri_schemes()function for disallowingjavascript:URIs FreshRSS/simplepie#65CURLOPT_PROXYwithget_curl_resolve_info()FreshRSS/simplepie#83jtojnar commentedon Nov 2, 2026
Looks like the redirect/autodiscovery part was assigned a CVE-2026-111234. In #994, I am dropping the support for fetching local files.