Skip to content

chore(deps): update vulnerable deps and fix dompurify config - #137

Merged
Ardnived merged 7 commits into
mainfrom
chore/update-deps
Aug 8, 2026
Merged

Ardnived merged 7 commits into
mainfrom
chore/update-deps

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Closes #101.

pnpm audit --prod goes from 70 advisories (29 high) to 0, and the DOMPurify allowlist on CMS-authored event prose starts actually applying. All 27 entries in scripts/audit-baseline.json are pruned, leaving the list empty.

The dependency half

The lockfile was sitting at the floor of ranges that already permitted the patched versions, so a plain in-range pnpm update did most of the work. Nothing here crosses a major.

before after clears
react-router 7.1.2 7.18.2 8 HIGH — XSS via open redirects, XSS in ScrollRestoration, the vendored turbo-stream v2 arbitrary-constructor bug, 3 DoS
dompurify 3.2.3 3.4.13 all 20 of its advisories, incl. GHSA-cj63-jhhr-wcxv (USE_PROFILES prototype pollution) — the very option removed below
payload (via @payloadcms/sdk) 3.86 3.87.1 drops image-size, whose 2 HIGH advisories had no published patch
postcss 8.4.38 8.5.26 2 HIGH + the 2 nanoid HIGH underneath it
build-time transitives — — brace-expansion, minimatch, picomatch, js-yaml, fast-uri, glob, undici all re-resolved in range

Two things worth a reviewer's attention, because both differ from what the ticket predicted:

  • postcss is a package.json edit, and it had to be. tailwindcss is a production dependency declaring ^8.4.23, which would happily take 8.5.26 — but pnpm deduped it onto the root's exact devDependency pin of 8.4.38. So the pin, not the range, was holding two HIGH advisories in the production graph. Bumped to 8.5.26, a minor within the same major.
  • pnpm update also raised the caret floors across ~40 packages. Kept deliberately: it makes the patched versions a declared constraint rather than a lockfile-only fact, so the fix survives a lockfile regeneration. No major is crossed and no exact pin was touched.

swiper stays at ^12.2.0 (#104 shipped that major). Also dropped @react-aria/visually-hidden: nothing imports it, and at ^3.9.1 it began pulling react-aria + react-stately into the production graph of a widget that embeds in other people's pages.

Eager payload fell 12.5 KiB — 381.1 → 368.6 KiB standalone, 382.7 → 370.4 embed — mostly react-router 7.18 dropping its vendored turbo-stream. BUDGET_KIB is unchanged.

The DOMPurify half

EventDetails.tsx passed USE_PROFILES: { html: true } alongside a twelve-tag ALLOWED_TAGS and ALLOWED_ATTR: ['href']. Those do not intersect — the profile replaces them — so the effective policy was the full HTML profile (119 tags, 118 attributes, measured) and the allowlist was decorative.

The profile is XSS-safe, so this was never script execution. It is worse placed than that sounds: this markup renders inside a host page, where style buys an authored position:fixed;inset:0 overlay on someone else's site, img src a request to any origin, and form/input a credential prompt wearing the host's chrome.

The call moves to a sanitize.ts seam so a spec can reach the configured instance without importing the component tree. Re-verified against the updated 3.4.13 that the precedence is unchanged and that ADD_ATTR: ['target'] still adds rather than replaces (a javascript: href is still rejected; the string-array form is unrelated to the predicate form GHSA-cjmm-f4jc-qw8r reported).

What the reviews caught — three real holes, two opened by this branch

Worth reading, because none of them would have failed a gate:

  1. The tightened allowlist deleted five heading levels. lexicalToHtml passes any h1–h6 through; the new list carried only h3. Invisible by construction — a stripped tag keeps its text, so an authored H2 simply became prose. Fixed, and the spec now round-trips the serializer's own output through the sanitizer so the two files cannot drift again.
  2. data-* and aria-* were never in the allowlist's gift. ALLOW_DATA_ATTR / ALLOW_ARIA_ATTR default to true and are independent of ALLOWED_ATTR. Not decoration: this prose renders inside a vaul drawer driven by data-vaul-*, and aria-live hijacks announcements the host owns. Both off now.
  3. A failed audit reported itself as a clean pass. pnpm emits well-formed JSON on a registry failure — {"error":{…}} — which parsed, carried no advisories, and read downstream as an empty tree. The 27-entry baseline was the only thing catching it, and this PR empties the baseline. runAudit now rejects the error envelope and a missing metadata.

Also: a blind run now prints and exits on the advisories it did see (one auditConfig entry could otherwise have turned every unrelated finding green at once), and target links are normalized — only _blank survives with the forced rel; _top/_parent aim at the frame containing the widget and noopener does nothing about them.

The baseline is now empty, and that removed a guard

The gate treated "zero advisories against a non-empty baseline" as proof the audit had stopped looking rather than proof it was clean. With an empty list that signal cannot tell the two apart, so it is replaced by two that can: the pnpm.auditConfig suppression channel is read directly from package.json (the only place it is visible, and now the only remaining way to hide a finding — so its presence reds a PR), and totalDependencies === 0 catches a run that walked nothing. All branches were verified against a stubbed pnpm.

Verification

  • Gates: lint, typecheck, 873 tests in 77 files, pnpm build, pnpm size, pnpm audit:check (both normal and --strict) — all green.
  • pnpm audit --prod: 0 of 417. Full tree incl. devDeps: 0 of 1103.
  • hash.router.test.tsx — the react-router regression guard — passes unchanged. It pins that react-router normalises the basename ! to /!; confirmed in a real browser too.
  • Browser-verified against the built embed.js on a host page with live data (Playwright + the seeded local backend): boot writes #!; in-widget links carry #/!/gb; drill-down, deep links and Back all work; a fresh mount at a host #respond anchor takes the MemoryRouter branch, leaves location.hash untouched, scrolls to the host anchor and still navigates internally (fix(widget): survive foreign hashes and harden the mount path #92's contract, intact under 7.18.2). Map, pins, clusters and camera framing all render. Real CMS prose renders through the new sanitizer.
  • The fix reached the bundle: dist ships ALLOWED_TAGS:U,ALLOWED_ATTR:['href'],ADD_ATTR:['target'],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1 with no USE_PROFILES at our call site.

Deliberately not done

  • Widening the audit gate past --prod. audit.yml recorded this as costing 8 build-toolchain advisories; it now costs zero, so it is the cheapest it will ever be. Left as a decision rather than folded into a dependency bump — the comment records the measurement.
  • Ratcheting BUDGET_KIB down to lock in the 12.5 KiB. The script's own slack rule is not tripped, and a dep-bump shrink is less durable than an architectural one.
  • A pre-existing caveat found in passing: EventMetadata.tsx puts unescaped CMS prose into a JSON-LD <script>. Not exploitable today (react-helmet-async sets it via innerHTML on a detached script, where </script> stays character data), but it becomes a real injection the day anything server-renders Helmet. Not touched here.

🤖 Generated with Claude Code

Ardnived and others added 7 commits August 7, 2026 19:28
`pnpm update` pulls every direct dependency to the newest version its
declared range already allowed — the lockfile sat at the floor of those
ranges, so nothing here widens a range or crosses a major.

The load-bearing moves:

- react-router 7.1.2 -> 7.18.2 clears eight HIGH advisories (XSS via open
  redirects, XSS via ScrollRestoration, the vendored turbo-stream v2
  arbitrary-constructor bug, three DoS). 7.18 also drops the vendored
  turbo-stream outright, which is most of a 12.5 KiB fall in the eager
  payload (381.1 -> 368.6 KiB standalone).
- dompurify 3.2.3 -> 3.4.13 clears all 20 of its advisories, including
  GHSA-cj63-jhhr-wcxv (USE_PROFILES prototype pollution allows event
  handlers) — the very option the next commit removes.
- payload 3.86 -> 3.87.1 drops `image-size`, so its two unpatched
  advisories leave the graph rather than being waited out.
- The build-time transitives (brace-expansion, minimatch, picomatch,
  js-yaml, fast-uri, glob, undici, nanoid) were all in range under their
  own parents and re-resolved on the same update.

postcss is the one package.json edit. tailwindcss (a prod dep) declares
`^8.4.23` and would happily take 8.5.26, but pnpm deduped it onto the
root's exact devDependency pin of 8.4.38 — so the pin, not the range, was
holding two HIGH advisories in the production graph. Bumped to 8.5.26,
a minor within the same major.

swiper stays at ^12.2.0 (#104 already shipped that major).

`pnpm audit --prod` goes 70 advisories (29 high) -> 0.

Closes #101

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The sanitize call passed `USE_PROFILES: { html: true }` alongside a
twelve-tag `ALLOWED_TAGS` and `ALLOWED_ATTR: ['href']`. Those do not
intersect — the profile REPLACES them — so the effective policy on
CMS-authored prose was the full HTML profile, ~117 tags and ~113
attributes, and the twelve tags were decorative.

The profile is XSS-safe, so this was never script execution. It is worse
placed than that sounds: the markup renders inside a HOST page, where
`style` buys an authored `position:fixed;inset:0` overlay on top of
someone else's site, `img src` a request to any origin the author picks,
and `form`/`input` a credential prompt wearing the host's chrome.

Dropping the option is the whole fix. Verified against dompurify 3.4.13
(the version the previous commit lands on, not the 3.2.3 the report was
written against) that the precedence is unchanged, and that
`ADD_ATTR: ['target']` still ADDS rather than replaces, that `target` is
not a URI attribute so a `javascript:` href is still rejected, and that
the string-array form is not the predicate form GHSA-cjmm-f4jc-qw8r
reported.

The call moves to a `sanitize.ts` seam in the same folder so a spec can
reach the configured instance without importing the component tree. The
spec is the point: nothing asserted on this output before, which is how
the option survived. It boots jsdom, because a sanitizer's behaviour IS
the DOM behaviour and there is no pure half to extract. Confirmed it
fails on four cases with `USE_PROFILES` put back.

Closes #101

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…rried

All 27 booked advisories are gone, so all 27 lines go with them — the
weekly `--strict` run fails on a baselined advisory that is no longer
reported, which is what makes a fix prune its own line.

Emptying the list has a consequence the file did not anticipate. The gate
treated "zero advisories against a non-empty baseline" as proof the audit
had stopped looking rather than proof it was clean — a swallowed registry
error, or an `auditConfig.ignoreGhsas` slipped in elsewhere. With an empty
baseline, zero IS the expected state, so that signal cannot tell the two
apart any more and the guard would have gone quiet without anyone
removing it.

So the check becomes the size of the graph it walked: pnpm reports
`totalDependencies` (417 for --prod here), and a run that audited none of
them audited nothing. An absent field is skipped rather than failed — an
older pnpm not reporting the count is not evidence of blindness. Verified
both branches against a stubbed pnpm: warns on the PR gate, reds under
--strict, same as the guard it replaces.

Closes #101

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The altitude reviewer caught the new audit guard claiming cover it did
not give. Its comment named `auditConfig.ignoreGhsas` as one of the
things a graph-size check would catch — it cannot: pnpm drops ignored
ids before writing the JSON, so suppression changes neither the graph
nor the totals. The guard would have stayed green through exactly the
case it advertised, which is worse than not claiming it, because the
comment stops the next person looking for a real check.

So the suppression channel is now read directly (`pnpm.auditConfig` in
package.json — the only place it is visible), and the graph-size branch
keeps only the narrow claim it can support: zero packages walked means a
wrong working directory or an empty lockfile. Verified all three
branches fire, and that a normal run still passes.

Also folded the duplicated 'Check `pnpm audit --prod` by hand.' tail into
one message.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three of these were real holes, two of them opened by this branch.

**The allowlist deleted five heading levels.** `lexicalToHtml` passes any
h1-h6 through, and the tightened list carried only `h3` — so removing
USE_PROFILES took the other five with it. Invisible by construction: a
stripped tag keeps its text, so an authored H2 just became prose, with
no error and every gate green. All six are allowed now, and the spec
round-trips the serializer's own output through the sanitizer so the two
files cannot drift apart again.

**`data-*` and `aria-*` were never in the allowlist's gift.**
ALLOW_DATA_ATTR / ALLOW_ARIA_ATTR default to true and are independent of
ALLOWED_ATTR, so the config that called itself "an allowlist and nothing
else" passed every one of them. Not decoration: this prose renders
inside a vaul drawer driven by `data-vaul-*`, and `aria-live` on a host
page hijacks announcements the host owns. Both are off now.

**A failed audit reported itself as a clean pass.** pnpm emits
well-formed JSON on a registry failure — `{"error":{…}}` — which parsed,
carried no advisories, and so read downstream as an empty tree. The
27-entry baseline used to catch it; emptying it in the previous commit
took away the only thing that did. `runAudit` now rejects the error
envelope and a missing `metadata`, routing both to the "unavailable"
branch that already knows to warn on a PR and red the weekly run.

Two smaller corrections to the same gate: a blind run now prints and
exits on the advisories it DID see, so one `auditConfig` entry can no
longer turn every unrelated finding green at once; and that suppression
reds a PR rather than warning, because unlike an outage it is a
repo-authored change sitting in somebody's diff.

Also dropped a comment claiming pnpm hides suppressed advisories from
the report totals. It does not — it rewrites `advisories` and leaves
`metadata` alone. The config read is still the right signal, but for the
reason that it is exact rather than that it is the only one.

Also: target links are now normalized rather than passed through. Only
`_blank` survives (with the forced rel); `_top` and `_parent` aim at the
frame containing the widget and `noopener` does nothing about them, so
they are dropped to the default `_self`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Nothing in src, .ladle, scripts or tests imports it, and it is absent
from dist — but it sat in `dependencies`, and the in-range bump made it
cost something: at ^3.9.1 it declares `react-aria` as a runtime
dependency, which pulled react-aria + react-stately into the PRODUCTION
graph of a widget that embeds in other people's pages. Removing the line
takes both back out.

Also re-points the `@r2wc/core` note in Widget.tsx, which named 1.2.0
while the bump moved it to 1.3.1. 1.3.1 rewrote the constructor from an
assignment to a class field, so the comment now rests on the language
rule that actually makes our reset land second — base-class field
initialisers run inside `super()` — rather than on a version number that
goes stale on the next bump. Behaviour re-verified against both.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- `.claude/rules/tests.md` listed the jsdom specs as a closed set of two,
  while the new sanitizer spec announces itself as the third and points
  back at that list. Added it, with the reason it is the least optional
  of the three.
- `.claude/rules/data-layer.md` still sent readers to `EventPanel` for
  the DOMPurify call; that folder is `EventDetails`, and the call now
  lives in its own `sanitize.ts`. Records the superset rule the spec
  enforces while it is there.
- `.claude/rules/components.md` had nothing about the sanitizer at all.
  It does now, naming both ways the allowlist has already been inert —
  an option that replaces it, and the data/aria options that bypass it.
- `.github/workflows/audit.yml` recorded the `--prod` scope gap as
  costing 8 build-toolchain advisories to close. It now costs zero: the
  full tree reports 0 at every severity. Left as a decision rather than
  widening the gate inside a dependency bump.
- `.claude/skills/finalize-pr/SKILL.md`'s security-review trigger grepped
  `organisms/EventPanel/`, a folder that no longer exists — so the
  path-based half would not have fired for this very change (only the
  `package.json` clause saved it). Repointed at `EventDetails/`. The
  pattern names Atlas-specific paths, so there is nothing to port to the
  sibling repos.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 62e0973
Status: ✅  Deploy successful!
Preview URL: https://bd935dfa.sahajatlas-design.pages.dev
Branch Preview URL: https://chore-update-deps.sahajatlas-design.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 62e0973
Status: ✅  Deploy successful!
Preview URL: https://0e2efdd2.sahajatlas.pages.dev
Branch Preview URL: https://chore-update-deps.sahajatlas.pages.dev

View logs

@Ardnived
Ardnived merged commit 435d755 into main Aug 8, 2026
5 checks passed
@Ardnived
Ardnived deleted the chore/update-deps branch August 8, 2026 03:41
Ardnived added a commit that referenced this pull request Aug 8, 2026
One conflict, in .claude/rules/tests.md: this branch and #101 each added a
fourth jsdom spec to the same list, and both bumped its count to "Three".
Kept both entries, corrected the count to Four, and fixed #101's "least
optional of the three" to match. The ordinal in the report-form entry
still reads correctly — with sanitize.test.ts second, it is the third
cautionary tale.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 11, 2026
* fix(build): pin smoke discovery to the head commit's deploy

`pick()` gates the HOST, never which BUILD that host serves. Cloudflare
publishes two per project — the per-deployment alias and a stable branch
alias — and both cleared the gate, so the lane could go green having
smoke-tested the previous commit.

Candidates now carry provenance and are ranked: the deployment named by
our own check run for this SHA (its `details_url` ends in the deployment
UUID, whose first 8 chars ARE the alias) beats a deploy-shaped URL from a
per-SHA source, which beats a branch alias. A Cloudflare comment naming
some other commit is refused outright — that is the observed defect, not
a hypothetical: on PR #135 the comment still linked `9326e3b`'s deploy
while the head was `56c6b0d`.

Also wires `failure` through `main()`. It was computed in `discover()`
and dropped on the floor, so `timeoutStatus` never saw it and the
`failed` status — added by #132's code review precisely so a broken build
is not reported as a slow one — was unreachable in production while its
unit spec passed.

Closes #138

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(build): pin URL provenance, and record the third smoke invariant

Eleven cases over `deploymentAlias` / `provenanceOf` / `pickPreview`,
built on PR #135's real data so the fixture names the defect rather than
paraphrasing it. The host gate is re-asserted at the strongest tier as
well as the weakest: ranking chooses AMONG urls `pick()` accepts and must
never reach past it.

tests.md gains the third invariant — a green Smoke check means the specs
ran against THIS commit — and loses #132's "known gap, deliberately still
open", whose precondition (does the check-run summary carry a per-commit
URL?) is now answered: yes, on all of #133-#137.

It also records why a passing unit spec did not stop `failed` being
unreachable: the defect was in the wiring, which no pure test can see.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(build): close the gaps /security-review found

Three Low findings, all about the new attestation trusting something
self-declared:

- The deployment id was read from any check run admitted by NAME, and a
  name is self-declared. An installed App with `checks:write` could call
  itself "Cloudflare Pages: sahajatlas" and choose the `details_url` we
  derive the expected host from. It could never aim us off-host — pick()
  decides that — but it could steer selection between builds of our own
  site, which is the defect this ticket closes. Now gated on the app slug,
  matching source 1's "both the context AND the author".
- The bare project host is PRODUCTION, not a preview. It clears pick(),
  isn't deploy-shaped, and so sat on the `alias` floor beside a branch
  alias — but this script only runs for a PR head, so production is never
  the right answer. Refused outright.
- `includes(shortSha)` matched a 7-hex prefix anywhere, including inside a
  longer hex run, so a stale comment could be called "naming the head" on
  a coincidence. Now a whole-token match, built only from a real hex
  prefix so a bogus PR_HEAD_SHA degrades instead of throwing.

Also softens the tests.md headline, which promised more than the `alias`
floor delivers, and corrects the "exactly one run" comment: filter=latest
is one run per check NAME, which is unique per APP, not globally — which
is exactly why the slug gate matters.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(build): close the gaps /code-review found

Two High, four Medium, three Low. The two that mattered most were both
things this PR had asserted and not checked:

- The summary DENIED the URL it had just refused. `refused` reached the
  poll log but never `main()`, so at timeout `absent` read "no check run,
  no deployment, no bot comment" while the line above named the URL we
  declined — and ci.yml routes `absent` to "INVESTIGATE, don't re-run". It
  now rides into `explain()`. It deliberately does NOT reach
  `timeoutStatus`: another commit's URL is not evidence that this one
  built, so it must not soften `absent` into "re-run".
- `\b<sha>\b` rejected every LONGER spelling of the same commit (`56c6b0d1`,
  the full 40 hex). Since that predicate now gates the URL harvest and not
  just the evidence, source 4 would have died wholesale the day Cloudflare
  printed one more digit. Only the left boundary is anchored now.

- Deploy-shape is read at BOTH scopes. Reading it only for per-SHA sources
  left one comment's two URLs indistinguishable, so Cloudflare's table
  order decided which won — this ticket's own defect, one level down. New
  `claimed` tier: below the check run, above a branch alias.
- The slug gate now guards every CONCLUSION drawn from a check run, not
  just `deployment`. An impostor could still set `failure`, and `failed`
  tells the reader "re-running cannot help" — a red check nobody can clear.
  URLs stay on the name-only path; `pick()` bounds those.
- The header's "the only URLs this refuses are X" was false four ways.
  Replaced with the enumeration, and the top-line "take the first we find"
  corrected. MEMORY.md warns about exactly this class of scope claim.
- `deploymentAlias` took the FIRST uuid while its doc said "ending in";
  the production-host refusal read a module-level slug instead of the
  passed host; the poll line dropped evidence whenever it had a refusal.

`waitingLine` is exported and specced, per the lesson this PR itself added
to tests.md — the wiring is where every one of these lived.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

chore(deps): update vulnerable deps and fix dompurify config

1 participant