You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specs/AdditionalAllowedFrameAncestors.md
+60-46Lines changed: 60 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,29 @@ Additional Allowed Frame Ancestors for iframes
2
2
===
3
3
4
4
# Background
5
-
Due to potential [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking) attack, a lot of sites only allow themselves to be hosted in certain trusted ancestor iframes and pages. The main way to specify this ancestor requirement for sites are http header [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
5
+
Due to potential [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking) attack, a lot of sites only allow themselves to be embedded in certain trusted ancestor iframes and pages. The main way to specify this ancestor requirement for sites are http header [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
6
6
7
-
However, there are application scenarios that require hosting these sites in the app's UI that is authored as an HTML page.
8
-
`<webview>` HTML element was provided for these hosting scenarios in previous solutions like Electron and JavaScript UWP apps.
7
+
However, there are application scenarios that require embedding these sites in the app's UI that is authored as an HTML page.
8
+
`<webview>` HTML element was provided for these embedding scenarios in previous solutions like Electron and JavaScript UWP apps.
9
9
10
-
For WebView2, we are providing a native API for these hosting scenarios. Developers can use it to provide additional allowed frame ancestors as if the site sent these as part of the Content-Security-Policy frame-ancestors directive. The result is that an ancestor is allowed if it is allowed by the site's original policies or by this additional allowed frame ancestors.
10
+
For WebView2, we are providing a native API for these embedding scenarios. Developers can use it to provide additional allowed frame ancestors as if the site sent these as part of the Content-Security-Policy frame-ancestors directive. The result is that an ancestor is allowed if it is allowed by the site's original policies or by this additional allowed frame ancestors.
11
11
12
12
# Conceptual pages (How To)
13
13
14
-
To host other sites in an trusted page with modified allowed frame ancestors
14
+
To embed other sites in an trusted page with modified allowed frame ancestors
15
15
- Listen to FrameNavigationStarting event of CoreWebView2.
16
-
- Set AdditionalAllowedFrameAncestors property of the NavigationStartingEventArgs to a list additional allowed frame ancestors using the same syntax as [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
16
+
- Set AdditionalAllowedFrameAncestors property of the NavigationStartingEventArgs to a list additional allowed frame ancestors using the same syntax for the source list of [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors). Basically, it is a space delimited list. All source syntax of Content-Security-Policy frame-ancestors directive are supported.
17
17
18
18
The list should normally only contain the origin of the top page.
19
-
If you are hosting other sites through nested iframes and the origins of some of the intermediate iframes are different from the origin of the top page and those origins might not be allowed by the site's original policies, the list should also include those origins.
19
+
If you are embedding other sites through nested iframes and the origins of some of the intermediate iframes are different from the origin of the top page and those origins might not be allowed by the site's original policies, the list should also include those origins. As an example, if you owns the content on https://example.com and https://www.example.com and uses them on top page and some intermediate iframes, you should set the list as "https://example.comhttps://www.example.com".
20
20
21
-
You should only add an origin to the list if it is fully trusted. You should limit the usage of the API to the targetted app scenarios.
21
+
You should only add an origin to the list if it is fully trusted. When possible, you should try to limit the usage of the API to the targetted app scenarios. For example, we can set a specific name attribute to the iframe that is used to embed sites (something like `<iframe name="my_site_embedding_frame">`) and then detect the embedding scenario when the trusted page is navigated to and the embedding iframe is created.
/// and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
199
210
/// If set, a frame ancestor is allowed if it is allowed by the additional allowed frame ancestoers or original http header from the site.
200
211
/// Whether an ancestor is allowed by the additional allowed frame ancestoers is done the same way as if the site provided
201
212
/// it as the source list of the Content-Security-Policy frame-ancestors directive.
202
-
/// This property gives the app the ability to use iframe to host sites that otherwise
203
-
/// could not be hosted in an iframe in trusted app pages.
204
-
/// This could potentially subject the hosted sites to [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking)
205
-
/// attack from the code running in the hosting web page. Therefore, you should only
206
-
/// set this property with origins of fully trusted hosting page and any intermediate iframes.
213
+
/// For example, if https://example.com and https://www.example.com are the origins of the top
214
+
/// page and intemediate iframes for a nested iframe that is embedding a site, and you fully trust
215
+
/// those origins, you should set thus property to "https://example.com https://www.example.com".
216
+
/// This property gives the app the ability to use iframe to embed sites that otherwise
217
+
/// could not be embedded in an iframe in trusted app pages.
218
+
/// This could potentially subject the embedded sites to [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking)
219
+
/// attack from the code running in the embedding web page. Therefore, you should only
220
+
/// set this property with origins of fully trusted embedding page and any intermediate iframes.
207
221
/// Whenever possible, you should use the list of specific origins of the top and intermediate
208
222
/// frames instead of wildcard characters for this property.
209
223
/// This API is to provide limited support for app scenarios that used to be supported by
0 commit comments