-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Use Case
This is in reference to fedidcg/protocol-library#22. One of the potential solutions to how to establish the identity of the user for RP2, in its iframe embedded in RP1, is to use a standard OAuth flow. However, iframes provide limited flexibility with regards to what information can be passed to the embedded page. Besides the src url, there are some attributes which can control very specific properties but no general access to things like http headers. As per the OAuth Bearer Token specification, in reference to passing access tokens via URI query parameters:
Because of the security weaknesses associated with the URI method (see Section 4), it SHOULD NOT be used unless it is the only feasible method. Resource servers MAY support this method.
In Section 4.3 (recommendations), the specification goes on to say:
Don't pass bearer tokens in page URLs:
Bearer tokens SHOULD NOT be passed in page URLs (for example as query string parameters). Instead, bearer tokens SHOULD be passed in HTTP message headers or message bodies for which confidentiality measures are taken. Browsers, web servers, and other software may not adequately secure URLs in the browser history, web server logs, and other data structures. If bearer tokens are passed in page URLs, attackers might be able to steal them from the history data, logs, or other unsecured locations.
Assumptions
- iFrames are not evil. No proposals or specifications exist that deprecate the use of iFrames. Web Components / Shadow DOM do not provide the same level of security and isolation as iframes and are not meant to be a replacement for iframes
- Many embedded content providers use iframes and in the set of solutions we have been proposing to help to support embedded content and federated identity, we have never indicated that part of the proposal is to no longer use iframes
- Despite the existence of security standards for iframes like CSP frame-ancestors, that might not be enough to allow for in-frame auth flows like OIDC / SAML which rely on 'tracking cookies'
Proposal
We add a new attribute to the iframe called ‘accesstoken’ which maps well to the naming conventions used in the oauth2 specification. Usage would look like:
<iframe src="https://www.mea.com/dashboard" accesstoken="123"></iframe>
The accesstoken attribute would be used to populate the Authorization header as such
GET https://www.mea.com/dashboard HTTP/1.1
User-Agent: …
…
Authorization: Bearer 123
What does this buy us
Technically speaking you can already pass an access token via the uri to an iframe. However, the spec specifically recommends against doing this. Also, for those who go this route, extra effort is often needed to more aggressively prevent replay attacks, going as far as making all access tokens single use which can overly complicate systems.
The above proposal provides a secure way to pass authentication information on frame load as opposed to after the initial page load. This is often needed because while some authenticated information could be delay loaded, some, such as CSP frame-ancestors headers, must be returned as part of the page response. By providing this minimal attribute, it will ease the implementation burden on RP1 and also provide a secure framework that meets the guidelines of the OAuth specification.
By making it a more secure option, this could provide 1 mechanism to solve the problems explained in issue 22.
What are the risks
- OAuth is a protocol and not a native browser feature like CSP headers. I am not aware of other places where we expose something as part of the core html specification that is related to a protocol like this. What is the precedent?
- With this pattern, the access token will still likely be in the html document src. It is recommended that those going this route, for the top level parent page, use ‘Cache-Control no-store’ header to prevent caching of these tokens and potential access to them after the user has logged off.
- Is there a risk in having a well-known attribute that holds a security token? Will this create an attack vector if malicious code can scan for iframes and look for values in this field? Is this more risky than what people do today by placing it in the url.
Open Questions
- How can we have feature discovery so RP1 can know when the browser can support this?
- Iframe is one use case but we have not imagined what happens if the content is embedded vai alternative elements like img or media tags. Should this proposal expand to cover other such elements? I have put very little thought into that but … maybe?
What are people doing today
(possibly include links) This is not a sanctioned list of approaches, just a representation of what I found when searching:
- Passing the token via the url and including more aggressive replay attack prevention by requiring JTI claims and single-use tokens
- Attempting to use the srcdoc attribute of the iframe and pre-load the actual content via a direct call and then assign it to the frame srcdoc
- Indicate to the child frame in the url that it should ask the parent for some authentication via postMessage communication.