Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: Source/core/dom/Document.cpp

Issue 141103006: Protect document.execCommand() from recursive call and DOM mutation events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2014-02-03T14:21:08 Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index ee1a346618b6b2e029f93a482ebdbb7caf402c7a..cdd382a7a842fa2779fc69e6526bb5d53bca45f6 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -4165,6 +4165,22 @@ static Editor::Command command(Document* document, const String& commandName, bo
bool Document::execCommand(const String& commandName, bool userInterface, const String& value)
{
+ // We don't allow recusrive |execCommand()| to protect against attack code.
+ // Recursive call of |execCommand()| could be happened by moving iframe
+ // with script triggered by insertion, e.g. <iframe src="javascript:...">
+ // <iframe onload="...">. This usage is valid as of the specification
+ // although, it isn't common use case, rather it is used as attack code.
+ static bool inExecCommand = false;
+ if (inExecCommand) {
+ String message = "We don't execute document.execCommand() this time, because it is called recursively.";
+ addConsoleMessage(JSMessageSource, WarningMessageLevel, message);
+ return false;
+ }
+ TemporaryChange<bool> executeScope(inExecCommand, true);
+
+ // Postpone DOM mutation events, which can execute scripts and change
+ // DOM tree against implementation assumption.
+ EventQueueScope eventQueueScope;
return command(this, commandName, userInterface).execute(value);
}
« no previous file with comments | « LayoutTests/fast/parser/nested-fragment-parser-crash-expected.txt ('k') | Source/core/editing/CompositeEditCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698