Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the necessity to protect against device exfil attacks #664

Open
gioele-antoci opened this issue Oct 24, 2024 · 4 comments
Open

Clarify the necessity to protect against device exfil attacks #664

gioele-antoci opened this issue Oct 24, 2024 · 4 comments

Comments

@gioele-antoci
Copy link

TL;DR: Should the FedCM specifications and/or documentation more emphatically warn against device exfiltration attacks?

Context:

  • FedCM does not take a stance on how Relying Parties (RPs) and Identity Providers (IDPs) secure the authentication exchange after the /assertion endpoint.
  • The /assertion endpoint returns a token to the front-end channel. The RP's front end is expected to submit the token to the RP's back end to ultimately open a session on the RP.
  • Passing the token through the front-end channel exposes it to device exfiltration attacks (e.g., a malicious script running on a compromised RP might monkey-patch fetch and steal the token).

RPs should be effectively guided towards implementing a nonce/PKCE flow while associating the authentication exchange with that specific device, for example, by using HttpOnly cookies.

Alternative Proposal:
Instead of returning the token from /assertion, should user agents invoke an RP's callback defined in the configuration file? This approach would alleviate some of the implementation complexity for FedCM RPs and IDPs.

Related to: #536 and #599

@samuelgoto
Copy link
Collaborator

RPs should be effectively guided towards implementing a nonce/PKCE flow while associating the authentication exchange with that specific device, for example, by using HttpOnly cookies.

Yeah, that makes sense. A couple of questions:

a) Can we do this as part of the #599 ? @aaronpk WDYT?
b) As @bvandersloot-mozilla suggested, is there anything that the browser can do to help? Would some opt-in validation help? E.g. maybe the browser could understand @aaronpk profile and throw errors when certain parameters aren't used?

Instead of returning the token from /assertion, should user agents invoke an RP's callback defined in the configuration file? This approach would alleviate some of the implementation complexity for FedCM RPs and IDPs.

I'd be happy to explore options where the browser can help make the system more secure. I'd still want to do that within the boundaries of what would show up in #599.

@philsmart
Copy link
Contributor

I'd +1 a way for FedCM to send the token directly to the RP's back-end without making it available to the RP's front-end via JS. Maybe either could be supported, allowing both 'public' (browser-based) and 'confidential' (server-based) RP clients.

It even seems common these days for public applications/clients e.g. a Single Page Application, to use a backend, server-side, component to manage tokens, the Backend For Frontend Pattern (BFF).

Overall I think server-side authentication is very common (swapping security tokens for sessions on the backend, managed by HttpOnly session cookies on the frontend), and those would not need whatever comes back from the IdP accessible via JS in the front-end.

@cbiesinger
Copy link
Collaborator

@philsmart could you talk a bit how you envision this working concretely, especially for SPAs? I assume you want the browser to make a credentialed HTTPS request to some URL with the token, but how does this interact with the JS API? How does the page know that a token is now available?

@philsmart
Copy link
Contributor

philsmart commented Nov 28, 2024

@cbiesinger; I was thinking (and maybe @gioele-antoci was thinking similarly) that both the existing mode could be supported, where the token is resolved directly from the n.c.get call, and a new mode where FedCM sends the token directly to an endpoint on the RP, and the n.c.get call returns whatever the RP wants after it consumes the token, or nothing at all (the RP might need to create or rotate a HttpOnly session identifier cookie of some kind i.e. set a cookie in response to the FedCM call).

An SPA can then use it as you suggest, in the same way it works now. But a more traditional server-side rendered (and importantly, server-side authenticated) site would just use the session cookie, and the server would make further HTTP calls using the token(s) (if required). Noting that, as Aaron points out in #599, server-side authentication and token management is still possible even for SPAs using the Backend For Frontend (BFF) architecture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants