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

Aperta
#1,318 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
tauri, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

详细描述这个 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

Lingua principale
TypeScript
Stelle
12.9k
Fork
975
Merge medio
20h 27m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codexu/note-gen

Tutte le issue di codexu/note-gen

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.