PTK SAST test cases — DOM scenarios

Total scenarios: 23

Each page focuses on a specific DOM sink or data-flow pattern and now follows a unified layout. Use the cards below to jump straight into inline vs. external variants, summaries, and safe counter-examples.

Back to main"

Cookies

Cookie security

Cookie mutations, leakage vectors, and safe configurations across inline and external scripts.

HTML sinks

document.write / writeln

Direct writes, cross-source payloads, dynamic wrappers, and delegated event handlers.

HTML sinks

innerHTML

Inline cases plus external triggers for DOM sources, storage, and template-style builders.

HTML sinks

insertAdjacentHTML

Coverage for positional inserts, storage sources, and delegated handlers feeding raw markup.

DOM APIs

appendChild

Demonstrates DOM node construction from untrusted strings and safer text-node alternatives.

Dynamic execution

eval family

Classic eval, storage-driven payloads, string wrappers, and allowlisted JSON execution.

Dynamic execution

new Function()

Function constructor flows from multiple sources, builder patterns, and structured safe handling.

Dynamic execution

JavaScript injection (taint)

Exercises every javascript-injection-taint sink: string timers, execScript, jQuery globalEval/getScript, execCommand, createContextualFragment, crypto.generateCRMFRequest, and script.text.

Navigation

Open redirects

Open redirect sink with optional navigation, URL builders, and allowlist-focused mitigations.

Navigation

Link manipulation

Anchor href tampering, delegated setters, storage sources, and safe allowlisted normalisation.

Messaging

Web message handling

postMessage usage, origin validation pitfalls, wildcard targetOrigin, and structured payload hardening.

Selectors

DOM selector injection

CSS selector taint flows, wildcard postMessage helpers, weak origin checks, and escaped allow-list examples.

Data sinks

Client-side JSON / SQL / XPath

eval-based JSON parsing, WebSQL concatenation, XPath with raw user input, plus safe validation patterns.

Ajax

Ajax request headers

XHR header manipulation, wildcard postMessage listeners, and header allow-list examples.

DOM data manipulation

DOM data manipulation

formAction/target/method/value/placeholder, style/cssText/background*, document.title, history state, createHTMLDocument.

Static analysis

Secrets fixture

Comment and string literals containing fake secrets to test token-detection rules and heuristics.

Service Worker

Cache poisoning

Fetch handlers writing attacker-controlled requests into caches and redirecting with untrusted URLs.

Templates

Client template injection

Dynamic templates compiled from tainted sources and injected into the DOM.

Auth tokens

JWT client misuse

Tokens sourced from URL/cookies written to storage and headers without validation.

Storage

Storage security

Untrusted data persisted into localStorage/sessionStorage/IndexedDB sinks.

Prototype

Prototype pollution

Client-side prototype mutation via untrusted data flowing into __proto__/setPrototypeOf/assign.

DOM

DOM clobbering

id/name collisions crafted through tainted HTML/attributes to shadow globals.