[GH-ISSUE #5683] One-shot copy single file into Firejail and let me run a parser against it #3062

Open
opened 2026-05-05 09:42:25 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @bf on GitHub (Feb 25, 2023).
Original GitHub issue: https://github.com/netblue30/firejail/issues/5683

When parsing unknown third-party PDF files, I'd like to run a PDF parser via firejail on a certain file so that:

  • the PDF parser cannot see any other files
  • the PDF parser cannot modify the file (e.g. it is copied or --read-only mounted)
  • no Firefail profiles need to be set up beforehand (--noprofile)
  • no other info should be visible inside the container about the host system
  • no root is needed to run the firejail (--bind is not an option)

Describe the solution you'd like

Something like firejail --noprofile --private --net=none --blacklist=/ --whitelist=/home/foo/data/files/X.pdf --read-only=/home/foo/data/files/X.pdf pdftotext /home/foo/data/files/X.pdf.

Currently this command fails because --private doesn't allow mounting /home/foo/data within the container.

Describe alternatives you've considered

I have tried using --put=/home/foo/data/files/X.pdf /home/foo/data/files/X.pdf but it seems it cannot be used with --noprofile because it always asks for pid or name to be given.

Additional context

I have chosen the pdftotext example because there is already a firejail profile for it: 8983cff10a/etc/profile-m-z/pdftotext.profile

From the profile it seems there is no possibility to limit access to only the file supplied via command line. In my case I know beforehand which exact file pdftotext should run on. I want make sure pdftotext does not see any other file in the filesystem.

Thank you

Originally created by @bf on GitHub (Feb 25, 2023). Original GitHub issue: https://github.com/netblue30/firejail/issues/5683 ### Is your feature request related to a problem? Please describe. When parsing unknown third-party PDF files, I'd like to run a PDF parser via firejail on a certain file so that: - the PDF parser cannot see any other files - the PDF parser cannot modify the file (e.g. it is copied or --read-only mounted) - no Firefail profiles need to be set up beforehand (--noprofile) - no other info should be visible inside the container about the host system - no root is needed to run the firejail (--bind is not an option) ### Describe the solution you'd like Something like `firejail --noprofile --private --net=none --blacklist=/ --whitelist=/home/foo/data/files/X.pdf --read-only=/home/foo/data/files/X.pdf pdftotext /home/foo/data/files/X.pdf`. Currently this command fails because --private doesn't allow mounting `/home/foo/data` within the container. ### Describe alternatives you've considered I have tried using `--put=/home/foo/data/files/X.pdf /home/foo/data/files/X.pdf` but it seems it cannot be used with `--noprofile` because it always asks for pid or name to be given. ### Additional context I have chosen the pdftotext example because there is already a firejail profile for it: https://github.com/netblue30/firejail/blob/8983cff10a5bc2d387804b09c30ba33cc89f1c54/etc/profile-m-z/pdftotext.profile From the profile it seems there is no possibility to limit access to only the file supplied via command line. In my case I know beforehand which exact file pdftotext should run on. I want make sure pdftotext does not see any other file in the filesystem. Thank you
Author
Owner

@bf commented on GitHub (Feb 25, 2023):

I've settled on something like this now. But its much too verbose to just make sure exactly one file is mounted as read-only for the program.

firejail --noprofile --caps.drop=all --nonewprivs --seccomp --net=none --nodbus --noinput --nogroups --noroot --private-dev --blacklist=/ --whitelist=/home/foo/data/asd.pdf --read-only=/home/foo/data/asd.pdf --private-cwd=/home/foo/data/ pdftotext asd.pdf -

<!-- gh-comment-id:1445139950 --> @bf commented on GitHub (Feb 25, 2023): I've settled on something like this now. But its much too verbose to just make sure exactly one file is mounted as read-only for the program. `firejail --noprofile --caps.drop=all --nonewprivs --seccomp --net=none --nodbus --noinput --nogroups --noroot --private-dev --blacklist=/ --whitelist=/home/foo/data/asd.pdf --read-only=/home/foo/data/asd.pdf --private-cwd=/home/foo/data/ pdftotext asd.pdf - `
Author
Owner

@smitsohu commented on GitHub (Feb 25, 2023):

Are you aware of the private-home option? It will not mount the file but copy it (as per the issue title), so there is no need to worry about read-only.

<!-- gh-comment-id:1445193798 --> @smitsohu commented on GitHub (Feb 25, 2023): Are you aware of the `private-home` option? It will not mount the file but copy it (as per the issue title), so there is no need to worry about `read-only`.
Author
Owner

@ghost commented on GitHub (Feb 25, 2023):

What exactly do you mean by parsing unknown third-party PDF files? Read them with a PDF viewer? Convert them to text like in your example with pdftotext? Inspect them with an app like qpdf (which can remove metadata too)?

IMO it would be much easier to create a custom profile that has all the Firejail options to create a very tight sandbox and shell-script in whatever PDF you want to 'parse'. Right now your solution misses important options like disable-mnt, nonewprivs, memory-deny-write-execute, private-bin, private-cache, private-dev, private-etc, private-opt, private-srv, private-tmp, restrict-namespaces, ... Adding all those on CLI quickly becomes a pain too.

<!-- gh-comment-id:1445211157 --> @ghost commented on GitHub (Feb 25, 2023): What exactly do you mean by `parsing` unknown third-party PDF files? Read them with a PDF viewer? Convert them to text like in your example with pdftotext? Inspect them with an app like [qpdf](https://qpdf.readthedocs.io/en/stable/cli.html#pdf-inspection) (which can remove metadata too)? IMO it would be much easier to create a custom profile that has all the Firejail options to create a very tight sandbox and shell-script in whatever PDF you want to 'parse'. Right now your solution misses important options like disable-mnt, nonewprivs, memory-deny-write-execute, private-bin, private-cache, private-dev, private-etc, private-opt, private-srv, private-tmp, restrict-namespaces, ... Adding all those on CLI quickly becomes a pain too.
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#3062
No description provided.