-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for privilege escalation vulnerability #6748
base: master
Are you sure you want to change the base?
Conversation
Fixes issue where the service would write the data dir into /usr/bin if the binary was within /usr/bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the submission!
Added some comments there. However, let's wait for @ainar-g's input before changing anything, he may add some corrections.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #6748 +/- ##
==========================================
- Coverage 51.74% 51.66% -0.08%
==========================================
Files 185 185
Lines 14884 14907 +23
==========================================
Hits 7702 7702
- Misses 6431 6454 +23
Partials 751 751 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional notes:
-
It is not clear how this change affects the BSDs, and in particular macOS, which really wants applications to be installed in
/Applications
, for example. -
It seems like it's breaking Docker? There are assumptions about AdGuard Home being installed to
/opt/
there. -
The install script should probably be changes as well to fully implement the change for new installations as well.
Regarding macOS, I am very unfamiliar with the system. But if /Applications is owned by root and denies writes by non-root users, I don't see we can't just define I will test AdGuardHome on a OpenBSD vm at some point and verify it works; currently it uses the same patch as the one for linux.
I don't see why it would break docker as Docker doesn't install the service and the checks added only run when
I am not as familiar with the script, and it is very large. But would redefining $agh_dir to equal the new location, obtained by the command ...
# Function install_service tries to install AGH as service.
install_service() {
# Installing the service as root is required at least on FreeBSD.
use_sudo='0'
if [ "$os" = 'freebsd' ]
then
use_sudo='1'
fi
if ( cd "$agh_dir" && maybe_sudo ./AdGuardHome -s install )
then
$agh_dir = "/usr/bin"
return 0
fi
log "installation failed, removing $agh_dir"
... Testing Results
|
Notes from a macOS perspective, while it's not strictly required by the system, there are reasons as to why most users should be running it from the Applications folder:
|
Do we have any updates for this issue? Side note the CVE number is CVE-2024-36586. |
Description
Patch for a privilege escalation vulnerability in the service component of AdGuardHome.
Please note that this pull request does not come with a issue number because it was privately disclosed via email to @ameshkov and @ainar-g; due to the sensitive nature of security disclosure.
Patch Details
This patch sets the correct executable permissions for AdGuardHome when running the
AdGuardHome -s install
command. This includes setting the owner as root:root and permissions to 0755 (blocks write access to all users except root). Furthermore, the binary is moved to/usr/bin/
to add it to the global path and vitally place it in a non-root read-only directory, otherwise the previous steps would not be enough to protect against this vulnerability.Patch Knock On Effects (all accounted for)
Additional changes include, disabling the installation of AdGuardHome as a service on Windows due the vulnerability being unable to be patched (Go lacks the proper API bindings to set file ownership and permissions on Windows). It is highly recommended a msi installer is created to install the service, rather than allow a user to try install it manually without any guidance. Moreover, even with guidance the process is complex and time consuming. Do note this can easily be changed in
internal/home/service.go
on line698
.Other alterations. There is a issue where AdGuardHome will write it's data to
/usr/bin/
if the executable is within that path. This is an inappropriate directory for data and thus should not be used. Instead if the program is within/usr/bin/
AdGuardHome now assumes a new directory/var/lib/AdGuardHome
(auto created recursively if it does not exist). Note, this does not interfere with the desired behavior of allowing AdGuardHome to use the current executable dir as it's workDir, it only redirects the workDir if the binary is withinuser/bin
(essentially if AdGuardHome is running as a service it will store data in the new location, unless overwritten with the existing workdir CLI option).Testing
This PR has been tested on Ubuntu wsl.