[GH-ISSUE #6532] Assertion failed: env_get("LD_PRELOAD") == NULL (run_symlink.c: run_symlink: 81) #3297

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

Originally created by @elde-n on GitHub (Nov 5, 2024).
Original GitHub issue: https://github.com/netblue30/firejail/issues/6532

Description

Having LD_PRELOAD set while trying to run a symlinked firejail application in /usr/local/bin/ will cause a failed assertion

Steps to Reproduce

Steps to reproduce the behavior

  1. Run in bash as root ln -s /usr/bin/firejail /usr/local/bin/foo
  2. Run in bash LD_PRELOAD=1 foo
  3. See error Assertion failed: env_get("LD_PRELOAD") == NULL (run_symlink.c: run_symlink: 81)

Additional context

It would be nice to have an option to ignore/drop the LD_PRELOAD env instead of asserting

Originally created by @elde-n on GitHub (Nov 5, 2024). Original GitHub issue: https://github.com/netblue30/firejail/issues/6532 ### Description _Having LD_PRELOAD set while trying to run a symlinked firejail application in /usr/local/bin/ will cause a failed assertion_ ### Steps to Reproduce _Steps to reproduce the behavior_ 1. Run in bash as root `ln -s /usr/bin/firejail /usr/local/bin/foo` 2. Run in bash `LD_PRELOAD=1 foo` 3. See error `Assertion failed: env_get("LD_PRELOAD") == NULL (run_symlink.c: run_symlink: 81)` ### Additional context It would be nice to have an option to ignore/drop the LD_PRELOAD env instead of asserting
Author
Owner

@rusty-snake commented on GitHub (Nov 5, 2024):

Which firejail version? Is it reproducible with firejail-git?

<!-- gh-comment-id:2457901769 --> @rusty-snake commented on GitHub (Nov 5, 2024): Which firejail version? Is it reproducible with firejail-git?
Author
Owner

@elde-n commented on GitHub (Nov 5, 2024):

I'm on version 0.9.72, it's reproducible with latest commit, this is the line causing the assertion https://github.com/netblue30/firejail/blob/master/src/firejail/run_symlink.c#L81

<!-- gh-comment-id:2457916794 --> @elde-n commented on GitHub (Nov 5, 2024): I'm on version 0.9.72, it's reproducible with latest commit, this is the line causing the assertion `https://github.com/netblue30/firejail/blob/master/src/firejail/run_symlink.c#L81`
Author
Owner

@hlein commented on GitHub (Apr 10, 2026):

Trying some Gentoo emerges (compile and install packages via the package manager) with firejail-0.9.80 and most things enabled in /etc/firejail/firecfg.config, and building app-office/libreoffice-25.2.7.2-r1 fails with something extremely similar:

[5000+ lines of successful building]
...
[FNT] CustomTarget/extras/fonts/opens___.ttf
/usr/local/bin/fontforge -lang=ff -c 'Open($1); Generate($2)' /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/extras/source/truetype/symbol/OpenSymbol.sfd /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/workdir/CustomTarget/extras/fonts/opens___.ttf
...
/bin/cp  --no-dereference --force --preserve=timestamps /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/extras/source/gallery/bullets/Bullet08-Diamond-LightBlue.svg /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/instdir/share/gallery/bullets/Bullet08-Diamond-LightBlue.svg
run_symlink: LD_PRELOAD is: 'libsandbox.so'
fontforge: ../../src/firejail/run_symlink.c:81: run_symlink: Assertion `env_get("LD_PRELOAD") == NULL' failed.
make[1]: *** [/var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/extras/CustomTarget_opensymbol.mk:19: /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/workdir/CustomTarget/extras/fonts/opens___.ttf] Aborted
make[1]: *** Waiting for unfinished jobs....
...

I can see the value in being paranoid about LD_PRELOAD. In src/firejail/run_symlink.c:

        if (env_get("LD_PRELOAD") != NULL)
                fprintf(stderr, "run_symlink: LD_PRELOAD is: '%s'\n", env_get("LD_PRELOAD"));
        assert(env_get("LD_PRELOAD") == NULL);
        assert(secure_getenv("LD_PRELOAD") == NULL);
        execvp(a[0], a);

If I understand it, env_get is examining the original environment firejail was handed, and secure_getenv is consulting the sanitized env that has been constructed for the child we're about to launch.

But maybe instead of assert checks here, there should be a profile knob that allows passing LD_PRELOAD, making it configurable. Still default to no, but we could update the profiles of tools used in package-building with LD_PRELOADset to allow it. The alternative would be that for any tool where this crops up, have to disable firejail wrapping entirely, at least on Gentoo (and probably other source distros like Arch?).

<!-- gh-comment-id:4226528243 --> @hlein commented on GitHub (Apr 10, 2026): Trying some Gentoo emerges (compile and install packages via the package manager) with `firejail-0.9.80` and most things enabled in `/etc/firejail/firecfg.config`, and building `app-office/libreoffice-25.2.7.2-r1` fails with something extremely similar: ``` [5000+ lines of successful building] ... [FNT] CustomTarget/extras/fonts/opens___.ttf /usr/local/bin/fontforge -lang=ff -c 'Open($1); Generate($2)' /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/extras/source/truetype/symbol/OpenSymbol.sfd /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/workdir/CustomTarget/extras/fonts/opens___.ttf ... /bin/cp --no-dereference --force --preserve=timestamps /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/extras/source/gallery/bullets/Bullet08-Diamond-LightBlue.svg /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/instdir/share/gallery/bullets/Bullet08-Diamond-LightBlue.svg run_symlink: LD_PRELOAD is: 'libsandbox.so' fontforge: ../../src/firejail/run_symlink.c:81: run_symlink: Assertion `env_get("LD_PRELOAD") == NULL' failed. make[1]: *** [/var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/extras/CustomTarget_opensymbol.mk:19: /var/tmp/portage/app-office/libreoffice-25.2.7.2-r1/work/libreoffice-25.2.7.2/workdir/CustomTarget/extras/fonts/opens___.ttf] Aborted make[1]: *** Waiting for unfinished jobs.... ... ``` I can see the value in being paranoid about `LD_PRELOAD`. In `src/firejail/run_symlink.c`: ``` if (env_get("LD_PRELOAD") != NULL) fprintf(stderr, "run_symlink: LD_PRELOAD is: '%s'\n", env_get("LD_PRELOAD")); assert(env_get("LD_PRELOAD") == NULL); assert(secure_getenv("LD_PRELOAD") == NULL); execvp(a[0], a); ``` If I understand it, `env_get` is examining the original environment `firejail` was handed, and `secure_getenv` is consulting the sanitized env that has been constructed for the child we're about to launch. But maybe instead of assert checks here, there should be a profile knob that allows passing `LD_PRELOAD`, making it configurable. Still default to no, but we could update the profiles of tools used in package-building with `LD_PRELOAD`set to allow it. The alternative would be that for any tool where this crops up, have to disable `firejail` wrapping entirely, at least on Gentoo (and probably other source distros like Arch?).
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#3297
No description provided.