Skip to content

Security fixes, and Rust crates instead of programs and hand-written parsers - #4

Merged
Neotoxic-off merged 2 commits into
masterfrom
dev
Oct 19, 2026
Merged

Neotoxic-off merged 2 commits into
masterfrom
dev

Conversation

@Neotoxic-off

Copy link
Copy Markdown
Owner

Security fixes from an audit, and Rust crates in place of external programs and hand-written parsers.

Security

  • Opening a folder no longer runs its programs. lim ran git inside the opened folder, and git obeys that folder's .git/config: core.fsmonitor ran on every file open, a clean filter in the explorer, textconv in the commit pickers, gpg.program in git log/show. A project delivered as an archive or a copied checkout could run any command as the user. git is now read with gix, which never takes filter or diff drivers from the folder's own config.
  • No more hangs on FIFOs and devices. The pickers (preview, grep, TODO), the reload after a shell command and the statusline's .git/HEAD read only regular files, with bounded reads.
  • Private backups. Panic-recovery copies and save temp files are created new, owner-only (0600), and a link planted at their name is not followed.
  • Bidi control characters are drawn as ? (no "Trojan Source" reordering); the Windows clipboard read is bounded by the block size.

Crates instead of programs or hand-written code

What Before Now
git (signs, status, file list, log/graph, show, stash, browse) git processes gix (src/repo.rs)
gitsigns diff hand-written Myers imara-diff (via gix)
Syntax highlighting keyword lists, ~40 languages syntect + bat's grammars (two-face), 200+
Markdown preview hand-written parser pulldown-cmark
Config JSON hand-written parser jsonc-parser (comments, trailing commas)
Update over HTTPS libcurl (dlopen) / WinHTTP FFI ureq + rustls
Clipboard xclip/wl-copy/pbcopy, user32 FFI arboard
Open URL/file xdg-open/open/explorer open
Text tools hand-written base64/base32/hex/URL/SHA-256 data-encoding, percent-encoding, sha2
Random bytes, time zone /dev/urandom, RtlGenRandom, localtime_r, GetTimeZoneInformation getrandom, jiff

Fixed on the way: the explorer passed git status --relative, which git rejects, so it never showed statuses.

Measured

Windows, same 3000-file repository, median of 20 runs:

before after
open a file (gitsigns) 20.1 ms 1.5 ms
git status picker 22.5 ms 6.2 ms
stash picker + preview 52.5 ms 3.3 ms
gitsigns diff, 20k lines 3.8 ms 2.1 ms

The perf budgets hold in debug and release; lim still beats Neovim on every vs_neovim operation. Costs: syntect highlighting is slower than the keyword lists (typing 500 chars with a frame per key: 125 → 356 ms in release, budget 4000 ms); the binary grows from about 2 MB to about 7 MB; a clean release build takes about 3x longer.

Limits

  • A far jump parses from 300 lines above (as Vim's syntax sync minlines): a block comment opened further up is missed until scrolled through. Lines over 20,000 bytes are drawn plain.
  • PowerShell has no grammar in bat's set, so .ps1 files are not colored.
  • Clipboard and default-app opening were not tested on a real desktop (the tests disable them).

Checks

  • cargo clippy --all-targets: 0 warnings on Windows and Linux (WSL).
  • cargo test: 158/158 on Windows, 161/161 on Linux, perf budgets included.
  • vs_neovim: lim faster on every row.
  • Live HTTPS test against the GitHub API passes on Windows and Linux.

…ecurity audit's findings

Security (from the audit):
- git ran repository-chosen programs on file open (core.fsmonitor), in the
  explorer (clean filters), the commit pickers (textconv) and git log/show
  (gpg.program). git is now read with gix, which takes filter and diff
  drivers only from the user's and the system's config, never from the
  opened folder's .git/config.
- The pickers, the reload after a shell command and the statusline's
  .git/HEAD read only regular files, with bounded reads: a FIFO or a
  symlink to /dev/zero no longer hangs or exhausts lim.
- Panic backups and save temp files are new files, owner-only (0600),
  and a link planted at their name is not followed.
- Bidi controls are drawn as `?`; the Windows clipboard read is bounded.

Crates for what lim did with programs or by hand:
- gix for git (gitsigns base, status, file list, log/graph, show, stash,
  browse) in src/repo.rs; imara-diff (through gix) for gitsigns.
- syntect with bat's grammars (two-face) for highlighting; pulldown-cmark
  for the Markdown preview; jsonc-parser for the config.
- ureq with rustls for the update's HTTPS (no libcurl or WinHTTP FFI).
- arboard for the clipboard, open for the default app.
- data-encoding, percent-encoding, sha2, getrandom and jiff for the text
  tools' encodings, hashes, random bytes and time zones.

Dependencies are optimized in debug builds so the perf budgets hold in
`cargo test`. The old explorer passed `git status --relative`, which git
rejects, so it never showed statuses; it does now.
@Neotoxic-off
Neotoxic-off merged commit 1794aa5 into master Oct 19, 2026
8 checks passed
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