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

Removal of support for the object-src directive #21190

Merged
merged 6 commits into from
Oct 3, 2022

Conversation

rebloor
Copy link
Contributor

@rebloor rebloor commented Sep 29, 2022

Description

Adds a released note to provide documentation for Bug 1766881 Remove object-src requirement from the extension CSP, at least in MV3. Also includes some miscellaneous edits to the content–security-policy manifest key page.

Related issues and pull requests

Browser compatibility data PR: mdn/browser-compat-data#17901

@rebloor rebloor added the Content:WebExt WebExtensions docs label Sep 29, 2022
@rebloor rebloor requested a review from Rob--W September 29, 2022 17:57
@rebloor rebloor requested a review from a team as a code owner September 29, 2022 17:57
@rebloor rebloor self-assigned this Sep 29, 2022
@rebloor rebloor requested a review from a team as a code owner September 29, 2022 17:57
@rebloor rebloor requested review from willdurand and bsmth and removed request for a team September 29, 2022 17:57
@github-actions github-actions bot added the Content:Other Any docs not covered by another "Content:" label label Sep 29, 2022
Copy link
Member

@willdurand willdurand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


> **Note:** The examples below include the {{CSP("script-src")}} directive because this was required in older browser versions. This directive is optional in modern browsers without obsolete [plugins](/en-US/docs/Glossary/Plugin) ([more information](https://github.com/w3c/webextensions/issues/204)).
> **Note:** The examples include the {{CSP("script-src")}} directive, which was required in older browser versions. This directive is optional in modern browsers without obsolete [plugins](/en-US/docs/Glossary/Plugin). See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> **Note:** The examples include the {{CSP("script-src")}} directive, which was required in older browser versions. This directive is optional in modern browsers without obsolete [plugins](/en-US/docs/Glossary/Plugin). See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information.
> **Note:** The examples include the {{CSP("script-src")}} directive, which was required in older browser versions. This directive is optional in modern browsers without obsolete [plugins](/en-US/docs/Glossary/Plugin). See W3C Web Extensions Community Group issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information.

(maybe)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to what Will said. Also move the "issue" text before the number into the link, [issue 204](....)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also on checking I noticed that webextensions doesn't have a space in it in the group name.

@@ -52,6 +52,8 @@ This article provides information about the changes in Firefox 106 that will aff

## Changes for add-on developers

- The `object-src` directive in the `"content-security-policy"` manifest key is now optional in Manifest V3. This is because the `object-src` directive is only required for browsers with obsolete [plugins](/en-US/docs/Glossary/Plugin), and browsers enabling Manifest V3 don't contain such plugins. See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The `object-src` directive in the `"content-security-policy"` manifest key is now optional in Manifest V3. This is because the `object-src` directive is only required for browsers with obsolete [plugins](/en-US/docs/Glossary/Plugin), and browsers enabling Manifest V3 don't contain such plugins. See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})
- The `object-src` directive in the `"content-security-policy"` manifest key is now optional in Manifest V3. This is because the `object-src` directive is only required for browsers with obsolete [plugins](/en-US/docs/Glossary/Plugin), and browsers enabling Manifest V3 don't contain such plugins. See W3C Web Extensions Community Group issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -113,14 +113,14 @@ In Manifest V3, the `content_security_policy` key is an object that may have any
</tbody>
</table>

## Example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming a heading may break existing links, because the link is generated from the header content. If not absolutely necessary, I try to avoid header changes after publication.

If it's worth making the change, we should double-check that there are no references to the old header (at least on MDN, but also the extension workshop).

In this case I think that it's fine to proceed with the change, but I am noting this to emphasize the consideration that I made in evaluating this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I did check. I couldn't find any links to this heading, and they are only three cross-reference links to example/examples headings in the add-ons content!


> **Note:** The examples below include the {{CSP("script-src")}} directive because this was required in older browser versions. This directive is optional in modern browsers without obsolete [plugins](/en-US/docs/Glossary/Plugin) ([more information](https://github.com/w3c/webextensions/issues/204)).
> **Note:** The examples include the {{CSP("script-src")}} directive, which was required in older browser versions. This directive is optional in modern browsers without obsolete [plugins](/en-US/docs/Glossary/Plugin). See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to what Will said. Also move the "issue" text before the number into the link, [issue 204](....)


```json example-bad
"content_security_policy": "script-src 'self' https://*.jquery.com;"
```

However, this is only invalid in browsers that support obsolete [plugins](/en-US/docs/Glossary/Plugin). See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to the other instance, add "CG" before "issue" and put "issue" within the brackets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -52,6 +52,8 @@ This article provides information about the changes in Firefox 106 that will aff

## Changes for add-on developers

- The `object-src` directive in the `"content-security-policy"` manifest key is now optional in Manifest V3. This is because the `object-src` directive is only required for browsers with obsolete [plugins](/en-US/docs/Glossary/Plugin), and browsers enabling Manifest V3 don't contain such plugins. See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The `object-src` directive in the `"content-security-policy"` manifest key is now optional in Manifest V3. This is because the `object-src` directive is only required for browsers with obsolete [plugins](/en-US/docs/Glossary/Plugin), and browsers enabling Manifest V3 don't contain such plugins. See W3C Web Extensions issue [204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})
- The `object-src` directive in the `"content-security-policy"` manifest key is now optional. This only existed to restrict obsolete [plugins](/en-US/docs/Glossary/Plugin), whose support has been dropped a long time ago from Firefox. See W3C Web Extensions CG [issue 204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})

The change is not MV3-specific. In the documentation, I mentioned the potential need for keeping it in MV2 in case an extension dev wants to be backwards-compatible with older versions. MV3 is already backwards incompatible, so the concern does not apply there.

The reference to the WECG has been repeated 4 times. It may make sense to create one subsection that explains the background (feel free to use information from the WECG issue) and then refer to that from the docs and changelog.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regard to the repetition of the WECG reference, given that we're talking about something that is no longer required, adding a specific section seems unnecessary. On the content–security-policy page, maybe we could remove the second two references and just keep the first one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's no longer required in Firefox nor Firefox.

However, it has been required for a many years in Firefox, and continued to be required in Chrome if one wants to customize the CSP. Documentation and examples will most likely include object-src, so some documentation of the history and an explicit statement that it's not required would be nice.

FYI:

  • This only affects extensions that want to customize the CSP in the manifest file.
  • In older Firefox, if it wasn't specified, the whole policy was ignored and the default CSP would be applied instead. The bad thing about this if the extension had specified a more stricter CSP in other parts (e.g. default-src, frame-src, etc), that it would be ignored.
  • In Chrome, if it's missing or deemed insecure, the object-src directive is replaced with the default (object-src 'self'), and a warning message is logged. Now that I'm writing this out, this behavior doesn't sound too bad.
  • In Safari there is no object-src requirement. IIRC this defaults to 'self'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rob--W I've now created a separate section to deal with object-src, please take a look and let me know if this is good to go.

@rebloor rebloor requested a review from Rob--W September 29, 2022 22:34
@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2022

Preview URLs

External URLs (3)

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy
Title: content_security_policy

(this comment was updated 2022-10-03 22:07:51.614676)

Copy link
Member

@Rob--W Rob--W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ for accuracy, please address the two minor issues before merging though.

@@ -52,6 +52,8 @@ This article provides information about the changes in Firefox 106 that will aff

## Changes for add-on developers

- The `object-src` directive in the `"content-security-policy"` manifest key is now optional. The `object-src` directive was designed to restrict obsolete [plugins](/en-US/docs/Glossary/Plugin), and support for these plugins was dropped from Firefox some time ago. See W3C WebExtensions Community Group [issue 204](https://github.com/w3c/webextensions/issues/204), Remove object-src from the CSP (at least in MV3), for more information. ({{bug(1766881)}})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you simplify this and refer to your new section?


- The {{CSP("script-src")}} directive must include at least the `'self'` keyword, and may only contain secure sources. The set of permitted secure sources differ between Manifest V2 and Manifest V3.
- The policy may include just {{CSP("default-src")}} (without {{CSP("script-src")}}) if its sources meet the requirement for the {{CSP("script-src")}} directive.
- The {{CSP("object-src")}} keyword may be required in some browsers that support obsolete [plugins](/en-US/docs/Glossary/Plugin). If required, it should be set to a secure source such as `'none'`. This may be required for browsers up until 2022 ([more information](https://github.com/w3c/webextensions/issues/204)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep/shorten the bullet point instead of removing it? It's part of the bullet list (connected to the previous point), which is supposed to be a complete list.

Do refer to the new section.

@rebloor
Copy link
Contributor Author

rebloor commented Oct 3, 2022

Thanks @Rob--W I've made the changes you requested will merge.

@rebloor rebloor merged commit f9c963c into mdn:main Oct 3, 2022
@rebloor rebloor deleted the object-src-not-supported branch October 3, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Other Any docs not covered by another "Content:" label Content:WebExt WebExtensions docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants