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

[8.0] Remove support for configuring csp.rules #114379

Merged

Conversation

TinaHeiligers
Copy link
Contributor

@TinaHeiligers TinaHeiligers commented Oct 7, 2021

Related to #103915

Removes support for csp.rules

CSP misconfiguration is a regular cause of frustration for users and support tickets and to help alleviate the issue, we implemented additive configuration. Configuring csp.rules was deprecated at the same time with a warning that support for the configuration would be removed in 8.0.

This PR removes support for configuring csp.rules and as a consequence.
As a consequence, this PR also handles the conditional config deprecation on specific rules (can't include nonce, must include self introduced in 7.4)

Note: The underlying implementation remains the same in that we combine the default Kibana rules with specific, per-directive configurations to compose the http request header.

Checklist

  • Documentation was added for features that require explanation or tutorials
  • Document change in breaking changes
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be added to/removed from the docker list
  • This was checked for cross-browser compatibility (Firefox, Chrome, Safari only)
    If a plugin configuration key changed, check if it needs to be allowlisted in the cloud
  • allowlist

For maintainers

Release Note

Support for the csp.rules configuration property has been removed in favor of directive specific configuration. Configuring the default csp.script_src, csp.workers_src and csp.style_src values is not required.

@TinaHeiligers TinaHeiligers added backport:skip This commit does not require backporting release_note:breaking v8.0.0 labels Oct 8, 2021
@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

@TinaHeiligers TinaHeiligers marked this pull request as ready for review October 8, 2021 06:40
@TinaHeiligers TinaHeiligers requested review from a team as code owners October 8, 2021 06:40
Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

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

kibana-docker LGTM

@TinaHeiligers TinaHeiligers added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Oct 8, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@TinaHeiligers TinaHeiligers added the Feature:Security/CSP Platform Security - Content Security Policy label Oct 8, 2021
@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@jportner jportner left a comment

Choose a reason for hiding this comment

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

LGTM, found a couple of tiny nits in the comments below. Also one more in the dev docs but GitHub won't let me add comments on unchanged sections. Suggested change:

diff --git a/docs/setup/settings.asciidoc b/docs/setup/settings.asciidoc
index 6d086de63c3..88d8b7f9da5 100644
--- a/docs/setup/settings.asciidoc
+++ b/docs/setup/settings.asciidoc
@@ -495,8 +495,8 @@ To disable, set to `null`. *Default:* `null`
 | Controls whether the https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy[`Content-Security-Policy`] and
 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options[`X-Frame-Options`] headers are configured to disable embedding
 {kib} in other webpages using iframes. When set to `true`, secure headers are used to disable embedding, which adds the `frame-ancestors:
-'self'` directive to the `Content-Security-Policy` response header (if you are using the default CSP rules), and adds the `X-Frame-Options:
-SAMEORIGIN` response header. *Default:* `false`
+'self'` directive to the `Content-Security-Policy` response header and adds the `X-Frame-Options: SAMEORIGIN` response header. *Default:*
+`false`
 
 | `server.customResponseHeaders:` {ess-icon}
  | Header names and values to

src/core/server/csp/csp_config.ts Outdated Show resolved Hide resolved
this.#directives.clearDirectiveValues('frame-ancestors');
this.#directives.addDirectiveValue('frame-ancestors', `'self'`);
}

this.rules = this.#directives.getRules();
Copy link
Contributor

Choose a reason for hiding this comment

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

This class was the only consumer of CspDirectives.getRules(). I don't suppose we ever actually needed to expose the individual rules anyway, we really just needed to expose the CSP header.

Nit: Since you've removed this usage here, you could remove that method from the CspDirectives class (or just make it private) and remove those assertions from its unit tests, too.

Copy link
Contributor Author

@TinaHeiligers TinaHeiligers Oct 11, 2021

Choose a reason for hiding this comment

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

True, there's no need to keep getRules since we are only using it within the CspDirectives class. I've removed it (inlining directly in getCspHeader) and updated the tests.

src/core/server/config/deprecation/core_deprecations.ts Outdated Show resolved Hide resolved
src/core/server/csp/config.ts Outdated Show resolved Hide resolved
@TinaHeiligers TinaHeiligers enabled auto-merge (squash) October 11, 2021 19:39
@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

@tylersmalley
Copy link
Contributor

@elasticmachine merge upstream

@TinaHeiligers
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
core 1019 1018 -1
Unknown metric groups

API count

id before after diff
core 2300 2298 -2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@TinaHeiligers TinaHeiligers merged commit 44c9611 into elastic:master Oct 12, 2021
@TinaHeiligers TinaHeiligers deleted the kbn-103915-remove-csp-rules branch October 12, 2021 00:59
artem-shelkovnikov pushed a commit to artem-shelkovnikov/kibana that referenced this pull request Oct 20, 2021
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Security/CSP Platform Security - Content Security Policy release_note:breaking Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants