← Back to index

DOM-based test cases — DOM data manipulation sinks

High: 2 Medium: 1 Low: 0 Safe: 0 Total: 3

These scenarios intentionally wire tainted DOM inputs (hash, query, cookies, storage, history, window.name) into the specific sinks covered by dom-data-manipulation-taint: form metadata (action/target/method/formAction/value/placeholder), inline styles (style/cssText/background), document title, history state, and createHTMLDocument. Script/Eval/handler sinks are intentionally omitted so that this page only exercises the dom-data-manipulation module.

Inline scenarios

INLINE-1 (High): DOM/storage → form metadata/value/placeholder
// inline-script[#1]
function inlineRewriteFormMetadata() {
  const form = document.getElementById('inline-profile-form');
  const input = document.getElementById('inline-profile-input');
  const submitBtn = document.getElementById('inline-submit-btn');
  const destField = document.getElementById('inline-user-url');
  const methodField = document.getElementById('inline-method-source');
  const placeholderField = document.getElementById('inline-placeholder-source');

  const dest = destField.value || location.hash.slice(1) || getCookieByName('ptk_dest') || '/api/profile';
  const method = methodField.value || new URLSearchParams(location.search).get('method') || 'post';
  const placeholder = placeholderField.value || window.name || 'Enter value';
  const storedPayload = sessionStorage.getItem('profilePayload') || document.cookie || 'stored=value';

  form.target = window.name || '_self';
  form.method = method;
  input.value = storedPayload;
  input.placeholder = placeholder;
  submitBtn.formAction = `${dest}?submit=1`;
}
inlineRewriteFormMetadata();
INLINE-2 (Medium): localStorage/hash → style/cssText/background
// inline-script[#2]
function inlineApplyTaintedStyles() {
  const button = document.getElementById('inline-style-button');
  const card = document.getElementById('inline-themed-card');
  const cssField = document.getElementById('inline-style-source');
  const imageField = document.getElementById('inline-style-image');
  const storedButtonStyle = localStorage.getItem('buttonStyle');
  const storedCardCss = localStorage.getItem('cardCss');

  button.setAttribute('style', cssField.value || storedButtonStyle || "background:#444;color:#fff;");
  card.style.cssText = storedCardCss || "background:#fee;border:2px dashed #c00;padding:1rem;";
  card.style.backgroundImage = `url(${imageField.value || location.hash.slice(1) || window.name })`;
}
inlineApplyTaintedStyles();
Awaiting themed card CSS…
INLINE-3 (High): Cookies/hash → history/title/createHTMLDocument
// inline-script[#3]
function inlineMutateHistory(run = false) {
  if (!run) return;
  const sourceField = document.getElementById('inline-history-source');
  const payload = sourceField.value || document.cookie || location.hash.slice(1) || "history-demo";

  history.pushState({ jump: payload }, payload, payload);
  document.title = payload;
  document.implementation.createHTMLDocument(payload);
}
inlineMutateHistory(false);
Only dom-data-manipulation sinks are touched: document.title, history.pushState, createHTMLDocument.