Skip to content

Plan to fix all current CVEs #38

@Pierstoval

Description

@Pierstoval

As of this statement in #7:

I haven't checked, but are the current CVEs resolved on the fork?

They are related to XSS flaws:

We know the CVEs are not fixed yet on Materialize, and there are already discussions in the original repository (Dogfalo#6331 and Dogfalo#6286) about this subject.

Current situation

Since the current CVEs are related to XSS that can be triggered when Materialize is used in a bad manner, this is the developer's responsibility to sanitize their data before using the three aforementioned components.

However, since the warnings will still display, and since Materialize can be "considered harmful" because of these (even though the discussions on the original repo suggest that it's not Materialize's problem, but rather how devs are using it), we should still find solutions to fix the warnings in an easy and backwards-compatible manner.

This is important for some CI that don't accept dependencies with warnings, or for clients that are worried about warnings they might not understand, especially when it's written "XSS" in them (which is a well-known flaw on the web in general)

Proposal

I suggest that for all the three involved components we add a boolean sanitizeInput option.

When this option is true, the input data will be sanitized with an equivalent of htmlspecialchars() in PHP. There are plenty examples about this on the internet, the best one I found is this one here:

function escapeHtml(text) {
  var map = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;'};
  
  return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}

Suggestions on other sanitizing methods are encouraged, since this has never been a "standard" process in the web industry 😄 .

Behavior on Materialize 1.x

This option will by default be null. To keep backwards compatibility, null will be equivalent to false.

However, if we detect null, we display a warning in the console, as a reminder to the developer that the native behavior of not-sanitizing is deprecated, and default value will change in 2.x to true.
To remove the warning, we suggest the user to specify the value themselves, even if it's false.
An explicit false will not trigger the warning, since this means that the developer knows what they are doing, and in such case, Materialize cannot guarantee input data safety.

Behavior on the future Materialize 2.x branch

Here, default value is true, and any falsy value will be interpreted as false. We could add type checks to force the user to specify a boolean, but I think this might be overkill. Suggestions appreciated 😉


Feel free to discuss all the different points, and even provide PRs if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions