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

whitelist globbing #216

Closed
curiosity-seeker opened this issue Jan 10, 2016 · 19 comments
Closed

whitelist globbing #216

curiosity-seeker opened this issue Jan 10, 2016 · 19 comments
Labels
enhancement New feature request

Comments

@curiosity-seeker
Copy link
Contributor

I was trying to rewrite/streamline my Firejail profile for LibreOffice. One rule which I tried was

whitelist ~/*.odt

but that doesn't work. It does work, though, in the form

whitelist ~/Example.odt

So it seems that placeholders are not supported. This would be a very useful enhancement in Firejail, indeed!

@netblue30
Copy link
Owner

I'll implement it, thanks for the idea!

@netblue30 netblue30 added the enhancement New feature request label Jan 10, 2016
@curiosity-seeker
Copy link
Contributor Author

Great - thank you very much in advance!

BTW, it would be nice if one could add several file suffixes in one line if possible. Something like

whitelist ~/*.odt, *.doc, *.docx

or

whitelist ~/*.odt | *.doc | *.docx

just to keep the profile more readable.

@netblue30
Copy link
Owner

I'll try that one also.

@ghost
Copy link

ghost commented Jan 31, 2016

Maybe in Bash syntax:
whitelist ~/*.{odt,doc,docx}

@netblue30 netblue30 changed the title Whitelisting file types whitelist globbing Mar 6, 2016
@netblue30
Copy link
Owner

several similar requests to follow:

@netblue30
Copy link
Owner

Also allow {}

@vn971
Copy link
Contributor

vn971 commented May 13, 2016

And []

@msva
Copy link
Contributor

msva commented Mar 5, 2017

Any updates on this?

@june128
Copy link
Contributor

june128 commented Oct 15, 2019

I'm currently working on enhancing the Thunderbird profile, so that Thunderbird can set itself as the default mail-program (and other things).
Thunderbird needs to modify the ~/.config/mimeapps.list-file for that. It does that by first creating a file named ~/.config/mimeapps.list.randomBit (where randomBit are 6 random characters [a-zA-Z0-9]) and then renaming this temporary file to ~/.config/mimeapps.list to make the change.

For that enhancement to be done, whitelist globbing would be needed (I think).

@rusty-snake
Copy link
Collaborator

rusty-snake commented Oct 16, 2019

@julianschacher #2874

EDIT:

whitelist globbing would be needed (I think)

To whitelist a file/dir it must be exists in the "normal" fs, thats why mkdir/mkfile is in the profiles.

rusty-snake pushed a commit that referenced this issue Oct 16, 2019
 - enable `seccomp`, but allow `chroot`
 - fix wusc. ==> comment it because of #216 it is broken
 - fix pdf export

[skip ci]
@june128
Copy link
Contributor

june128 commented Oct 17, 2019

@julianschacher #2874

@rusty-snake Thanks for the link! That's really an unfortunate issue.

@rusty-snake
Copy link
Collaborator

601df2f

@danielkrajnik
Copy link

danielkrajnik commented Dec 18, 2021

thanks, is it possible to use it resursively, that is all *.mp4 files in a directory and its subdirectories?

@rusty-snake
Copy link
Collaborator

man 7 glob:

Globbing is applied on each of the components of a pathname separately. A '/' in a pathname cannot be matched by a '?' or '*' wildcard

@danielkrajnik
Copy link

I see, so glibc doesn't provide a way to do it? Is there no other way to whitelist all files of specific format (e.g. *.mp4) in all subdirectories?

@rusty-snake
Copy link
Collaborator

If the (sub)directory structure isn't to deep, you can

whitelist ${HOME}/Downloads/*.mp4
whitelist ${HOME}/Downloads/*/*.mp4
whitelist ${HOME}/Downloads/*/*/*.mp4

@danielkrajnik
Copy link

Thanks, it is quite deep unfortunately (network mount). Ideally there would be a way to whitelist only certain files in such large directories rather than all of it.

@glitsj16
Copy link
Collaborator

@danielkrajnik Maybe you could write a shell script from where you pre-select the (*.mp4) files you want to whitelist and bind mount them in a specific location. That way you can blacklist your network mount and only whitelist the new mount path. Have you tried that yet?

@rusty-snake
Copy link
Collaborator

You can use find+xargs:

find ~/Videos -type f -name "*.mp4" -printf "--whitelist=%p\0" | xargs -0 -x -s 65536 /bin/sh -c 'firejail "$@" /usr/bin/totem'

I'm not sure if you can perform injections with this command (spaces in filenames work), but if this is an untrusted network mount, you should check this.

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

8 participants