updatecheck.sh writes the versions file into /etc/pihole, which is owned
by the unprivileged pihole user. When it ran as root (the installer,
`pihole -up`, `pihole checkout`, `sudo pihole updatechecker`, the Docker
start-up check, ...) the pihole user could watch the directory, swap the
script's temporary file for a symlink and have root chmod/chown/append
to whatever it pointed at. Reproduced: a root-only file ended up owned by
pihole.
- When started as root, hand over to the pihole user (`su`) and exit
with its result. This covers every caller, including future ones, and
the pihole user can only damage what it already owns. The "reboot"
argument is forwarded.
- Drop the chown of the temporary file; it is no longer needed and was
the dangerous part.
- Use `mv -fT` so that a symlink to a directory at the target path is
replaced rather than having the temporary file moved into the
directory.
Tests (fresh install): started as root the script must do its work as
the pihole user and write a pihole-owned 0644 versions file; a symlink
(to a file or to a directory) at the target path must be replaced rather
than followed.
Note: running as the pihole user needs git to trust the root-owned Core
and Web repositories (safe.directory). The installer sets that up (see
the following commit); other installers of this script, such as the
Docker image, need the equivalent.
Reported-by: Keith Linneman (LinnemanLabs)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
pihole-FTL-prestart.sh runs as root (ExecStartPre=+) and, right after
chown-ing /etc/pihole and /var/log/pihole to the pihole user, walks them
with `find ... -exec chmod`. find only builds a list of paths and chmod
acts on them afterwards, so the pihole user can swap a directory or file
for a symlink in between; root's chmod then follows it and changes the
permissions of a file pihole has no business touching (e.g. 0755 on
/etc/shadow makes it world-readable).
Reproduced against the stock script: with a pihole-owned loop flipping a
directory name between "real directory" and "symlink to a root-only
file", the file went from 0600 to 0755 within a handful of restarts.
Run the three find calls as the pihole user instead. It owns everything
below those directories, and a symlink pointing anywhere else only yields
a permission error. Failure stays non-fatal so it can never stop FTL from
starting.
Add a deterministic test: with the script's chown stubbed out, a
root-owned probe stays untouched only if the fix-up does not run as root.
This is independent of the other changes in this series and applies to
the same pre-existing code on master/development, so it can be
cherry-picked on its own.
Reported-by: Keith Linneman (LinnemanLabs)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
- updatecheck.sh: reword the publish comment to refer to mv/rename(2) and
place it directly above the mv call; use chmod 0644
- pihole-FTL-prestart.sh: replace the loop/rm/no-op redirect with a single
documented su call using touch and chmod
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
The `pihole updatechecker` cron job and pihole-FTL-prestart.sh both ran as
root and created/truncated/chmod-ed /etc/pihole/versions on a fixed path
without O_NOFOLLOW. Since the pihole user owns /etc/pihole, a compromised
pihole account could replace `versions` with a symlink to any root-owned
file and have root truncate it, relax its mode, or create it. The chmod
step also allows exposing e.g. /etc/shadow. See GHSA-xch2-4qxw-g5vj.
- pihole.cron: run `updatechecker` as the pihole user (like updateGravity),
so root no longer writes into /etc/pihole from cron.
- updatecheck.sh: build the file in a mktemp'd temp file and rename() it
into place; a symlink at the target is replaced, not followed.
- pihole-FTL-prestart.sh: create/permission `versions` (and, same bug
class, `dhcp.leases`) as the pihole user via `su`, neutralising any
planted symlink. A symlink to a root-owned file then only yields EPERM.
- basic-install.sh / uninstall.sh: register the root-owned Core and Web
repos in git's system-wide safe.directory list so the now-unprivileged
updatechecker can still read local versions.
Behaviour change: /etc/pihole/versions is now consistently mode 0644 after
a service (re)start; the find in prestart previously left it 0640, against
the file's own comment and updatecheck.sh's own chmod 644.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
pihole-FTL-prestart.sh sets /etc/pihole/versions to 0644 so that
pihole -v works for all users, but the find command that sets every
file in /etc/pihole to 0640 runs right after it and undoes that. After
every FTL start, pihole -v run by a normal user fails with "Permission
denied" and shows N/A for all versions.
Move the chmod after the find commands, and check in the fresh install
test that the file is readable by a user other than pihole.
Signed-off-by: candygoogy <186837547+candygoogy@users.noreply.github.com>
Debian 11 (bullseye) reached end of life on 2026-08-31. Its security suite is being retired: the pool files still referenced by the `bullseye-security` index return 404 on `deb.debian.org`, and the index itself expires on 2026-09-07. Installing the `pihole-meta` dependency package therefore fails and `distro-test (debian_11)` is red on every pull request. As a required check, it blocks all merges, and there is nothing left to fix on our side.
Ubuntu 20.04 (focal) is out of standard support since 2025-05 and only receives ESM updates. Its archive is still complete, so the job is green today, but it will break the same way once focal moves to `old-releases.ubuntu.com`. Drop it now rather than waiting for the next red matrix.
Signed-off-by: DL6ER <dl6er@dl6er.de>
Render both the current template and a v6.4.3 reference with the local su
line substituted before comparing against the installed file, so the
freshness check stops always reporting a difference. On fresh installs the
rendered file is installed directly. Unmodified v6.4.3 files (which lack
the postrotate signal for FTL.log and webserver.log) are replaced with the
current template, and customized files are left alone with a hint naming
the missing postrotate.
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
The arpflush command has been deprecated in favor of networkflush.
This commit completes the deprecation cycle by removing:
- arpFunc() function definition
- arpflush case statements in command routing
- All associated comments and references
Users should use 'pihole networkflush' instead.
Signed-off-by: Adnan Mazharuddin Shaikh <adnanmazharuddinshaikh@gmail.com>
If the system's /etc/logrotate.conf has dateext enabled (the upstream
default, carried by most distros), our stanzas would inherit it when
the system's scheduled logrotate reads them via that file - but our
own forced runs invoke /etc/logrotate.d/pihole directly, bypassing
logrotate.conf entirely, so they'd still use numeric suffixes. Same
config, two different rotated filenames depending on who rotated it
first.
Set nodateext explicitly in each of our stanzas (scoped to just our
own blocks, so it can't leak into other packages' logrotate.d entries)
to keep this deterministic. Numeric suffixes also match what
piholeLogFlush.sh's manual flush path already assumes (it looks for
logfile.1 specifically).
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
Our config moved into /etc/logrotate.d/pihole a while back, so the
system's own scheduled logrotate now picks it up too. Our nightly and
@reboot forced runs were still using a private state file though, so
the system's run and ours each rotated the same logs independently,
unaware of each other.
Drop the private state file and use logrotate's default one instead,
so both sides agree on what's already been rotated. Also clean up the
now-stale /etc/pihole/logrotate and private state file left behind by
older installs.
Signed-off-by: Adam Warner <me@adamwarner.co.uk>