DOM Clobbering Websites - Micro Benchmarks - 6

Description: Explore how DOM properties can be manipulated for benchmark testing in browser environments.

Source:

Type: API-TYPE-1

Code:

document.getElementsByTagName('iframe')[0].src

Sink:

Type: XSS

Code:

document.createElement('script').src

Testing Code:

* @Name: getElementByTagName-src.js
 * @SourceType: API-TYPE-1
 * @SourceCode: document.getElementsByTagName('iframe')[0].src
 * @SinkType: XSS
 * @SinkCode: document.createElement('script').src
 */

// Create the necessary HTML element
let iframeSource = document.createElement('iframe');
iframeSource.src = 'https://example.com';
iframeSource.style.display = 'none';
document.body.appendChild(iframeSource);

// JavaScript to create and append the source element
let source = document.createElement('source');
let src = document.getElementsByTagName('iframe')[0].src;
source.src = src;
document.body.appendChild(source);

Other Tests