Skip to content
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

port to plain Debian (non-Qubes) #33

Open
adrelanos opened this issue Jul 15, 2019 · 10 comments
Open

port to plain Debian (non-Qubes) #33

adrelanos opened this issue Jul 15, 2019 · 10 comments

Comments

@adrelanos
Copy link
Contributor

Wondering if this could be useful for Debian too.

(Not only Debian TemplateBased AppVMs in Qubes. I mean "normal" Debian systems without Qubes.)

More operating system compatibility could get more eyes on this. Then the Qubes support would ideally be nothing too special.

It is already easy to get a Debian boot menu which has a live and a persistent mode using grub-live.

Similarly I am planning to add a boot menu entry which allows the user to boot with root access or without root access.

A system booted without root access could benefit from the same mechanisms that "Qubes"-"VM"-Hardening is using. We could scratch the "Qubes" as well as the "VM" part as this should be possible on any Debian host or VM or any Linux (etc.).

I might even implement all of this myself into the security-misc (or separate) package. Debian packaging works already perfectly and Fedora / Qubes packaging is on the way too (QubesOS/qubes-issues#1885).

So if you are wondering why I am creating lots of tickets and/or asking lots of questions lately, then this post will explain my motivation.

@tasket
Copy link
Owner

tasket commented Jul 16, 2019

I've thought about this in the past, but wasn't aware of grub-live so I assumed it would only involve making /home files immutable. But maybe a whitelisting, etc. would also be valuable to a 'live' instance.

If you end up putting some of these features into security-misc, I could add an installer exception for Whonix templates so there is no collision, or put a notice in the readme to that effect. For the time being, however, I'd like to continue here with Qubes-VM-hardening's narrower scope of whitelisting and re-enabling auth, possibly making that work in Qubes-Whonix.

@adrelanos
Copy link
Contributor Author

adrelanos commented Jul 16, 2019 via email

@adrelanos
Copy link
Contributor Author

What's the rationale of making user files immutable?

chattr -R -f +i $chfiles $chfiles_add $chdirs $chdirs_add

After reboot, malicious modification would be undone anyhow.

Malware being active in the current session could stay resident so or so. It does not have to require any dotfiles for that. And after reboot, gone so or so. So currently I don't see the gain by chattr +i . Could you please kindly explain?

@tasket
Copy link
Owner

tasket commented Aug 19, 2019

vm-boot-protect protects against unprivileged malware persistence during startup. Its basic method is admin-controlled +i immutable...

This helps prevent unprivileged malware staying active, either through some user auto-run ability or shimming (altering PATH, for example). Since a user can delete then replace any file in a folder they own (even files owned by root!), immutable is needed to stop this. It could make a difference (at least with initial post-startup state) in the default case where /home contents are not quarantined/replaced.

vm-boot-protect-root protects against privileged malware persistence during startup. Its basic method is file quarantine...

If we assume that privilege escalation is attained, then /home becomes more of a problem as indeed +i won't stop such malware. But that's why I'm making it easier to add /home to quarantine (i.e. privdirs).

(BTW "so or so" isn't an expression I'm aware of; I don't know the meaning of those statements. "so and so" usually means 'some other unimportant person'.)

@adrelanos
Copy link
Contributor Author

adrelanos commented Aug 19, 2019 via email

@adrelanos
Copy link
Contributor Author

Rewrite for plain Debian (non-Qubes) is in process. Early version below. Not ready for testing yet. Operating system integration not done yet.

https://github.com/Whonix/security-misc/blob/master/usr/lib/security-misc/virusforget

Could you have a look please to see if you see any obvious holes in this script?

@tasket
Copy link
Owner

tasket commented Aug 20, 2019

virusforget seems to operate on a principle of comparing live files with backup copies.... I probably missed it, but I didn't see where virusforget/backup was being protected.

Also, I learned that symlinks don't take attribs like immutable (sigh). I plan to work around this with something like find -type l + mount --bind.

@adrelanos
Copy link
Contributor Author

adrelanos commented Aug 21, 2019 via email

@tasket
Copy link
Owner

tasket commented Aug 21, 2019

It's an excellent point I did not consider yet. It resides in /home/virusforget. Only accessible by root.

The /home/user dir is owned by user, so virusforget (-i mutable) can be renamed or even deleted also by non-root attacker. Then it could be replaced with changed files.

(root compromise) How does Qubes-VM-hardening protect against that? Basically that configuration has to be done in TemplateVM and therefore resides in root image outside of reach of malware inside TemplateBasedVM?

Yes. User has to decide they want to protect /home against root attacks. The tools for that are adding /home to quarantine (privdirs) and/or using whitelists or deployment files from /etc/default/vms. Alternately, they could simply generate a sha256sum list for /home/user contents.

Another interesting approach (in future) might be to automatically create a sha256sum list specifically for chfiles and chdirs, or to copy those files into /etc/default/vms for deployment. IOW, help the user with this type of advanced configuration.

@tasket
Copy link
Owner

tasket commented Aug 21, 2019

The philosophy behind the two available levels (vm-boot-protect and vm-boot-protect-root) and the user having to choose advanced protection of /home is that the rest of /rw is normally executed as 'root' at startup, while /home contents are normally executed as 'user'. If non-priv user has an escalation exploit they can use from /home startup scripts, then they can persist the escalation... but only until the vulnerability is patched.

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

No branches or pull requests

2 participants