Closed Bug 1941347 Opened 6 months ago Closed 3 months ago

Escape "<" and ">" in attributes when serializing HTML

Categories

(Core :: DOM: Core & HTML, task)

task

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
firefox136 --- wontfix
firefox139 --- fixed

People

(Reporter: zcorpan, Assigned: tschuster)

References

Details

(Keywords: dev-doc-complete, sec-want, Whiteboard: [adv-main139-])

Attachments

(1 file)

See https://github.com/whatwg/html/issues/6235

Chromium is doing a staged rollout of this, currently at 1%, and haven't found compat problems so far.

We should implement this as well, since it helps to mitigate mutation XSS (mXSS) attacks.

Now at 3% :)

Keywords: sec-want
Assignee: nobody → tschuster

I am only modifying nsContentUtils::SerializeNodeToMarkup here. We have some older serializers based on nsIContentSerializer, which as far as I can tell already escape < and >, at least when escaping at all.

nsXMLContentSerializer::AppendAndTranslateEntities seems to escape it, which is also used for nsXHTMLContentSerializer::AppendAndTranslateEntities unless all entity encoding is disabled.

Attachment #9475965 - Attachment description: WIP: Bug 1941347 - Escape "<" and ">" in attributes when serializing HTML → WIP: Bug 1941347 - Escape "<" and ">" in attributes when serializing HTML.
Depends on: 1691006
See Also: 1691006
Depends on: 1960896
Attachment #9475965 - Attachment description: WIP: Bug 1941347 - Escape "<" and ">" in attributes when serializing HTML. → Bug 1941347 - Escape "<" and ">" in attributes when serializing HTML. r?#dom-core-reviewers
Pushed by tschuster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d176c8bbf229 Escape "<" and ">" in attributes when serializing HTML. r=dom-core,devtools-reviewers,nchevobbe,hsivonen
Blocks: 1962084
Keywords: dev-doc-needed
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
Blocks: 1691006, 1960896
No longer depends on: 1691006, 1960896
QA Whiteboard: [qa-triage-done-c140/b139]

FF139 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/39309

The pref is Nightly-only, isn't it?

The pref is Nightly-only, isn't it?

That's how it looks and how I have documented it

+# Serialize < as < and > as > in attribute values for getHTML, innerHTML etc.
+- name: dom.security.html_serialization_escape_lt_gt

  • type: RelaxedAtomicBool
  • value: @IS_NIGHTLY_BUILD@
  • mirror: always
Whiteboard: [adv-main139-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: