Skip to content
Last updated

no-unsafe-markdown

Disallows potentially executable content in description fields.

OASCompatibility
2.0
3.0
3.1
3.2
AsyncAPICompatibility
2.6
3.0
ArazzoCompatibility
1.0

API design principles

Description fields support Markdown and are rendered by documentation tools. Embedded <script> tags, HTML event handler attributes (such as onerror), and javascript: URLs can execute in the reader's browser, which makes them a cross-site scripting risk — especially when parts of the API description come from external sources. This rule flags the common patterns, but it doesn't replace HTML sanitization in the rendering tool. Keep executable code out of descriptions.

Configuration

OptionTypeDescription
severitystringPossible values: off, warn, error. Default is warn in the recommended configuration.

Example configuration:

rules:
  no-unsafe-markdown: error

Examples

Examples of incorrect Markdown in description fields :

info:
  description: Contains a malicious script tag <script>alert('hello')</script>
info:
  description: Contains an event handler <img src=x onerror=alert('hello')>
info:
  description: Contains a malicious link [click](javascript:alert('hello'))

Example of correct Markdown in description fields:

info:
  description: Plain text, no executable code.

Resources