Repository navigation
Closed
Labels
Milestone
Description
背景
TeX は単なる markup parser ではなく、入力内容によってはファイルアクセスや外部コマンド等のリスクがある。
texrun の core process と TeX 実行環境の信頼境界を明文化し、MVP で実装可能な防御を追加する。
MVP で実装するもの
個別の実装は関連 Issue で行い、この Issue では横断的なポリシー決定・不足分の実装・文書化を担当する。
- compile timeout(実装は Implement the TeX Live engine with latexmk #5。default 値をここで決める)
- timeout 時の child process termination(process group 単位。実装は Implement the TeX Live engine with latexmk #5)
- 最大入力サイズの検討(workspace へのコピー時に適用。Implement isolated compile workspaces #4)
- 最大 artifact サイズの検討(PDF / preview。Generate page previews and inspect PDF metadata #8)
- workspace 外 path の拒否(実装は Implement isolated compile workspaces #4)
- shell を介さない subprocess invocation(Implement the TeX Live engine with latexmk #5, Generate page previews and inspect PDF metadata #8)
- dangerous option を暗黙に有効化しない(
-shell-escapeを常に無効化、latexmkrcを読まない-norc) - kpathsea の
openin_any/openout_anyを paranoid(p)にし、TeX から workspace 外の読み書きをどこまで防げるか検証する - 子プロセスに渡す環境変数を allowlist 化する
- network access を必要としない実行を基本とする
設計として明文化するもの
将来的には TeX engine を texrun 本体と別の isolation boundary で動かす。
候補:
- Docker / Podman
- gVisor
- microVM
MVP で container orchestration 全体まで作る必要はないが、後から worker 実装を差し替えられる構造にする。
検討事項
-shell-escape/ restricted shell escape の扱い- TeX から host filesystem が見える範囲
- process tree の確実な kill
- CPU / memory limit
- network namespace
- font / TeX package の読み取り専用提供
完了条件
- 現時点で保証する安全境界と保証しない範囲が文書化されている(例:
docs/security.md。脆弱性報告窓口としてSECURITY.mdも検討)- 特に「MVP の in-process 実行では TeX から TeX Live の texmf ツリー等 host の一部が読める」ことを明記する
- timeout が実際に機能する
- 将来 sandbox backend を変更しても core API を壊さない設計になっている
- 危険な入力(
\write18、\input{/etc/passwd}、latexmkrc、root 外 symlink)に対する挙動が Add integration fixtures for common LaTeX scenarios #10 の fixture で検証されている
依存
- Implement isolated compile workspaces #4, Implement the TeX Live engine with latexmk #5 と並行して進め、方針はそれらの実装前に決めるのが望ましい
Activity
docs: add initial README (#18)
feat(core): define compile domain model and engine interface (#20)
nishide-dev commentedon Sep 30, 2026
PR #20(#3)レビューからの申し送り:
.texrun/out(dot ディレクトリ配下)。kpathseaopenout_any=p/openin_any=pと組み合わせたとき、-outdirを相対/絶対で渡す両方で aux・log・\include子ファイルの.auxが書けるか検証すること(paranoid モードは dot file への書き込みを拒否するため要確認)。WorkspacePathは制御文字を拒否済みだが、bidi 制御文字(U+202E 等)やゼロ幅文字は許容している。表示時の扱いを検討。docs(security): address review on command execution and read boundaries
docs(security): define the MVP security model and execution limits (#22)
feat(workspace): add isolated compile workspaces (#21)
nishide-dev commentedon Sep 30, 2026
完了条件を満たしたため close します。
docs/security.md/SECURITY.md(docs(security): define the MVP security model and execution limits #22)timeoutfixture と engine の integration test で検証CompileContext経由の設計(feat(core): define compile domain model and engine interface #20)。container backend は Add a container-based sandbox backend for the TeX engine #26 で追跡