GeezerVison is showing github.com — Kernel version is only checked at its start, then run through eval · Issue #63 · tmiland/kernel-installer
Kernel version is only checked at its start, then run through eval #63
Description
Problem
The kernel version is only checked at its start, and is later run through eval:
chk_version (kernel_installer.sh:437) uses ^[0-9]+\.[0-9]+ with no end anchor, so anything that starts with digits.digits passes. -k (:745) only checks the first character.
run_ok runs its command string with eval (src/slib.sh:344), and the version is pasted into those strings: run_ok "wget -c $kernel_url" (:1432) and run_ok "tar xf linux-${LINUX_VER}.tar.$file_ext" (:1442).
- With
--mainline, the version comes from https://www.kernel.org/finger_banner (:84, :93) and reaches that eval before anything is downloaded or checked.
Impact
A malformed version string becomes shell code run as root. On the default stable/longterm path, signature checking fails first for a bad version, so the tar line is not reached (traced in the code, not run). The exposure is mainly --mainline and runs with GET_VERIFIED_TARBALL=0. The banner is fetched over HTTPS, so this needs a tampered response. Still, version data should not be able to run as a command.
Suggested fix
- Validate the whole string, e.g.
^[0-9]+\.[0-9]+(\.[0-9]+)?(-rc[0-9]+)?$. Apply it to -k, to the versions read from the banner, and to LINUX_VER / MAINLINE_VER from the environment.
- Longer term: call
run_ok with a function or quoted arguments instead of a string for eval.
How this was checked
On Linux Mint 22.3 (bash 5.2), main 8cbf9f2:
- The
chk_version pattern accepts 6.17.7;junk and 6.17x y.
- With
src/slib.sh sourced, run_ok "echo linux-${v}.tar.xz" and v='6.17.7;echo MARKER' wrote two lines to the log, linux-6.17.7 and MARKER.tar.xz, so the ; split the command. The control run (v=6.17.7) wrote a single line linux-6.17.7.tar.xz.
- Not tested: a full installer run with a tampered banner.
Metadata
Metadata
Development
No branches or pull requestsIssue actions