Skip to content

Conversation

@mozfreddyb
Copy link
Collaborator

@mozfreddyb mozfreddyb commented Oct 31, 2025


Preview | Diff

@mozfreddyb mozfreddyb force-pushed the improved-threat-mode-descr-fix-287 branch from 5e625d3 to db63861 Compare October 31, 2025 15:50
@mozfreddyb mozfreddyb force-pushed the improved-threat-mode-descr-fix-287 branch from db63861 to 3a5c90f Compare October 31, 2025 15:51
index.bs Outdated

# Security Considerations # {#security-considerations}

The Sanitizer API is intended to prevent DOM-based Cross-Site Scripting
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the heading below we just use "XSS". We should probably be somewhat consistent in this document about that. And we might also need a reference for this term I suppose if we want to use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is MDN an acceptable reference for web specifications?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe, because it's only for non-normative text. But it gets kinda circular and doesn't seem ideal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do you think we need to define it ourselves instead?

index.bs Outdated
Comment on lines 1578 to 1582
: `<math>` MathML math
:: The reasoning for the inclusion of MathML is solely based on [[SafeMathML]].
: `<svg>`
:: This element is not allowed, because it leads to HTTP requests to arbitrary hosts.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we did allow some Math and SVG by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • MathML is some allowed as can only be seen when following the reference. I'll make it explicit
  • You're right and I think I got that wrong. Will correct this in a follow-up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The PR is getting a bit too unwieldy for my personal preference. I'll do the SVG/MATHML/HTML tables in a follow-up

…s in a cohesive way with a table and footnotes.
Copy link
Collaborator

@annevk annevk left a comment

Choose a reason for hiding this comment

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

I'm not sure how I feel about the "Index" section. It largely duplicates the existing lists, with some words added. That would probably be better inline?

@mozfreddyb
Copy link
Collaborator Author

I'm not sure how I feel about the "Index" section. It largely duplicates the existing lists, with some words added. That would probably be better inline?

Well, I guess we need a place for detailed reasoning that's going to come in the #354 follow-up. I can add this to Security Considerations instead if that's preferable?

<tr>
<td><code>object</code></td>
<td>http://www.w3.org/1999/xhtml</td>
<td>This element is disallowed because it can include other, untrusted documents and including scripts.</td>
Copy link
Collaborator

@evilpie evilpie Nov 6, 2025

Choose a reason for hiding this comment

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

"including scripts" doesn't seem grammatically correct to me.


While the Sanitizer aims to disallow Cross-Site Scripting attacks [[XSS]], the default
settings are a bit stricter and do not include elements that may change page
settings, layout or fetch resources from other origins. The following elements
Copy link
Collaborator

@evilpie evilpie Nov 6, 2025

Choose a reason for hiding this comment

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

We don't/can't really differentiate between fetching resources from same vs. other origins, so this seems too specific.

## Elements and attributes not allowed in the default config ## {#default-disallowed-elements}

While the Sanitizer aims to disallow Cross-Site Scripting attacks [[XSS]], the default
settings are a bit stricter and do not include elements that may change page
Copy link
Collaborator

Choose a reason for hiding this comment

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

"a bit" feels a bit off here. Maybe "the default settings are purposefully stricter"

@evilpie
Copy link
Collaborator

evilpie commented Nov 6, 2025

The definition of the kinds of XSS we try to prevent is central to defining our threat model, so I would prefer if it was clearly laid out as part of the specification instead of a link to MDN.

the construction of a Sanitizer object that leaves script-capable markup in
and doing so would be a bug in the threat model.
The Sanitizer API is intended to prevent DOM-based Cross-Site Scripting [[XSS]]
by traversing supplied HTML content and removing elements and attributes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe clarify that sanitzation happens before inserting. E.g.:

[...] by traversing supplied HTML content, after parsing but before insertion into any document, and removing [...]

I think this is obvious to us, but I think a lot of people haven't entirely thought through the "when" aspect of sanitiaztion.


The Sanitizer API offers only functions that turn a string into a node tree.
The context is supplied implicitly by all sanitizer functions:
The Sanitizer API offers functions that combine parsing, sanitization and insertion.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is very true. I wonder if it bears saying at the top of this section, in the paragraph "The Sanitizer API is intended to [...]". Maybe instead of the comment I've proposed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document threat models

4 participants