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

CONSOLE-4327: Add new API field to ConsolePlugin CRD for allowing additional CSP sources #1706

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jhadvig
Copy link
Member

@jhadvig jhadvig commented Oct 24, 2024

Add ConsolePluginCSP Field Documentation to ConsoleDynamicPlugin CRD Enhancement

This pull request updates the enhancement documentation for the ConsoleDynamicPlugin Custom Resource Definition (CRD) by introducing a new section that explains the ConsolePluginCSP field.

Link to the API change: openshift/api#2042

Summary of Changes:

  • New ConsolePluginCSP Field:

    • Adds the capability for dynamic plugins to define their own Content-Security-Policy (CSP) directives.
    • Describes how CSP directives can be used to mitigate security vulnerabilities like cross-site scripting (XSS) and data injection attacks.
  • Supported CSP Directives:

    • Outlines the supported CSP directives: DefaultSrc, ScriptSrc, StyleSrc, ImgSrc, and FontSrc.
    • Describes how the OpenShift web console backend merges these directives with its own default policies into a single CSP header.
  • CSP Directive Validation:

    • Implements validation rules to restrict the number of values for each directive.
    • Enforces value uniqueness.
    • Prohibits certain characters (commas, semicolons, whitespace, wildcard *) and specific formatting (values enclosed in single quotes).
  • Example Usage:

    • Provides an example that demonstrates how different plugins' CSP directives are merged into a unified policy for the OpenShift web console.

Why This Change?

The addition of this field to the ConsoleDynamicPlugin CRD enables plugin developers to configure secure policies for loading external resources while maintaining compliance with OpenShift’s security best practices. This change strengthens the ability to protect against potential vulnerabilities by enforcing clear rules for CSP configuration in dynamic plugins.

/assign @spadgett

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 24, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 24, 2024

@jhadvig: This pull request references CONSOLE-4265 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to this:

Add ConsolePluginCSP Field Documentation to ConsoleDynamicPlugin CRD Enhancement

This pull request updates the enhancement documentation for the ConsoleDynamicPlugin Custom Resource Definition (CRD) by introducing a new section that explains the ConsolePluginCSP field.

Link to the API change: openshift/api#2042

Summary of Changes:

  • New ConsolePluginCSP Field:

  • Adds the capability for dynamic plugins to define their own Content-Security-Policy (CSP) directives.

  • Describes how CSP directives can be used to mitigate security vulnerabilities like cross-site scripting (XSS) and data injection attacks.

  • Supported CSP Directives:

  • Outlines the supported CSP directives: DefaultSrc, ScriptSrc, StyleSrc, ImgSrc, and FontSrc.

  • Describes how the OpenShift web console backend merges these directives with its own default policies into a single CSP header.

  • CSP Directive Validation:

  • Implements validation rules to restrict the number of values for each directive.

  • Enforces value uniqueness.

  • Prohibits certain characters (commas, semicolons, whitespace, wildcard *) and specific formatting (values enclosed in single quotes).

  • Example Usage:

  • Provides an example that demonstrates how different plugins' CSP directives are merged into a unified policy for the OpenShift web console.

Why This Change?

The addition of this field to the ConsoleDynamicPlugin CRD enables plugin developers to configure secure policies for loading external resources while maintaining compliance with OpenShift’s security best practices. This change strengthens the ability to protect against potential vulnerabilities by enforcing clear rules for CSP configuration in dynamic plugins.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented Oct 24, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign adambkaplan for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 24, 2024

@jhadvig: This pull request references CONSOLE-4265 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to this:

Add ConsolePluginCSP Field Documentation to ConsoleDynamicPlugin CRD Enhancement

This pull request updates the enhancement documentation for the ConsoleDynamicPlugin Custom Resource Definition (CRD) by introducing a new section that explains the ConsolePluginCSP field.

Link to the API change: openshift/api#2042

Summary of Changes:

  • New ConsolePluginCSP Field:

  • Adds the capability for dynamic plugins to define their own Content-Security-Policy (CSP) directives.

  • Describes how CSP directives can be used to mitigate security vulnerabilities like cross-site scripting (XSS) and data injection attacks.

  • Supported CSP Directives:

  • Outlines the supported CSP directives: DefaultSrc, ScriptSrc, StyleSrc, ImgSrc, and FontSrc.

  • Describes how the OpenShift web console backend merges these directives with its own default policies into a single CSP header.

  • CSP Directive Validation:

  • Implements validation rules to restrict the number of values for each directive.

  • Enforces value uniqueness.

  • Prohibits certain characters (commas, semicolons, whitespace, wildcard *) and specific formatting (values enclosed in single quotes).

  • Example Usage:

  • Provides an example that demonstrates how different plugins' CSP directives are merged into a unified policy for the OpenShift web console.

Why This Change?

The addition of this field to the ConsoleDynamicPlugin CRD enables plugin developers to configure secure policies for loading external resources while maintaining compliance with OpenShift’s security best practices. This change strengthens the ability to protect against potential vulnerabilities by enforcing clear rules for CSP configuration in dynamic plugins.

/assign @spadgett

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

#### Validation Rules
- Each directive can have up to 16 unique values.
- The total size of all values across directives must not exceed 8192 bytes (8KB).
- Each value must be unique, and there are additional validation rules to ensure no quotes, spaces, commas, or wildcard symbols are used.
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume the controller will deduplicate if multiple ConsolePlugins do end up duplicating values, since we don't validate for duplications across multiple resources

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, this will be responsibility of the console-operator's controller 👍

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

Overall LGTM. @JoelSpeed let us know what you think.

@opayne1 We'll want to cover this in the console plugin docs and release notes.

`ConsolePlugin` introduces the ability for dynamic plugins to specify their own Content Security Policy (CSP) directives in the OpenShift web console, using the `ConsolePluginCSP` field in the `ConsolePluginSpec`. This field is crucial for mitigating potential security risks, such as cross-site scripting (XSS) and data injection attacks, by controlling which external resources the browser can load.

#### Content Security Policy (CSP) Overview
CSP is a security feature that helps detect and mitigate attacks by specifying which sources are allowed for fetching content like scripts, styles, images, and fonts. For dynamic plugins that require loading resources from external sources, defining custom CSP rules ensures secure integration into the OpenShift console.
Copy link
Member

Choose a reason for hiding this comment

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

I'd link out to the MDN documentation for Content Security Policy either here or above.

Copy link
Member Author

Choose a reason for hiding this comment

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

added below

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Changes are good, but, we don't have a plan for moving from TechPreview to GA. What requirements would you expect of this new feature/what testing would you want to see, before you're ready to ship, can that be added to the graduation criteria section?

(This is something we are trying to promote engineers to think more about at the moment, in an effort to deliver complete and quality features first time)

@jhadvig
Copy link
Member Author

jhadvig commented Oct 25, 2024

@JoelSpeed @spadgett I've added additional commit with the Graduation Criteria as suggested.
PTAL

Comment on lines 621 to 649
Note: Currently Console uses `Content-Security-Policy-Report-Only` instead of
`Content-Security-Policy` header. Due to that the browser will only warn about
Console CSP violations.
Copy link
Member

Choose a reason for hiding this comment

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

Should we discuss when we decide to turn on enforcement? It's an important date for plugins because they'll need to adopt these changes before it's enforced.

Copy link
Member

Choose a reason for hiding this comment

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

Let's talk about this @jhadvig and come up with a plan.

Copy link
Member Author

Choose a reason for hiding this comment

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

@spadgett so when discussed with @vojtechszocs there should be at least 2-3 releases before we flip the switch.
First we need to:

Probably there will be more steps that we need to meet, this is just how I see right now.

* Update the OpenShift official documentation to include detailed guidelines
on configuring `ConsolePluginCSP` in the `ConsoleDynamicPlugin` CRD, along with
recommendations.
* Add CSP feature to release notes.
Copy link
Member

Choose a reason for hiding this comment

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

We should document clearly when this will be enforced in the release notes.

on configuring `ConsolePluginCSP` in the `ConsoleDynamicPlugin` CRD, along with
recommendations.
* Add CSP feature to release notes.
* Extend e2e test suit for console-operator repository:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there interactions with other components at all? Do you think adding something to the origin test suite that runs across all PRs in openshift, to prevent other components causing regressions in this feature?

Copy link
Member

@spadgett spadgett Oct 28, 2024

Choose a reason for hiding this comment

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

Hey, @JoelSpeed. The two out-of-the-box console plugins enabled by default are the monitoring plugin and networking plugin. I think we should work with those teams to add Cypress tests for CSP violations in their plugins.

I'm hesitant to add it to the origin suite because we'd be exposing everyone to UI flakes when only a handful of components impact us, and it would mean introducing an entirely new library for UI testing (Cypress). In the past, we've targeted adding UI tests to specific repos we know can break console like the authentication and OLM.

cc @jgbernalp @tnisan

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with @spadgett 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable, please clarify that within the doc and when it comes to feature promotion, I'd expect to see links to tests that cover this outside of origin, and their results being green over a couple of weeks ideally

@jhadvig jhadvig changed the title CONSOLE-4265: Add new API field to ConsolePlugin CRD for allowing additional CSP sources CONSOLE-4327: Add new API field to ConsolePlugin CRD for allowing additional CSP sources Oct 29, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 29, 2024

@jhadvig: This pull request references CONSOLE-4327 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to this:

Add ConsolePluginCSP Field Documentation to ConsoleDynamicPlugin CRD Enhancement

This pull request updates the enhancement documentation for the ConsoleDynamicPlugin Custom Resource Definition (CRD) by introducing a new section that explains the ConsolePluginCSP field.

Link to the API change: openshift/api#2042

Summary of Changes:

  • New ConsolePluginCSP Field:

  • Adds the capability for dynamic plugins to define their own Content-Security-Policy (CSP) directives.

  • Describes how CSP directives can be used to mitigate security vulnerabilities like cross-site scripting (XSS) and data injection attacks.

  • Supported CSP Directives:

  • Outlines the supported CSP directives: DefaultSrc, ScriptSrc, StyleSrc, ImgSrc, and FontSrc.

  • Describes how the OpenShift web console backend merges these directives with its own default policies into a single CSP header.

  • CSP Directive Validation:

  • Implements validation rules to restrict the number of values for each directive.

  • Enforces value uniqueness.

  • Prohibits certain characters (commas, semicolons, whitespace, wildcard *) and specific formatting (values enclosed in single quotes).

  • Example Usage:

  • Provides an example that demonstrates how different plugins' CSP directives are merged into a unified policy for the OpenShift web console.

Why This Change?

The addition of this field to the ConsoleDynamicPlugin CRD enables plugin developers to configure secure policies for loading external resources while maintaining compliance with OpenShift’s security best practices. This change strengthens the ability to protect against potential vulnerabilities by enforcing clear rules for CSP configuration in dynamic plugins.

/assign @spadgett

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented Nov 1, 2024

@jhadvig: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants