Skip to content

SECURITY: typst: backport GHSA-rw6x-h3xm-cvq5 fix (typst init template.path traversal) - #1002

Merged
bryan-minimal merged 1 commit into
mainfrom
security-typst-ghsa-rw6x
Oct 23, 2026
Merged

bryan-minimal merged 1 commit into
mainfrom
security-typst-ghsa-rw6x

Conversation

@bryan-minimal

Copy link
Copy Markdown
Member

This backports the fix for GHSA-rw6x-h3xm-cvq5 (low) to typst 0.15.1.

The bug: typst init follows a package manifest's template.path out of the package, through .. or an absolute path. That copies arbitrary readable directories (for example ~/.ssh) into the new project. Affected range: 0.11.0–0.15.1; we ship 0.15.1. typst init is part of the binary we ship, so we're affected.

The fix: fdb38b89f1 "Turn all manifest paths into virtual paths" (typst#8989), on main only. Upstream says it won't cut a patch release: symlinks inside a package can still lead out of it, which is intended behaviour today (typst#5454), so a patch release wouldn't meaningfully raise security. This backport closes the .. and absolute-path vectors from the advisory; the symlink caveat is noted in build.ncl.

The patch: GHSA-rw6x-h3xm-cvq5.patch is a verbatim git format-patch of fdb38b89f1.

  • git apply --check on v0.15.1 succeeds with line offsets only, no fuzz. It touches 5 files, including upstream's own smoke tests.
  • build.sh applies it with patch -Np1 under set -e, so a stale patch aborts the build instead of shipping unpatched.
  • Drop it on the next typst release.

Tests, with a negative control

Two new standalone tests mirror upstream's smoke tests:

  • template_path_escape_refused: a local package whose template.path = "../../../../secret" must make typst init fail with "path escapes root" and copy nothing.
  • template_path_absolute_is_package_relative: template.path = "/template" must resolve inside the package, not at the system root.

Remote min sessions, arm64, freshly activated for each run:

build min check standalone tests
this PR (0.15.1 + patch) Pass (both)
negative control: unpatched 0.15.1 with the same tests Fail: template_path_escape_refused (typst init followed the escaping path) and template_path_absolute_is_package_relative (resolved at the system root)

min check --packages typst on this PR passes every check, with no Skip.

Blast radius: typst only; nothing depends on it.

Follow-up: the vuln scanner can't see carried patches, so typst 0.15.1 will still show GHSA-rw6x as affected. It will need a VEX statement once this merges (drafted for Bryan; not filed). Once pkgs moves to stdlib 0.0.22, this is also a candidate for attrs.revision = 1 / attrs.patches[] under the new -rN scheme (minimal#1277, pkgmgr-rs#1036).

nickel format --check, bash -n and mip dump (amd64 and arm64) all pass.

🤖 Generated with Claude Code

…e.path traversal)

Verbatim format-patch of fdb38b89f1 (typst#8989, main only; upstream will not
cut a patch release). Adds standalone tests mirroring upstream's smoke tests;
both fail on unpatched 0.15.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner October 23, 2026 03:53
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 59 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 69 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 4017ba5 and 33cf258.

📒 Files selected for processing: 3
  • packages/typst/GHSA-rw6x-h3xm-cvq5.patch
  • packages/typst/build.ncl
  • packages/typst/build.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bryan-minimal
bryan-minimal added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit a6d334a Oct 23, 2026
11 checks passed
@bryan-minimal
bryan-minimal deleted the security-typst-ghsa-rw6x branch October 23, 2026 22:02
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