Skip to main content
Menu
Advisories

BFF static asset proxying forwards requests to arbitrary URLs

GHSA-6GXG-CHG2-RM9VPublished Updated GitHub

Description

Impact

When a Duende.BFF 4.x frontend proxies its static files from another server (StaticAssetsUrl), an unauthenticated attacker can make the BFF fetch other URLs and return the responses as its own. This has two consequences:

  • Server-side request forgery. Anyone who can reach the BFF can read the responses to GET requests to any host the BFF can reach, such as internal services, administrative endpoints and cloud metadata services.
  • Session takeover through a link. If a signed-in user opens a link from the attacker, attacker script runs on the BFF's origin. It can read the user's claims and call the BFF's local and remote APIs as the user. The BFF's antiforgery protection doesn't stop this.

You are not affected if no frontend sets StaticAssetsUrl (including frontends that use CdnIndexHtmlUrl), if the BFF serves static files itself, or if you use Duende.BFF 3.x or earlier.

Are you affected?

You are affected if your BFF runs a vulnerable version and at least one frontend has StaticAssetsUrl set. This includes development setups: a BFF running on a developer's machine is reachable from web pages the developer visits. That happens when you use any of the following:

builder.Services.AddBff()
    .AddFrontends(
        new BffFrontend(BffFrontendName.Parse("app"))
            .WithProxiedStaticAssets(new Uri("https://localhost:5173")));
// Affected whenever useCdnWhen returns false
new BffFrontend(BffFrontendName.Parse("app"))
    .WithBffStaticAssets(new Uri("https://localhost:5173"), useCdnWhen: () => isProduction);
// In the configuration section passed to LoadConfiguration
"Frontends": {
  "app": {
    "StaticAssetsUrl": "https://localhost:5173"
  }
}

After you upgrade:

  • Static asset proxy requests use their own HTTP client, named Duende.Bff.StaticAssetsProxyClient (Constants.HttpClientNames.StaticAssetsProxyClientName). If you configured headers, credentials, certificates or handlers for proxy requests through BffOptions.StaticAssetsClientName or BffOptions.BackchannelHttpHandler, move them to this client with AddHttpClient(Constants.HttpClientNames.StaticAssetsProxyClientName). Custom handlers on this client must not follow redirects.
  • The BFF doesn't follow redirects from the static assets server, and returns a 502 response for them.
  • The BFF removes Set-Cookie and Clear-Site-Data headers from the static assets server's responses. This is controlled by BffOptions.RemoveCookieHeadersFromProxiedResponses, the same setting as for proxied APIs. If you already set it to false, the static assets server can now set cookies on the BFF's origin too.

Workarounds

If you can't upgrade right away, do one of the following:

  • Remove StaticAssetsUrl from every frontend in environments that don't need it. For production, serve static files from a CDN with CdnIndexHtmlUrl, or from the BFF itself.
  • On a reverse proxy or web application firewall in front of the BFF, reject requests whose path starts with a URL scheme, such as /http: or /https:. Also match the percent-encoded forms of these paths.

Developers who use StaticAssetsUrl locally should upgrade too. Until they do, they should stop the BFF when they aren't using it.

Checking for exploitation

If a frontend with StaticAssetsUrl was reachable from untrusted networks, look in the access logs of the BFF and any proxies in front of it for GET requests whose path contains http: or https: (including percent-encoded forms). If you find any:

  1. Check what the BFF could reach from its network, and rotate any credentials that responses from those hosts may have exposed.
  2. Revoke the affected users' sessions. With server-side sessions (AddServerSideSessions), revoke the sessions in the session store. Without server-side sessions, rotate your ASP.NET Core Data Protection keys and revoke the users' refresh tokens at your identity provider. Both steps sign the affected users out.

Credits

Found by Duende Software during an internal security review.

Affected versions

References

GitHub · DuendeSoftware/products