Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.5 KB
Raw Blame
rules:
    - id: require-iframe-sandbox
      message: >-
          iframe elements must have a sandbox attribute to restrict embedded content.
          Add sandbox="..." with appropriate permissions (e.g., "allow-scripts allow-same-origin").
          If this iframe intentionally needs no sandbox, add a nosemgrep comment.
      severity: ERROR
      languages: [typescript, javascript]
      patterns:
          - pattern: <iframe ... />
          - pattern-not: <iframe ... sandbox="..." ... />
          - pattern-not: <iframe ... sandbox={...} ... />
      metadata:
          category: security
          technology:
              - react
          cwe:
              - 'CWE-1021: Improper Restriction of Rendered UI Layers or Frames'
          owasp:
              - A05:2021 - Security Misconfiguration

    - id: require-iframe-sandbox-array
      message: >-
          iframe in renderHTML array syntax must have a sandbox attribute.
          Add sandbox: '...' with appropriate permissions (e.g., 'allow-scripts allow-same-origin').
      severity: ERROR
      languages: [typescript, javascript]
      patterns:
          - pattern: |
                ['iframe', { ... }]
          - pattern-not: |
                ['iframe', { ..., sandbox: $X, ... }]
      metadata:
          category: security
          technology:
              - tiptap
          cwe:
              - 'CWE-1021: Improper Restriction of Rendered UI Layers or Frames'
          owasp:
              - A05:2021 - Security Misconfiguration