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

Support "include" directive for conditionals and negative conditionals #6459

Open
QUser534 opened this issue Sep 1, 2024 · 4 comments
Open
Labels
enhancement New feature request

Comments

@QUser534
Copy link

QUser534 commented Sep 1, 2024

Is your feature request related to a problem? Please describe.

I want to create very restrictive sandbox when net is enabled because the biggest risk is stealing private data. If net is NOT enabled, then I would like to have a looser profile that enables more data access.

In addition, support of negative conditionals.

Describe the solution you'd like

?HAS_NET: include super-restrictive-rules.inc

?!HAS_NET: include looser-rules.inc

Describe alternatives you've considered

Nothing as clean as this. Currently I have to use a loader script to load different profiles. Would be much easier to be able to add a conditional to global.inc to make software-wide.

I looked at #2158 and could not see any real reason why include was excluded.

@rusty-snake
Copy link
Collaborator

rusty-snake commented Sep 1, 2024

There is one thing you have to consider. globals.local is usually included at the top (after foo.local). Meaning ?HAS_NET: will be false in 99% for the times you reach it in globals.local.

Also ?HAS_NET: will be true once net is used, right? Be it net none or net eth0.

Edit actually we already have ?HAS_NET

I want to create very restrictive sandbox when net is enabled because the biggest risk is stealing private data.
If net is NOT enabled, then I would like to have a looser profile that enables more data access.

I'm happy to see that you have a more real world thread model than "I want to protect root because it is the user with the highest privileges". But keep in mind that a looser profile might allow data stealing thought other means than direct networking.

negative conditionals

workaround:

?HAS_NET: include super-restrictive-rules.inc
?HAS_NET: ignore include looser-rules.inc
include looser-rules.inc

?!HAS_NET:

Should be easy to implement, copy HAS_NET and negate the condition.

@rusty-snake rusty-snake added the enhancement New feature request label Sep 1, 2024
@QUser534
Copy link
Author

QUser534 commented Sep 1, 2024

But keep in mind that a looser profile might allow data stealing thought other means than direct networking.

I am not a security expert, so would you mind elaborating a malicious app could steal data if it's networking is disabled? Is there an easy way to break out of the network jail so it can upload data to a remote server?

Or would it require some type of user action, such as the program with no net-access modifies another program that it hopes will be run unsandboxed (such as modifying the .profile file), so then that program can upload the data?

There is one thing you have to consider. globals.local is usually included at the top (after foo.local). Meaning ?HAS_NET: will be false in 99% for the times you reach it in globals.local.

Hmmm, I see what you mean that for most people that would be the case. I modified it so firejail is always run with firejail --net=none, so in this case it would be aware of when to include each profile (even if the profile itself will disable net later that is okay).

Another way to do this that is perhaps more generalizable

  1. Make it so ?CONDITION can utilize include directive

  2. Make "conditions" passable via command line switches: --conditional="foo=1" --conditional="bar=1"

Then, allow these to be conditionals. For example:

?HAS_XXX: where XXX is the passed flag, in this case ?HAS_FOO and ?HAS_BAR

This resolves the issue of these "flags" not being known.

Then, users can pass a flag. This is especially important when wanting to use the "default" program on a new program.

For example:

firejail --conditional="net=0" --conditional="personal=0" --conditional="images=1"

Then the conditions the user created would include whatever was needed based on the flag data they passed.

What do you think about this idea?

@QUser534
Copy link
Author

QUser534 commented Sep 1, 2024

The concept of user-defineable conditionals seems useful even without "include" directive support. Should it be made into a separate feature enhancement for tracking?

In general, some conditionals could be useful even for standard profiles. For example: paranoid=1

Currently, many profiles enable net access for example to not break some very rarely used feature. So, basically net access was enabled for a feature 1% of people use like maybe a music program uses it to fetch lyrics on request as an example. Expanded use of conditions could allow profiles to be written to have more aggressive profiles when it's okay if the program works 99% instead of 100%.

@rusty-snake
Copy link
Collaborator

Or would it require some type of user action, such as the program with no net-access modifies another program that it hopes will be run unsandboxed (such as modifying the .profile file), so then that program can upload the data?

Yes, anything in that direction.

?HAS_XXX:

I somewhere suggested a ?HAS(...) but I can not find it anymore.

--conditional

If you already need to construct a firejail cmd, you can simply add the wanted includes. Conditionals an interesting for the firecfg case where you don't have a firejail cmd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request
Projects
None yet
Development

No branches or pull requests

2 participants