Skip to content

[Safe Outputs Conformance] SEC-004: Handlers with body fields missing content sanitization #15805

@github-actions

Description

@github-actions

Conformance Check Failure

Check ID: SEC-004
Severity: MEDIUM
Category: Security
Date: 2026-02-14
Run ID: §22025666977

Problem Description

The conformance checker identified 29 handlers that accept body or content fields but do not implement content sanitization. This violates the Safe Outputs specification requirement that all user-facing content must be sanitized to prevent injection attacks and ensure safe rendering.

Security Impact: Without proper sanitization:

  • Potential for cross-site scripting (XSS) via malicious markdown
  • Script injection through HTML in markdown
  • Link-based phishing attacks
  • Markdown rendering exploits

Affected Handlers

Key handlers missing sanitization (29 total):

Critical Priority

  • add_comment.cjs - Adds comments without sanitizing body
  • add_workflow_run_comment.cjs - Workflow comments unsanitized
  • create_pr_review_comment.cjs - PR review comments unsanitized

High Priority (Close Operations)

  • close_issue.cjs - Close messages unsanitized
  • close_pull_request.cjs - Close messages unsanitized
  • close_discussion.cjs - Close messages unsanitized
  • close_expired_issues.cjs - Expiration messages unsanitized
  • close_expired_pull_requests.cjs - Expiration messages unsanitized
  • close_expired_discussions.cjs - Expiration messages unsanitized
  • close_older_issues.cjs - Close messages unsanitized
  • close_older_discussions.cjs - Close messages unsanitized

Medium Priority (Other Operations)

  • add_reaction_and_edit_comment.cjs
  • create_missing_data_issue.cjs
  • create_missing_tool_issue.cjs
  • check_workflow_recompile_needed.cjs
  • 14 additional handlers (see conformance report)

Current Behavior

These handlers accept body fields and pass them directly to GitHub API without sanitization. While GitHub's markdown renderer provides some protection, the specification requires explicit sanitization for defense in depth.

Expected Behavior

Per the Safe Outputs specification, all handlers with body/content fields MUST:

  1. Sanitize content using approved sanitization functions
  2. Strip potentially dangerous HTML tags and attributes
  3. Validate and sanitize markdown constructs
  4. Escape user-controlled content appropriately

Remediation Steps

For each affected handler:

  1. Import sanitization module:

    const { sanitizeContent } = require('./sanitize_content_core.cjs');
  2. Sanitize before API calls:

    const sanitizedBody = sanitizeContent(body);
    await octokit.issues.createComment({
      body: sanitizedBody,
      // ...
    });
  3. For existing sanitization helpers, ensure they're being called:

    • sanitize_content.cjs - General content sanitization
    • sanitize_output.cjs - Output sanitization
    • sanitize_incoming_text.cjs - Input sanitization
  4. Add validation that sanitization occurred before API call

Verification

After remediation, verify the fix by running:

bash scripts/check-safe-outputs-conformance.sh

The check SEC-004 should pass for the remediated handlers.

References

  • Safe Outputs Specification: docs/src/content/docs/reference/safe-outputs-specification.md (Section: "SEC-004: Content Sanitization Required")
  • Existing sanitization modules: actions/setup/js/sanitize_*.cjs
  • Conformance Checker: scripts/check-safe-outputs-conformance.sh

Generated by Daily Safe Outputs Conformance Checker

  • expires on Feb 15, 2026, 11:01 PM UTC

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions