Repository navigation
Fix Snyk undici critical/high issues and media href hardening - #251
Conversation
Pin undici to ^7.30.1 (cheerio transitive), document the unfixed picomatch ReDoS in .snyk, and route media links through toAbsoluteHttpUrl. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Luen
left a comment
There was a problem hiding this comment.
Review: dependency changes look right (pnpm why undici → only cheerio > undici@7.30.1; picomatch is reached via next-sitemap/fast-glob and the eslint/vitest toolchain only, so the .snyk ignore rationale holds). Two things to tidy before merge, which I will push as a follow-up commit:
toAbsoluteHttpUrlsame-origin branch returns the raw input. Any value starting with/is passed through untouched, but browsers resolve/\evil.comand/<TAB>/evil.comtohttps://evil.com/. That contradicts the new "never reuse the raw input string" comment and lets a crafted path escape to another origin (this helper also guards Scholar-sourced team links). Fix: resolve against a sentinel base, reject if the origin changes, returnpathname + search + hash, and add tests.- Double sanitisation in
MediaCoverageList. Items are sanitised into state viasanitizeMediaItemand again at render viatoAbsoluteHttpUrl(article.url). The render-time check at thehrefsink is sufficient; droppingsanitizeMediaItemkeeps a single source of truth.
| if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null; | ||
| return parsed.toString(); | ||
| // Rebuild from URL components so callers never reuse the raw input string. | ||
| return `${parsed.protocol}//${parsed.host}${parsed.pathname}${parsed.search}${parsed.hash}`; |
There was a problem hiding this comment.
The rebuild is good, but the earlier candidate.startsWith('/') branch still returns the raw string. new URL('/\evil.com', base) and a /+TAB+/evil.com value both resolve to https://evil.com/, so those become cross-origin links. Suggest resolving same-origin paths against a sentinel base and returning only pathname + search + hash when the origin is unchanged.
| initialOffset?: number; | ||
| }; | ||
|
|
||
| const sanitizeMediaItem = (item: MediaItem): MediaItem => ({ |
There was a problem hiding this comment.
Redundant with the render-time toAbsoluteHttpUrl(article.url) below (and sources aren't covered here anyway; SourceTag sanitises those at render). Suggest removing sanitizeMediaItem and keeping the check at the href sink only.
Paths like `/\evil.com` or `/<tab>/evil.com` were returned raw, but browsers resolve them to another origin. Resolve same-origin paths against a sentinel base and return only pathname/search/hash when the origin is unchanged. Drop the redundant sanitizeMediaItem pass; the href sink already sanitises. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Claude BugBot Analysis
No bugs found. The same-origin path check in toAbsoluteHttpUrl correctly rejects /\host and /<tab>/host by resolving them against a dummy base. The MediaCoverageList and MediaSourceTags changes call it correctly, and the rest of the diff is dependency and Snyk metadata bumps.
No bugs were detected in this PR.
|
Both review points are addressed in 592c0b7. 🤖 Generated with Claude Code |
Summary
undicito^7.30.1via npm/pnpm overrides so cheerio no longer pulls vulnerable7.30.0(clears the 2 critical + 6 high Snyk findings).SNYK-JS-PICOMATCH-21248802in.snykuntil an npm release exists; picomatch is only used at build time through next-sitemap/fast-glob with developer-controlled patterns.toAbsoluteHttpUrl(and sanitize load-more API items) sohrefvalues are protocol-checked and rebuilt from URL components.Test plan
pnpm installresolvesundici@7.30.1pnpm run lintpnpm run testpnpm run build/medialinks still open correctlyMade with Cursor