[GH-ISSUE #417] Cleanup environment variables #303

Closed
opened 2026-05-05 05:33:32 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @FedericoCeratto on GitHub (Apr 7, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/417

firejail should be able to unset environment variables on start, maybe with a way to whitelist some variables.

Steps to reproduce:
export HELLO=WORLD; firejail env

Originally created by @FedericoCeratto on GitHub (Apr 7, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/417 firejail should be able to unset environment variables on start, maybe with a way to whitelist some variables. Steps to reproduce: ` export HELLO=WORLD; firejail env `
gitea-mirror 2026-05-05 05:33:32 -06:00
Author
Owner

@netblue30 commented on GitHub (Apr 7, 2016):

I'll bring in whitelisting for env variables.

<!-- gh-comment-id:206827169 --> @netblue30 commented on GitHub (Apr 7, 2016): I'll bring in whitelisting for env variables.
Author
Owner

@netblue30 commented on GitHub (Jul 9, 2016):

I added --rmenv=name to remove unwanted variables

<!-- gh-comment-id:231542925 --> @netblue30 commented on GitHub (Jul 9, 2016): I added --rmenv=name to remove unwanted variables
Author
Owner

@ndbroadbent commented on GitHub (Apr 3, 2018):

I am running a web application where my secrets (e.g. API keys) are stored in environment variables. I wanted to use firejail to sandbox some shell commands, and they don't need access to any of these variables.

I figured out that you can clear all environment variables with env -i:

firejail env -i <command>

You can also whitelist certain variables if you specify them after env -i:

firejail env -i HOME="$HOME" LANG="$LANG" PATH="$PATH" <command>

(Just posting a comment here in case someone else sees this.)

<!-- gh-comment-id:378183192 --> @ndbroadbent commented on GitHub (Apr 3, 2018): I am running a web application where my secrets (e.g. API keys) are stored in environment variables. I wanted to use firejail to sandbox some shell commands, and they don't need access to any of these variables. I figured out that you can clear all environment variables with `env -i`: ``` firejail env -i <command> ``` You can also whitelist certain variables if you specify them after `env -i`: ``` firejail env -i HOME="$HOME" LANG="$LANG" PATH="$PATH" <command> ``` (Just posting a comment here in case someone else sees this.)
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#303
No description provided.