Skip to content

Upgrade Astro to 7.4 and add basic security settings - #1

Merged
timlichtenberg merged 1 commit into
mainfrom
tl/security-hardening
Oct 22, 2026
Merged

timlichtenberg merged 1 commit into
mainfrom
tl/security-hardening

Conversation

@timlichtenberg

Copy link
Copy Markdown
Member

Summary

npm audit on main reports 12 vulnerable packages (1 critical, 10 high, 1 low), the critical one being astro 5.18.2. This upgrades Astro to 7.4.2, which clears all of them, narrows the permissions of the build job, and adds a narrow CSP meta tag, Dependabot version updates and a PR build check.

Changes

  • astro 5.18.2 to 7.4.2, @astrojs/sitemap to 3.7.4; Node 24 in the deploy workflow, engines.node >=22.23.4, minimum stated in the README.
  • vite.build.cssTarget set to Safari 14 and the other Vite 6 browsers. Without it, Vite 8 rewrites the bundled max-width media queries into range syntax that Safari before 16.4 ignores.
  • The build job in deploy.yml holds only contents: read; pages: write and id-token: write stay with the deploy job, so packages that run during npm ci and the build cannot deploy.
  • CSP meta tag in Base.astro: object-src 'none'; base-uri 'self'; form-action 'self'. It does not restrict scripts (the password gate and the Bokeh demo are untouched); it blocks plugins, <base> injection and form posts to other hosts. The password gate stays client-side only.
  • .github/dependabot.yml: weekly npm and GitHub Actions updates, minor and patch grouped, majors as separate PRs.
  • .github/workflows/pr-build.yml: npm ci and npm run build on every PR.

Validation

  • npm audit: 12 vulnerabilities on main, 0 on this branch.
  • npm run build on main and on this branch, then a diff of dist/ with hashed asset names, <style> blocks, whitespace and the CSP tag stripped: 1 of 7 pages differs, only by minifier variable names in the collaboration page script.
  • Range-syntax media queries in dist/: 0 on main, 13 on Astro 7 without cssTarget, 0 with it.
  • Every page of the built site loaded in headless Chromium with a securitypolicyviolation listener: 0 violations on 7 pages.
  • The deploy workflow dispatched on this branch, to check the build job with the narrowed permissions: the build job passed and the deploy job was refused by the github-pages branch rule, as intended (https://github.com/Interra-Project/Interra-Project.github.io/actions/runs/39746116353).

Not checked

  • The new PR workflow itself; it runs for the first time on this PR.

npm audit reported 12 vulnerable packages in the build tree, one of them critical (astro 5.18.2). Astro 7.4.2 and @astrojs/sitemap 3.7.4 clear all of them; npm audit now reports 0.

Astro 7 needs Node 22.23.4 or newer: the deploy workflow moves to Node 24, package.json gets an engines field and the README states the minimum. Vite 8 targets Safari 16.4 by default and rewrites max-width media queries in the bundled CSS into range syntax, which older Safari ignores; build.cssTarget keeps the CSS readable for Safari 14 and newer.

The build job now holds only contents: read; the Pages and OIDC scopes stay with the deploy job. Add a narrow Content-Security-Policy meta tag (object-src none, base-uri and form-action self), which does not restrict scripts, a weekly Dependabot config that groups minor and patch updates, and a pull-request workflow that builds the site.
@timlichtenberg
timlichtenberg requested review from a team as code owners October 22, 2026 08:15
@timlichtenberg
timlichtenberg merged commit ca4e3d0 into main Oct 22, 2026
2 of 3 checks passed
@timlichtenberg
timlichtenberg deleted the tl/security-hardening branch October 22, 2026 14:22

This branch had an error being deployed

1 failed deployment
github-pages — 964cd5f5 Deployed Oct 22, 2026 by timlichtenberg via deploy #2
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.

1 participant