-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Clarify threat model, "XSS first and foremost" #188
Comments
The sanitizer should take care of shadow roots. I think it makes sense for it to recurse into them. As there's currently no way to remove a shadow root from a shadow host. Not dropping PI might allow XSLT (although that wouldn't work in subtrees). |
Agree on shadow roots. Also agree that XSL transformations are XSS-equivalent. As I read it, XSLT wants a PI with a target |
Yeah. I was thinking later on that we should "Assert" https://infra.spec.whatwg.org/#assertions that the node is not CDATA or PI as the HTML parser cannot return those and for now we'd only run on HTML parser output. When there is an endpoint that can contain those we can carefully evaluate again as we'd also need to consider some other angles at that point anyway. That leaves your first bullet point and I'm less clear on that. allowUnknownMarkup seems like a potential forward compatibility problem and as such probably safer to remove by default. allowCustomElements sits between safe and unsafe. We don't know what the JS implementation will do and how vulnerable it is. I'd lean towards removing by default still. allowComments was also safer to remove based on discussion I thought. In particular because they have been a common mutated XSS vector in the past. |
allowComments / XSS: I believe this problem only occurrs when re-parsing, which the API discourages. If there's any XSS that involves comments but doesn't involve re-parsing, I'd be eager to learn more. custom elements: I see the point, and it makes sense to me, but this surely isn't "XSS first and foremost". unknown markup/compatibility: This one I just don't understand. If browsers add new markup that is inherently script-y, e.g. a new event handler, then -- regardless of compatibility -- the Sanitizer will drop it. There is no way to remain compatible and still maintain the security properties. In all other cases -- new markup that isn't inherently script-y -- it would seem that default-true would be the option that preserves existing behaviour. What I'm trying to figure out with this issue is the threat model we're trying to uphold. What I understood from issue #183 is that we re-focus on XSS, and drop any of the not-XSS-but-maybe-drop-anyway bits, at least from the default config. (I'll quote from that discussion: "We all know there is a shared understanding of the threat model 'no XSS'. Everything else seems to be quite app-specific with a lot of 'grey-area'." ) What I understand here is that... all the "grey-area" is back. And what I understood from issue #185 is that apparently it's all optional anyhow. I really think we need to have a shared consensus on the threat model and security requirements for the sanitizer. I increasingly view this as a blocker for this whole project. |
Let's be clear, unless Chrome unships this I don't think you are in a position to talk about blockers. Personally I think there is some room for nuance here, and erring on the safe side seems better unless there is a clear benefit to not doing so, which I don't think there is here. |
It was clarified to me that
|
Don't I agree that they have no effect when a whitelist is being used, but... |
You mean blocklist and allow/safelist? I don't see that in https://wicg.github.io/sanitizer-api/#sanitize-action-for-an-element. |
It's not explicitly mentioned in the steps, but currently (assuming a blocklist is being used):
If the settings are removed or defaulted to true, then custom/unknown elements not on the blocklist will then be allowed through, which is a behaviour change. If that's acceptable, then fine, I just thought your comment of " (Though admittedly on review Chrome/Edge use an allowlist by default, so if those are the only config options you are changing then indeed they don't matter.) |
In the meeting it was clarified that the issue around XSS is essentially whether we overall have a safelist or a blocklist by default (for both elements and attributes alike). I very much think we should have a safelist.
I think it's okay to have an opt-in to allow custom elements, unknown elements, and unknown attributes, although I'm less keen on unknown elements and attributes given the forward extensibility risk they present. I suggest we offer tri-states to configure each of them: not allowed, only allowed when explicitly safelisted, and all allowed. If you set all of these to "all allowed" you'd essentially end up with the blocklist. Given the safety concerns with that perhaps the naming should reflect that as well. I think the same logic applies to comments, though a tri-state doesn't make sense for them. (Although maybe if we end up adding node parts...) |
In your opinion, is it ok to have an opt-it to allow all custom elements, without needing to specify them? Same question for the other groups. |
That's what the tri-state I mentioned offers, but I'm less convinced it's a good idea for unknown elements/attributes. Seems very reasonable for custom elements though. |
I think that makes sense, thanks for clarifying. The important part for me is that it is possible to specify a config that e.g. enables all unknown attributes, or unknown elements while still being able to use the safe variant of the entry point (because that's not directly enabling XSS via platform features), which would now imply that default != baseline. To bikeshed a bit more - I'm not sure if we shouldn't have a separate tri-state group for data- attributes (vs controlling them together with all unknown attributes) - or just allow |
I think being able to control |
IIRC, we mentioned this in one of the recent meetings as still having several open sub-issues. My current take is:
I think open issues are:
I changed my opinion on A while ago, colleagues analyzed sanitizer usage "in the wild", and I circled back with them: There were several usages for explicitly allowing any I do think the dual safe/unsafe methods make this issue much easier, in that users or libraries can still build the functionality they want (using the unsafe variant; but then need to take the responsibilities for the security properties themselves. This didn't exist when we originally discussed this.) This IMHO makes it much easier to do the simple thing first, and potentially expand the API later when we have more insight into real-world usage. |
Looks like we discussed this in a synchronous meeting but never wrote it down here. Sigh.
comments Unknown markup (elements and attributes) Custom Elements Another note: Ergonomics of (dis)allowing non-finite sets (e.g., data- and custom elements) |
With the summary above, I think we can we label this issue as "ready to be written in the spec". |
I'm pretty sure the reason we decided to add a toggle for (I'm writing this down here as I was again questioning why we ended up where we ended up.) |
@mozfreddyb the one thing we haven't settled on is the exact API (IDL) to use, but I suppose that can be discussed as part of a PR. |
You're right. Some of thus discussed this again in our Feb 21st meeting, and aligned on The reasoning being:
|
This is a follow-up to #183. As I understand that issue, we would like to tighten the Sanitizer threat model to be specifically about XSS / script injection, with anything else being optional. This would have several consequences for the API in general:
Baseline and default would be XSS-focused, and would not be different concepts anymore. The distinction would just drop out. #183 covers this.
Additional cleanup items:
allowShadowRoots
. It seems that discussion gravitates towards default-true anyhow, but.. that'd also be default-true?The text was updated successfully, but these errors were encountered: