Context-Sensitive Sanitization for Web Application XSS Prevention

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing sanitization techniques for preventing cross-site scripting vulnerabilities are ineffective due to mismatches between sanitizer sequences and browser parsing contexts, leading to inconsistent and unsafe sanitization errors, particularly in legacy web applications where modifications are costly or infeasible.

Innovation Solution

An automatic context-sensitive sanitization technique that analyzes web applications in a pre-deployment phase to identify and correct sanitizer sequences matching the browser parsing context, storing the corrected sequences in a cache, and applies them in a runtime phase using a path detector to ensure proper validation of untrusted inputs.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If sanitizers are manually placed in a web application by programmers, then the web application can have sanitization capability, but the sanitization may be incorrect due to mismatch with browser parsing context and limited developer security expertise

Engineering Contradiction:
Improvesanitization correctnessVSAvoidsanitization implementation complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent performs pre-deployment analysis to automatically determine the correct sequence of sanitizers and their placement positions before the web application is deployed. This preliminary action analyzes the web application's code structure, identifies untrusted input parameters, and calculates the appropriate sanitizer sequences based on browser parsing contexts, thereby eliminating the need for manual sanitization implementation and ensuring correctness.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The web application performs self-analysis and self-configuration of sanitization sequences through automated static analysis of its own code. The system automatically identifies where sanitization is needed, determines the correct sanitizer sequences, and generates configuration information without requiring external security experts or manual intervention, enabling the system to service its own security needs.

Inventive Principle:
Principle #25Self-service

2Reliability

If special primitives are added to encode HTML output safely, then cross-site scripting can be prevented, but modifications to the web application and web browser are required which are costly or infeasible for legacy applications

Engineering Contradiction:
Improvecross-site scripting preventionVSAvoidimplementation feasibility
Core Design Contradiction:
ReliabilityVSEase of manufacture

Solution Approach 1:

The patent introduces an intermediary component that acts as a bridge between the web server and the web browser. This intermediary performs automatic context-sensitive sanitization by inserting the correct sanitizer sequences at identified placement positions in the output stream before the content reaches the browser. This approach prevents cross-site scripting without requiring modifications to the legacy web application code or the browser, as the sanitization is performed by the intermediary in the communication path.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Ease of operation

If sanitizers are placed without considering browser parsing context, then web application development is simpler, but sanitization errors occur leading to security vulnerabilities

Engineering Contradiction:
Improvesanitization implementation easeVSAvoidsanitization effectiveness
Core Design Contradiction:
Ease of operationVSReliability

Solution Approach 1:

The patent changes the parameter of sanitizer placement from fixed or manual positioning to dynamic context-sensitive positioning. The system analyzes the browser parsing context at each placement position and automatically determines the appropriate sanitizer sequence based on the context type (e.g., HTML attribute, JavaScript code, CSS style). This parameter change ensures that sanitization is both easy to implement (automatic) and effective (context-appropriate).

Inventive Principle:
Principle #35Parameter changes

Solution Approach 2:

The system performs preliminary analysis of the web application's code structure and browser parsing contexts before deployment. This preliminary action identifies all placement positions where untrusted input may be output and pre-calculates the correct sanitizer sequences for each position based on the expected browser parsing context, thereby ensuring both ease of operation and reliability without requiring runtime decision-making.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS9882923B2Automatic context-sensitive sanitization
Publication Date: 2018.01.30 MICROSOFT TECHNOLOGY LICENSING LLC
  • US9882923B2 patent drawing
  • US9882923B2 patent drawing
  • US9882923B2 patent drawing

AI summary

An automatic context-sensitive sanitization technique detects errors due to the mismatch of a sanitizer sequence with a browser parsing context. A pre-deployment analyzer automatically detects violating paths that contain a sanitizer sequence that is inconsistent with a browsing context associated with outputting an untrusted input. The pre-deployment analyzer determines a correct sanitizer sequence which is stored in a sanitization cache. During the runtime execution of the web application, a path detector tracks execution of the web application in relation to the violating paths. The correct sanitizer sequence can be applied when the runtime execution follows a violating path.