Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -59478,7 +59478,8 @@ interface <dfn interface>HTMLSelectedContentElement</dfn> : <span>HTMLElement</s

<div class="note">
<p>DOM clobbering is a common cause of security issues. Avoid using the names of
built-in form properties with the <code data-x="attr-fe-name">name</code> content attribute.</p>
built-in form properties with the <code data-x="attr-fe-name">name</code> and <code
data-x="attr-id">id</code> content attributes.</p>

<p>In this example, the <code>input</code> element overrides the built-in <code
data-x="attr-fs-method">method</code> property:</p>
Expand All @@ -59491,9 +59492,23 @@ form.method; // => "get"
input.name = "method"; // DOM clobbering occurs here
form.method === input; // => true</code></pre>

<p>Since the input name takes precedence over built-in form properties, the JavaScript reference
<code data-x="">form.method</code> will point to the <code>input</code> element named "method"
instead of the built-in <code data-x="attr-fs-method">method</code> property.</p>
<p>The same issue occurs with the <code data-x="attr-id">id</code> attribute and the <code
data-x="attr-fs-enctype">enctype</code> property:</p>

<pre><code class="js">let form = document.createElement("form");
let input = document.createElement("input");
form.appendChild(input);

form.enctype; // => "application/x-www-form-urlencoded"
input.id = "enctype"; // DOM clobbering occurs here as well
form.enctype === input; // => true</code></pre>

<p>Since the input <code data-x="attr-fe-name">name</code> and <code data-x="attr-id">id</code>
take precedence over built-in form properties, the JavaScript references <code
data-x="">form.method</code> and <code data-x="">form.enctype</code> will point to the
corresponding <code>input</code> elements instead of the built-in <code
data-x="attr-fs-method">method</code> and <code data-x="attr-fs-enctype">enctype</code>
properties.</p>
</div>


Expand Down