[bug] NoteGen Web Clipper pairing endpoint auto-approves unauthenticated requests server-side and skips Host validation

オープン
#1,318 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
tauri, typescript

調査の方向性

Read src-tauri/src/web_clipper.rs, starting with create_pairing, request_origin, and approve_pairing; trace how the routes are registered and how the approval command and UI are used. Review the reported Host and origin validation gaps and the authorization path. Done means unauthenticated requests cannot obtain a durable token or write clips, and legitimate pairing still requires user approval; run the Web Clipper tests if available.

索引モデルが issue の本文から書いたものです。

説明

详细描述这个 Bug

Summary
NoteGen starts a loopback Web Clipper HTTP service at startup (app_setup.rs:49) enabled by default. create_pairing stores the request as Pending then immediately calls approve_pairing in the same unauthenticated handler, minting a 32-byte Bearer token persisted with no expiry. Host is never validated and the origin check only validates an extension-scheme string shape, so any local process or web page can obtain a durable token and write attacker notes into the user vault.

Details
Service starts unconditionally at src-tauri/src/app_setup.rs:49 and binds loopback on the clipper port (web_clipper.rs:539-542); routes at 521-538; enabled defaults true (116-120, 505-510).

Failure 1: create_pairing calls request_origin (587) into optional_request_origin (310-335), accepting an extension-shaped Origin or a caller-supplied client ID header (328-334). is_extension_origin (289-299) and is_extension_id (301-308) only check prefix, charset and length; no code reads Host.

Failure 2: create_pairing (578-628) inserts the request as Pending (611-622), then line 623 calls approve_pairing in the same unauthenticated handler and line 626 returns approved. approve_pairing (866-905) mints a 32-byte token and calls persist_connections with no expiry. The approve_web_clipper_pairing command (858-864) and UI at web-clipper-bridge.tsx:417 are bypassed.

Sink: authorize (429-459) validates only protocol, enabled, origin shape, the self-asserted install ID, and the token hash with the install ID and origin recorded at pairing. create_clip (800-824) persists attacker Markdown up to 2 MiB into the note database; create_tag (826-856) and context (789-798) are reachable too.

Core vulnerable code path:

rust
// src-tauri/src/web_clipper.rs:611-628
.insert(
id.clone(),
PairingRequest {
event: event.clone(),
code_challenge: body.code_challenge,
status: PairingStatus::Pending,
},
);
approve_pairing(&state, &id).map_err(ApiError::internal)?;
Ok((
StatusCode::ACCEPTED,
Json(json!({ "id": id, "status": "approved", "expiresAt": event.expires_at })),
))
The unauthenticated handler stores the pairing as Pending then approves it itself on line 623, with no user confirmation and no Host validation anywhere in the path.

POC
Preconditions: NoteGen running, clipper enabled by default, attacker able to reach the loopback clipper port (any local process, or a page via DNS rebinding since Host is unchecked).

Step 1: POST the pairing collection route with loopback Host, Content-Type application/json, protocol version header 1, and an Origin or client ID header of an extension scheme plus an arbitrary identifier. Body: installId 8-128 chars, codeChallenge base64url SHA-256 of the verifier, browser, extensionVersion. Expected HTTP 202 with the pairing id and status approved.

Step 2: POST the exchange route under that id with the same headers and install IDs and the verifier. Expected HTTP 200 with the Bearer token.

Step 3: POST the clips route with Authorization Bearer and the token, install ID and protocol headers, plus mode, clipId, tagId, url, title, contentMarkdown and capturedAt. Expected HTTP 201 with the created mark id, so attacker Markdown is stored in the note vault.

Impact
The attacker holds a durable Bearer token treated as a fully authorised clipper connection. Note vault integrity is compromised: attacker Markdown up to 2 MiB per clip and attacker tags can be written and rendered in the trusted editor, enabling disinformation and phishing. Confidentiality is affected because context exposes clipper context and note metadata. The token never expires and the approval prompt never fires. CVSS v3.1 estimate 8.8.

Weaknesses
CWE: CWE-306 Missing Authentication for Critical Function (with CWE-287 Improper Authentication)

NoteGen 版本

dev branch (exact tagged release to be confirmed)

操作系统

Windows

报错日志

No response

主要言語
TypeScript
スター
12.9k
フォーク
975
平均マージ
20時間 27分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codexu/note-gen のほかの issue

codexu/note-gen の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。