Skip to content

Weekly review: patch happy-dom advisories; seven findings for review - #89

Open
DennisAlund wants to merge 1 commit into
mainfrom
claude/adoring-dirac-fn92up
Open

DennisAlund wants to merge 1 commit into
mainfrom
claude/adoring-dirac-fn92up

Conversation

@DennisAlund

Copy link
Copy Markdown
Member

Weekly defect review of the app, API, MCP, the three SDKs and the extension. This review fixes one thing. The other findings need a design decision, so they are posted as comments on this PR instead of in the diff.

Fix

Extension: upgrade happy-dom 20.14.6 → 21.0.4 (browser-extensions/)

  • What was wrong: yarn audit reported two high advisories in happy-dom: 1243084 (incomplete fix for CVE-2026-33943) and 1243623 (SSRF through iframe and stylesheet loading while parsing).
  • Impact: happy-dom is the DOM that vitest uses for the extension tests. It never ships in the extension, so the exposure is limited to the test environment.
  • Fix: bump the dev dependency to 21.0.4. It is a major version, but nothing in the suite needed changing.
  • Test: all 196 extension tests pass, tsc --noEmit is clean, and the audit now reports 0 vulnerabilities.

Checks

  • yarn test (root): 123 files, 1947 tests pass.
  • SDK unit suites: TypeScript 112/112, Python 138/138. Dart is not installed in the review environment, so its findings come from reading the code.
  • yarn audit: no advisories for the root app or the TypeScript SDK.
  • yarn e2e was not run because the change touches nothing in the admin UI.

Dependency drift (no advisories, not upgraded)

  • Minor and patch updates are available for hono, jose, wrangler, @cloudflare/workers-oauth-provider and @types/node.
  • Major updates are available for typescript (7), vitest (5) and @playwright/test (1.65, which is pinned).
  • agents is at 0.24.0; the latest is 0.34.1. It is pre-1.0, so treat each minor release as breaking.

Generated by Claude Code

yarn audit flags happy-dom 20.14.6 with advisory 1243084 (incomplete fix
for CVE-2026-33943, patched in 21.0.4) and 1243623 (SSRF through iframe
and stylesheet loading while parsing, patched in 21.0.0). happy-dom is the
vitest DOM for the extension tests only and never ships in the extension.

The major bump is drop-in for this suite: all 196 extension tests pass
and the typecheck is clean on 21.0.4. The audit now reports none.

Claude-Session: https://claude.ai/code/session_015egb9CMc3wGhvN1m7HqyyZ

Copy link
Copy Markdown
Member Author

Findings that need a decision (server)

Each one is checked against the code. None is fixed here, because each changes behavior or needs a design call.

1. The redirect can re-cache a link right after it is disabled or deleted (src/redirect.ts:29-41). Medium.

  • The race:
    1. A redirect misses KV and reads the still-active row from D1.
    2. disableLink, deleteLink or removeSlug commits and updates or evicts KV.
    3. The redirect then runs SlugCache.put with the stale active entry.
  • Read-through puts carry no TTL, so the disabled or deleted slug keeps redirecting until something else rewrites that key.
  • The race is most likely when the owner disables a link while it has traffic, which is the main reason to disable one.
  • Options: an expirationTtl on read-through puts only (bounded staleness, costs some D1 reads), or a version token checked on write.
  • redirect-kv.test.ts covers only the sequential cases.

2. Adding a custom slug during a URL update caches the old URL (src/services/link-management.ts, addCustomSlugToLink). Low.

  • link is read before the insert, and KV is written from link.url.
  • If updateLink commits in between, it rewrites KV only for the slugs it re-read, which does not include the new slug.
  • The new slug then redirects to the old URL with no expiry.
  • Possible fix: re-read the link after the insert.

3. The public bundle API applies the key owner's click filters, but bundle analytics and the link routes return raw counts.

  • Routes affected: GET /_/api/bundles, /bundles/:id and /bundles/:id/links. Each resolves resolveClickFilters(identity) in bundle-management.ts:102,141,318.
  • handlePublicBundleAnalytics says "raw click counts (no per-identity filter)", and public-api-range.test.ts pins raw counts for links.
  • filter_bots defaults to on, so one bot click plus one human click gives:
    • GET /bundles/:id → total_clicks: 1
    • GET /bundles/:id/analytics → 2
  • Slug click_count also differs between /bundles/:id/links and /links/:id.
  • The service comments say the filtering is deliberate, which is why this needs a decision: either the public bundle routes go raw, or the doc changes. Going raw changes API output.

4. The 24h, 7d, 30d and 90d timelines and sparklines drop the oldest partial bucket (src/db/click-repository.ts, getTimeline/fillBuckets, getBucketSpec/sparkLabels).

  • The query floor is now - N*86400 (or now - 86400 for 24h), but the labels cover only the last N calendar days (or 24 hours).
  • Clicks on the day of now - 7d, after that time of day, count in totals and last_7d but sit in no bucket.
  • Example: now is Nov 27 12:00 and a click lands Nov 20 18:00. The total is 1 and the buckets sum to 0.
  • The 1y sparkline got the matching fix last week (monthStart). Two choices for the daily and hourly ranges: floor at the start of the oldest bucket, or add an N+1th bucket. Either one changes the numbers users see.

5. MCP compare_links has no upper bound on link_ids (src/mcp/server.ts:680).

  • .min(2) with no .max().
  • Each id costs about 6 sequential D1 statements, so a few hundred ids exhaust the invocation's subrequest budget. The call then returns an internal error instead of a validation error.
  • Needs a chosen cap.

Generated by Claude Code

Copy link
Copy Markdown
Member Author

Findings that need a decision (SDK parity)

Both change the SDK surface, so they need a decision across all three SDKs.

1. The TypeScript and Dart SDKs have no request timeout; Python defaults to 30 s. Medium.

  • TypeScript (sdk/typescript/src/internal/http.ts): fetch gets no AbortSignal. A stalled server hangs the call indefinitely in a browser, or until undici's internal limit in Node.
  • Dart (sdk/dart/lib/src/base_client.dart): _httpClient.send(request) has no .timeout(...).
  • Python (client.py): DEFAULT_TIMEOUT = 30.0 maps to ShrtnrError(0, …), and its README documents the timeout option.
  • Parity means a timeout option in TypeScript and Dart, a README entry, and minor version bumps.

2. Dart throws a raw ArgumentError on an enum value it does not know. Low.

  • BundleAccent.fromWire and TimelineRange.fromWire throw (sdk/dart/lib/src/models.dart:49,95).
  • Once the server adds a bundle accent, client.bundles.list() fails outright for every caller of an older Dart SDK.
  • TypeScript and Python pass the value through unchanged.
  • Choices: tolerate the value (an unknown fallback) or wrap the error in ShrtnrError.

Generated by Claude Code

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
shrtnr 3205b84 Nov 27 2026, 07:10 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants