CYBER LIBRARY
Explore the bootcamp
Adversarial thinkingIntermediate

Cross-site scripting

Untrusted content can become executable code in another user’s browser.

3 min readUpdated 12 Oct 202612 connections
Markdown

The idea

Cross-site scripting occurs when untrusted content is handled in a way that allows browser-side code execution in an application context. Reflected, stored, and DOM-based cases describe different paths. Defenses include context-appropriate output encoding, safe rendering APIs, and sanitization where rich content is required. Content Security Policy can add a layer but does not replace correct handling. Demonstrations belong in authorized labs.

In practice

A note renderer displays a submitted string as text instead of inserting it into an unsafe HTML execution context.

A common misunderstanding

One encoding rule is not safe for every HTML, attribute, URL, JavaScript, or CSS context.

Check your understanding

What is the central defensive distinction?

Think it through: Treat untrusted content as data, and use safe APIs or appropriate encoding for its actual output context.

Follow content into the browser

A fictional community site displays learner biographies in a profile, a search result, and a moderator dashboard. The same biography reaches three rendering paths. A safe profile renderer does not establish that the dashboard is safe, especially if it uses an older rich-text component. Review the final browser operation at every destination rather than assuming a single input filter protects the whole journey.

Stored XSS describes content retained for later display. Reflected XSS involves content returned in a response associated with a request. DOM-based XSS concerns unsafe client-side handling. These descriptions can overlap; they help locate the data flow rather than providing mutually exclusive labels for every application. What matters for remediation is identifying the source, transformation, and unsafe rendering operation.

The effect is broader than reading a cookie. Browser code running in the application's origin may interact with page data or make permitted authenticated requests. An HttpOnly cookie limits direct script access to that cookie, but does not make arbitrary script execution harmless. Authorization and sensitive-operation confirmation still matter.

Demonstrate text handling safely

In a local sample page, submit a harmless string containing angle brackets and inspect whether it appears as literal text or becomes an element. Compare a framework's ordinary text rendering with an explicitly unsafe HTML insertion feature. Explain why the product would need a sanitizer if it intentionally supports formatted biographies.

A good finding names the affected renderer and who can supply the content. Include whether another user must visit a page, whether the content persists, and the permissions available in that context. Retest every affected display location after the fix. The lesson is to preserve a clear boundary between user content and application behavior throughout rendering.

Keep exploring

GO TO THE SOURCE

References & further reading

Original explanations, with primary references for deeper study.

OWASP: Web Security Testing Guide
EXPLORE THIS IDEA’S CONNECTIONS

A small part of a bigger picture.

11 notes · 20 connections
100%
Cross-site scripting · depth 1
Drag to pan · Pinch or use +/− to zoom · Click to preview · Double-click to read
Browse notes as a list (11)
FOLLOW ANOTHER THREADExplore the rest of the library
Start with a concept. Follow its connections.
Detection & responseAbuse Elevation Control MechanismElevation-control abuse bypasses or misuses mechanisms governing privileged execution.Making change happenAcceptance criteriaDefine observable conditions for a deliverable to be accepted.Security essentialsAccess controlUnderstand subjects, resources, permissions, and enforcement through a shared-drive example, including how access changes over time.Detection & responseAccess Token ManipulationAccess token manipulation changes or adopts operating-system security contexts.Risk & resilienceAccount Access RemovalAccount access removal disrupts legitimate users by changing, deleting, or restricting their identities.Evidence & investigationAccount DiscoveryAccount discovery enumerates identities available in a system or environment.Detection & responseAccount ManipulationAccount manipulation changes identity settings to preserve or expand access.Adversarial thinkingAcquire InfrastructureInfrastructure acquisition obtains domains, servers, or other resources used to support operations.Adversarial thinkingActive ScanningActive scanning probes target infrastructure to learn reachable services or weaknesses.Security essentialsAdversary in the middleAn intermediary may observe or alter a communication path.Security essentialsAESA symmetric block cipher whose safe use depends on its mode and implementation.Making change happenAgile deliveryUse short feedback cycles to adapt toward a useful outcome.