[bug] NoteGen Web Clipper pairing endpoint auto-approves unauthenticated requests server-side and skips Host validation
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- tauri, typescript
- Domain
- authentication, backend, security
Research direction
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.
Written by the indexing model from the issue text.
Description
详细描述这个 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
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 975
- Avg merge
- 20h 27m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from codexu/note-gen
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
Similar issues
-
bug triage:in-progress
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
redhat-developer/rhdh-plugin-export-overlays#4845 · 1 comment ·
Maintainers usually reply within 1 day
-
chore kaizen ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
IBM/mcp-context-forge#7681 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
cloudflare/workers-sdk#17159 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cybersemics/em#6398 ·
Maintainers usually reply within 1 day