Context-Aware Output Escaping via Dynamic Content Marking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Web applications face challenges in securing against Cross-Site Scripting (XSS) attacks due to the complexity of output escaping, especially when dynamic content is included in multiple contexts, as existing methods like input filtering and client-side protection are inadequate and difficult to implement and maintain.

Innovation Solution

Implementing runtime output sanitization filtering by marking dynamically-generated content with indicators before document generation, allowing a sanitization filter to identify and escape content appropriately based on context after the document is complete, decoupling marking and filtering processes to ensure comprehensive protection.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of time

If output escaping is performed during dynamic content inclusion, then the content can be sanitized early, but it is difficult to identify the outer context and determine the appropriate escaping method

Engineering Contradiction:
Improveescaping execution timingVSAvoidcontext identification difficulty
Core Design Contradiction:
Loss of timeVSDifficulty of detecting and measuring

Solution Approach 1:

The patent applies preliminary action by marking dynamic content with unique identifiers at the time of inclusion, before the complete document context is available. This allows the sanitization filter to later match these markers with their outer contexts in the final document, resolving the timing contradiction between early sanitization and context identification.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces markers as intermediary elements that bridge the dynamic content and its outer context. These markers serve as placeholders that the sanitization filter uses to locate and identify the context of dynamic content after document assembly, solving the problem of context identification.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If different escaping methods are used for different contexts (HTML, JavaScript, etc.), then each context can be properly sanitized, but the escaping methods are incompatible and cannot be used together

Engineering Contradiction:
Improvesanitization effectivenessVSAvoidescaping method complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent applies local quality by having the sanitization filter detect the specific context (HTML, JavaScript, CSS, etc.) of each marked dynamic content location and apply the appropriate escaping method only to that local context. This allows different escaping methods to be used for different contexts without requiring a single complex escaping system.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The patent segments the sanitization process into separate context-specific handling. The sanitization filter identifies different context types (HTML body, attributes, JavaScript event handlers, links) and applies corresponding escaping rules to each segment, making the overall system manageable despite handling multiple contexts.

Inventive Principle:
Principle #1Segmentation

3Difficulty of detecting and measuring

If sanitization is delayed until the complete document is constructed, then the context of every element can be identified, but the application cannot distinguish which parts are legitimate and which are XSS injected

Engineering Contradiction:
Improvecontext identification accuracyVSAvoidXSS attack vulnerability
Core Design Contradiction:
Difficulty of detecting and measuringVSObject-affected harmful factors

Solution Approach 1:

The patent combines preliminary action with delayed sanitization by marking dynamic content at the time of inclusion and then using these pre-placed markers to identify and sanitize only the dynamic portions in the final document. This allows the system to benefit from both early marking and late context identification, while protecting against XSS by focusing sanitization on marked dynamic content.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent extracts dynamic content from the mix of static and dynamic content by using markers to identify and isolate dynamic portions. The sanitization filter then applies escaping only to these extracted dynamic segments, making it efficient to identify legitimate versus potentially malicious content.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS10372899B2Method and apparatus for context-aware output escaping using dynamic content marking
Publication Date: 2019.08.06 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US10372899B2 patent drawing
  • US10372899B2 patent drawing
  • US10372899B2 patent drawing

AI summary

A technique to provide runtime output sanitization filtering of web application content that contains multiple contexts in which dynamic output is included. To facilitate this operation, dynamically-generated content is prepared for sanitization in advance, preferably by being “marked” by the web application itself (or by middleware). Preferably, given dynamically-generated content is marked by enclosing it between dynamic content indicators. After the document generation is completed but before it is output, the application-generated content is processed by a content sanitization filter. The filter uses the dynamic content identifiers to identify and locate the content that needs output escaping. The filter detects the appropriate context within which the dynamically-generated content has been placed and applies escaping. The output content is prepared for escaping in advance even if assembled from multiple sources that do not operate in the same runtime environment.