Skip to content

Commit

Permalink
Added some XSS sinks we initially overlooked.
Browse files Browse the repository at this point in the history
  • Loading branch information
leeN authored and tmbrbr committed Jul 6, 2023
1 parent 28a2fe3 commit d9c268e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5264,6 +5264,7 @@ already_AddRefed<DocumentFragment> nsContentUtils::CreateContextualFragment(
aRv.Throw(NS_ERROR_INVALID_ARG);
return nullptr;
}
ReportTaintSink(aFragment, "Range.createContextualFragment(fragment)");

// If we don't have a document here, we can't get the right security context
// for compiling event handlers... so just bail out.
Expand Down
11 changes: 11 additions & 0 deletions dom/html/HTMLFormElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2274,4 +2274,15 @@ void HTMLFormElement::MaybeFireFormRemoved() {
asyncDispatcher->RunDOMEventWhenSafe();
}

nsresult HTMLFormElement::CheckTaintSinkSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAString& aValue) {
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::action) {
nsAutoString id;
this->GetId(id);
ReportTaintSink(aValue, "form.action", id);
}

return nsGenericHTMLElement::CheckTaintSinkSetAttr(aNamespaceID, aName, aValue);
}

} // namespace mozilla::dom
3 changes: 3 additions & 0 deletions dom/html/HTMLFormElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ class HTMLFormElement final : public nsGenericHTMLElement,

nsresult DoReset();

virtual nsresult CheckTaintSinkSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAString& aValue) override;

// Async callback to handle removal of our default submit
void HandleDefaultSubmitRemoval();

Expand Down
4 changes: 4 additions & 0 deletions dom/html/HTMLIFrameElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ nsresult HTMLIFrameElement::CheckTaintSinkSetAttr(int32_t aNamespaceID, nsAtom*
nsAutoString id;
this->GetId(id);
ReportTaintSink(aValue, "iframe.src", id);
} else if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::srcdoc) {
nsAutoString id;
this->GetId(id);
ReportTaintSink(aValue, "iframe.srcdoc", id);
}

return nsGenericHTMLElement::CheckTaintSinkSetAttr(aNamespaceID, aName, aValue);
Expand Down
8 changes: 8 additions & 0 deletions dom/html/HTMLScriptElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,12 @@ bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
aType.EqualsLiteral("importmap"));
}

void HTMLScriptElement::SetTextContentInternal(const nsAString& aTextContent,
nsIPrincipal* aScriptedPrincipal,
ErrorResult& aError) {
nsAutoString id;
this->GetId(id);
ReportTaintSink(aTextContent, "script.textContent", id);
aError = nsContentUtils::SetNodeTextContent(this, aTextContent, true);
}
} // namespace mozilla::dom
3 changes: 3 additions & 0 deletions dom/html/HTMLScriptElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
[[nodiscard]] static bool Supports(const GlobalObject& aGlobal,
const nsAString& aType);

virtual void SetTextContentInternal(const nsAString& aTextContent,
nsIPrincipal* aSubjectPrincipal,
mozilla::ErrorResult& aError) override;
protected:
virtual ~HTMLScriptElement();

Expand Down

0 comments on commit d9c268e

Please sign in to comment.