omtex
aien-dev/omtex
Brought by drakestapleton
omtex / AUDIT_SCOPE.md
| 1 | # Audit scope |
| 2 | |
| 3 | Written for an outside, independent security audit. Revision described: |
| 4 | `4c86614a1ee09a5b8ca4da6c2f4a7bc958d1fd64` on `main`, 2026-10-26. Everything below is taken from the repository's own files at |
| 5 | that revision; items marked NOT_RUN were not executed while writing this document. |
| 6 | |
| 7 | ## What this repository is |
| 8 | |
| 9 | An Omega library, `lib/omtex.om` (1,176 lines, an `om2` unit), that writes LaTeX. A paper |
| 10 | (`examples/*/paper.om`) is concatenated after the library and compiled with the pinned `omc`; the |
| 11 | resulting generator prints the `.tex` file, and `paper.gen check OMC DIR` compiles every Omega |
| 12 | listing to confirm it is accepted or refused as stated. `docs/DESIGN.md` (110 lines) is the |
| 13 | contract for escaping, the math check, listings and refusal codes. `tools/` holds `build.sh`, |
| 14 | `pin.sh`, `compare.sh` and `zenodo-draft.sh`; `tests/run.sh` is the suite. Licence: Apache 2.0 |
| 15 | (`LICENSE`, `NOTICE`). |
| 16 | |
| 17 | ## What to review, in priority order |
| 18 | |
| 19 | 1. Prose escaping in `lib/omtex.om` against the table in `docs/DESIGN.md` ("Prose markup"): |
| 20 | always-escaped characters, paired quotes and emphasis, cite and ref keys, the allowed |
| 21 | backslash escapes, and refusal of control bytes and malformed UTF-8 (trap 11, exit 111). |
| 22 | 2. The math check: printable ASCII only, balanced braces, no `% $ #`, and a deny list of control |
| 23 | sequences (`\input \include \write \def \edef \gdef \xdef \let \catcode \immediate \openout |
| 24 | \openin \csname \special \read`). It is a deny list; check whether other primitives or macros |
| 25 | (for example `\newcommand`, `\renewcommand`, `\expandafter`) can reach the same effects. |
| 26 | `rawtex` and `preamble` lines use the same check with `&` and `\\` allowed. |
| 27 | 3. Listings: bodies containing `\end{lstlisting}`, non-ASCII or control bytes other than LF and |
| 28 | tab are refused. |
| 29 | 4. The `check` path (`txcheck`, `txrun`, `txchild`, `txpath`): it writes `DIR/<label>.om` and runs |
| 30 | `OMC` with fork and exec. The label character set (`zrkey`) allows `.` and `/`; check whether a |
| 31 | label such as `../x` leaves `DIR`. |
| 32 | 5. `tools/zenodo-draft.sh`: every request goes through `api()`, which refuses any URL containing |
| 33 | `publish`; the token is written to a header file under `umask 077` and unset; the script ends by |
| 34 | re-reading the deposition and failing unless it is still unsubmitted. The `eval` of the token |
| 35 | variable name takes a fixed name chosen by `--sandbox`. |
| 36 | 6. `tools/build.sh`: runs `pdflatex -interaction=nonstopmode -halt-on-error -no-shell-escape`, |
| 37 | and `bibtex` only when the `.aux` names bibliography data. |
| 38 | 7. `tools/pin.sh`: fetches omega-mv commit `91b3c9326919faf1491e29ae9276929e8349b8c7` with |
| 39 | `git fetch --depth 1` and refuses any `omc` whose sha256 differs from |
| 40 | `189ada82e00bb440cb41351bd252cc68c54a1b1050051cc42a1df700081c3b54`. |
| 41 | |
| 42 | ## Trust boundaries |
| 43 | |
| 44 | - The paper source is written by its author and compiled as code. omtex treats prose and math |
| 45 | text inside it as data that must not become arbitrary LaTeX. |
| 46 | - pdfTeX is trusted to honour `-no-shell-escape`. |
| 47 | - Zenodo is reached over HTTPS with a bearer token from the environment (`ZENODO_TOKEN` or |
| 48 | `ZENODO_SANDBOX_TOKEN`). |
| 49 | |
| 50 | ## Threat model summary |
| 51 | |
| 52 | - Assets: the integrity of generated papers, the Zenodo token, published Zenodo records. |
| 53 | - Attackers considered: prose or math text that tries to inject LaTeX; a mistaken run of the |
| 54 | Zenodo script against a published record. |
| 55 | - Defended: escaping with no raw prose path, math deny list, listing checks, output cap of 4 MiB, |
| 56 | deterministic output, the publish refusal in `api()`. |
| 57 | - Not defended / explicitly out of scope: a hostile paper author (the paper is a program; it can |
| 58 | call Omega host words directly); TeX Live vulnerabilities. |
| 59 | |
| 60 | ## Build from source at a pin |
| 61 | |
| 62 | Host tools and versions are listed in `DEPENDENCIES.md` (pdfTeX 3.141592653-2.6-1.40.25, TeX Live |
| 63 | 2023, `cm-super` 0.3.4-17, `git`, `sha256sum`). The compiler is fetched by `tools/pin.sh`. |
| 64 | |
| 65 | ```sh |
| 66 | tools/build.sh examples/listings/paper.om build/listings |
| 67 | OMTEX_NO_PDF=1 tools/build.sh examples/hello/hello.om build/hello # stop after the .tex |
| 68 | ``` |
| 69 | |
| 70 | ## Run every test |
| 71 | |
| 72 | NOT_RUN while writing this document. From AGENTS.md: |
| 73 | |
| 74 | ```sh |
| 75 | tests/run.sh |
| 76 | tools/compare.sh ORIG.tex ORIG.pdf build/X/paper.tex build/X/paper.pdf |
| 77 | ``` |
| 78 | |
| 79 | `tests/run.sh` pairs every refusal case with an accepted case, prints NOT_RUN (never PASS) for |
| 80 | cases the host cannot run, and exits 1 on any FAIL. `tools/compare.sh` needs poppler-utils and an |
| 81 | original paper's `.tex` and PDF. `tools/zenodo-draft.sh` needs a Zenodo token and network; NOT_RUN. |
| 82 | |
| 83 | ## Known limitations and NOT_RUN |
| 84 | |
| 85 | - Hosted CI (`.github/workflows/ci.yml`, added with this document) runs `sh tests/run.sh` with the |
| 86 | pinned `omc` on a GitHub-hosted arm64 runner and writes an SPDX SBOM. It does not run |
| 87 | `tools/compare.sh` or `tools/zenodo-draft.sh`. |
| 88 | - Moving the pin requires rerunning `tests/run.sh`, both reproductions and the keyword parity test |
| 89 | (AGENTS.md). |
| 90 | - A typesetting engine in Omega is not started; pdfTeX stays a host tool (`DEPENDENCIES.md`). |
| 91 | - `curl`, `jq` and `md5sum` are used by the Zenodo script; Omega replacements are named in |
| 92 | `DEPENDENCIES.md` but not built. |
| 93 | |
| 94 | ## Dependencies and provenance |
| 95 | |
| 96 | - Build path: pinned `omc` (fetched and hash-checked), pdfTeX and TeX Live packages, `bibtex` when |
| 97 | used, POSIX shell tools. The generator is a static Omega binary that only writes LaTeX to stdout |
| 98 | (`DEPENDENCIES.md`). |
| 99 | - Verification only: poppler-utils 24.02.0, mawk 1.3.4 (for the pin's `seed/omc/genkw.awk`). |
| 100 | - Zenodo script: curl 8.5.0, jq 1.7, md5sum (coreutils 9.4). |
| 101 | |
| 102 | ## Evidence |
| 103 | |
| 104 | - `evidence/tests.txt`: `TESTS pass=59 fail=0 not_run=0`. |
| 105 | - `evidence/REPRODUCTION.md` with `compare-omega-language.txt` and `compare-turing-brief.txt`: |
| 106 | reproductions of two published papers (for the first, 0 differing text lines and 9 of 9 pages |
| 107 | pixel-identical against the original rebuilt on the same TeX Live). |
| 108 | - `evidence/zenodo-new.txt` and `evidence/zenodo-newversion.txt`: draft runs against zenodo.org. |
| 109 | |
| 110 | AGENTS.md: never edit a recorded result. These are the author's logs, not independent |
| 111 | reproduction. |