PENTESYS POINT OF VIEW · ENGINEERING · 3 min read

Part of Validate insights →

XSS prevention across rendering and content workflows

Choose controls for the actual browser output context and check stored client-side and rich-content paths.

Technical review lead: James Hinton · Offensive security lead

OUR POSITIONKeep untrusted content from becoming executable browser behaviour; a single escaping function cannot be assumed to suit every context.

Keep untrusted content from becoming executable browser behaviour; a single escaping function cannot be assumed to suit every context.

01

Map where the browser receives untrusted content

Follow the information from its source through storage, transformation and rendering. A customer name, support note, imported record or URL fragment may reach several browser contexts. Identify whether it becomes ordinary text, an attribute, a URL, script-related data or rich HTML. The relevant control depends on that output path, not only on the form where the value first entered the system.

02

Prefer safe rendering by default

Use the framework's safe text-rendering behaviour and appropriate output handling for the intended context. Avoid unnecessary raw-HTML features and dangerous DOM operations. A framework can provide a useful default without protecting code that deliberately bypasses it. Review components, templates and client-side updates together so a safe initial response is not undermined by a later browser-side transformation.

03

Define the rich-content boundary

Where a feature intentionally accepts HTML, use a maintained sanitisation approach with a policy that matches the business need. Preserve the distinction between permitted formatting and executable behaviour. Check what later transformations do to the sanitised result. Do not assume a value that was safe for one display context remains safe after being inserted into another component or reconstructed by client code.

04

Use defence in depth without confusing its role

A suitable Content Security Policy can constrain some consequences, but it does not remove the need for safe rendering and context-aware handling. Keep important dependencies current and review application features that expand browser execution or content loading. Treat a browser control as one layer in the design rather than using its presence to close an unresolved unsafe rendering path.

05

Verify the complete workflow

Use authorised controlled records to check the original path and related displays, including administrative views, exports rendered in a browser and client-side updates. Confirm allowed formatting and legitimate content still work. Record the affected context and application version, and add regression tests at the appropriate rendering boundary. The useful closure evidence explains why untrusted data stays data throughout the relevant workflow.

Sources and further guidance

Start with the complete guide

Use the essential guide for the wider scope, process and buying context behind this analysis.

Read “Penetration testing: scope, process, costs and what happens after the report” →
Editorial note

This current engineering guide replaces the retired legacy topic. Apply the recommendations to the actual application and verify changes within an authorised scope.

TALK TO PENTESYS

Apply this guidance to your environment.

Tell us what you need to understand, test or prove. We'll help you choose a proportionate next step—without forcing the conversation into a predefined package.

Apply this to my environment →Explore Validate

More Pentesys analysis

Pentesys trust and assurance

Recognised credentials. Responsible AI. Experienced people.

Clear evidence of our company standards, testing services and access to AI programmes.

Independent company assurance

CREST member company for Penetration Testing in EMEA

CREST member company

Penetration Testing in EMEA. Company standards independently assessed by CREST.

Valid until 1 November 2026View company certificate
CREST Security Testing accreditation for penetration testing

CREST-accredited human-led penetration testing

Independent assurance for Pentesys’s human-led penetration-testing service.

Human-led testingView CREST listing

AI-enabled testing assurance

CREST accreditation for AI-enabled penetration testing

CREST-accredited AI-enabled penetration testing

Pentesys is one of the first ten companies worldwide accredited by CREST for AI-enabled penetration testing. The accreditation assesses the responsible, secure and appropriate use of AI in penetration-testing services.

AI-enabled penetration testingView CREST announcement

Responsible-AI commitment

CREST AI Charter signatory

CREST AI Charter signatory

A separate commitment to responsible, transparent and accountable use of AI in cybersecurity.

Responsible-AI commitmentAbout the CREST AI Charter

Secure organisational baseline

Cyber Essentials certified

Cyber Essentials certified

Pentesys is certified across the whole organisation against the Cyber Essentials baseline controls.

Recertification due 12 August 2027View Cyber Essentials certificate

Controlled AI programme access

Pentesys participates in Anthropic’s Cyber Verification Program (CVP) for Claude and has approved access to OpenAI Daybreak Blue.

Anthropic CVP for Claude

Participation in Anthropic’s Cyber Verification Program.

Programme participationAbout Anthropic CVP

OpenAI Daybreak Blue

Approved access for defensive cybersecurity work.

Approved programme accessAbout Daybreak Blue

CREST accreditation applies to Pentesys’s service delivery, not to an AI model, the Portal or an appliance.

Meet the expertise behind our testing