The vulnerability is a Server-Side Request Forgery (SSRF) in the FetchUrlReader component of Backstage. The root cause was the automatic following of HTTP redirects by the underlying fetch library. The backend.reading.allow configuration was only checked for the initial URL, not for any subsequent URLs in a redirect chain.
The analysis of the patch commit 27f9061d24affd1b9212fe0abd476bfc3fbaedcb confirms this. The core of the patch is in the packages/backend-defaults/src/entrypoints/urlReader/lib/FetchUrlReader.ts file.
The function FetchUrlReader.readUrl was completely refactored. The original implementation made a single fetch call, relying on its default behavior to follow redirects. The patched version introduces a loop to manually handle redirects. It sets redirect: 'manual' in the fetch options and, upon receiving a redirect status code, it checks the location header. Crucially, before fetching the next URL in the chain, it validates it against the backend.reading.allow list using a predicate function.
The primary vulnerable function is FetchUrlReader.readUrl, as it contained the flawed fetching logic. The FetchUrlReader.read function is also identified as vulnerable because it's a public entry point that directly calls readUrl. During an exploit, a profiler would likely show both FetchUrlReader.read and FetchUrlReader.readUrl in the stack trace. The fix ensures that all URLs in a redirect chain are subject to the same security policy, effectively mitigating the SSRF vulnerability.