Skip to main content
Menu
Advisories

Dynamic-frontend remote API proxy (WithRemoteApis) skips the BFF anti-forgery header

GHSA-4J63-5V5F-XCC4Published Updated GitHub

Description

Impact

Duende.BFF protects its API endpoints from cross-site request forgery by requiring a custom header (X-CSRF: 1 by default). A cross-site page cannot set a custom header on a simple request, so the header shows that the request came from the BFF's own frontend.

BFF enforces this check for local APIs and for remote APIs mapped with MapRemoteBffApiEndpoint. It does not enforce it for remote APIs that a dynamic frontend configures with WithRemoteApis. These routes match by path prefix and select their endpoint while the request is being handled, after the anti-forgery middleware has already run. The anti-forgery middleware finds no endpoint, so it skips the check. The RemoteApi builder has no option to require the header, so developers had no way to turn the check on.

A cross-site page can therefore make a signed-in user's browser send requests to a WithRemoteApis route. BFF attaches the user's access token and forwards the request to the backend API. The attacker cannot read the response, but state-changing operations on the backend still take effect.

Are you affected?

You are affected if you use dynamic frontends with WithRemoteApis. Vulnerable implementations have configuration code similar to the following:

services.AddBff()
    .AddRemoteApis()
    .AddFrontends(new BffFrontend(BffFrontendName.Parse("frontend"))
        .WithRemoteApis(new RemoteApi("/api", backendUri)
            .WithAccessToken(RequiredTokenType.User)));

Remote APIs mapped with MapRemoteBffApiEndpoint and local APIs marked with AsBffApiEndpoint are not affected.

Whether a cross-site request carries the user's session cookie depends on the cookie's SameSite setting:

  • SameSite=None: Fully exploitable. Deployments that host frontends on different domains often need this setting. In that case the anti-forgery header is the only CSRF protection, and this weakness bypasses it.
  • SameSite=Lax: Exploitable for state-changing GET endpoints, because the browser sends the cookie on top-level navigations.
  • SameSite=Strict (the default for dynamic frontends): Blocks attackers on other sites. An attacker on the same site, such as a sibling subdomain, can still send requests with the cookie, and the anti-forgery check does not stop them.

Workarounds

If upgrading is not possible:

  • Add middleware before UseBff() that rejects requests to your WithRemoteApis path prefixes when they do not have the anti-forgery header.
  • If your deployment allows it, set the session cookie to SameSite=Strict. This blocks attackers on other sites, but not attackers on the same site.
  • Map remote APIs with MapRemoteBffApiEndpoint instead of WithRemoteApis. These routes enforce the anti-forgery check.

Acknowledgements

Duende would like to thank @NotAFlightRisk for reporting this issue through our security reporting process, and we appreciate them disclosing it responsibly.

CVE ID Note

GitHub currently has a backlog of several weeks for issuing CVE IDs. We'll update this advisory as soon as one is issued to us.

Affected versions

References

GitHub · DuendeSoftware/products