[PR #1079] [MERGED] fixing --hosts-file privelege check #3844

Closed
opened 2026-05-05 10:08:57 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netblue30/firejail/pull/1079
Author: @ibukanov
Created: 1/29/2017
Status: Merged
Merged: 1/29/2017
Merged by: @netblue30

Base: masterHead: copy_to_root_fix


📝 Commits (1)

  • 5292798 fixing --hosts-file privelege check

📊 Changes

3 files changed (+68 additions, -26 deletions)

View changed files

📝 src/firejail/firejail.h (+1 -0)
📝 src/firejail/fs_hostname.c (+1 -1)
📝 src/firejail/util.c (+66 -25)

📄 Description

Currently the code uses the access() call to check if the user has an access to a file that is copied into the root as /etc/hosts. This inevitably adds a race when the user changes the file to a symbolic link pointing to an arbitrary location on the filsystem after the access check is done but before opening the file to copy it. This potentially allows to read any file on the system.

To close this the code adds a utility copy_file_from_user_to_root . It opens the copy destination file as root and then forks/drop privileges. Then as a user the utility opens the source file and do the copy into the destination descriptor that is preserved accross the fork.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netblue30/firejail/pull/1079 **Author:** [@ibukanov](https://github.com/ibukanov) **Created:** 1/29/2017 **Status:** ✅ Merged **Merged:** 1/29/2017 **Merged by:** [@netblue30](https://github.com/netblue30) **Base:** `master` ← **Head:** `copy_to_root_fix` --- ### 📝 Commits (1) - [`5292798`](https://github.com/netblue30/firejail/commit/5292798bb4fffc2f8c9b6de2bf373cf86ebf8e3b) fixing --hosts-file privelege check ### 📊 Changes **3 files changed** (+68 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `src/firejail/firejail.h` (+1 -0) 📝 `src/firejail/fs_hostname.c` (+1 -1) 📝 `src/firejail/util.c` (+66 -25) </details> ### 📄 Description Currently the code uses the access() call to check if the user has an access to a file that is copied into the root as /etc/hosts. This inevitably adds a race when the user changes the file to a symbolic link pointing to an arbitrary location on the filsystem after the access check is done but before opening the file to copy it. This potentially allows to read any file on the system. To close this the code adds a utility copy_file_from_user_to_root . It opens the copy destination file as root and then forks/drop privileges. Then as a user the utility opens the source file and do the copy into the destination descriptor that is preserved accross the fork. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 10:08:57 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#3844
No description provided.