DOM Clobbering Websites - Micro Benchmarks - 5

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

Source:

Type: API-TYPE-1

Code:

document.getElementsByName('source')[0].value

Sink:

Type: XSS

Code:

document.createElement('script').src

Testing Code:

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

// Create the necessary HTML element
let inputSource = document.createElement('input');
inputSource.type = 'hidden';
inputSource.name = 'source';
inputSource.value = 'https://example.com/script.js';
document.body.appendChild(inputSource);

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

Other Tests