[GH-ISSUE #37] Ampersands are not handled correctly when passed to "bash -c" #19

Closed
opened 2026-05-05 04:45:35 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @blueyed on GitHub (Aug 20, 2015).
Original GitHub issue: https://github.com/netblue30/firejail/issues/37

The following should pass "http://example.com/?foo&bar" to firefox:

% firejail --debug /usr/bin/firefox http://example.com/\?foo\&bar
…
Starting /usr/bin/firefox http://example.com/?foo&bar 
execvp argument 0: /bin/bash
execvp argument 1: -c
execvp argument 2: /usr/bin/firefox http://example.com/?foo&bar 
Child process initialized
/bin/bash: bar: command not found

parent is shutting down, bye...
Originally created by @blueyed on GitHub (Aug 20, 2015). Original GitHub issue: https://github.com/netblue30/firejail/issues/37 The following should pass "http://example.com/?foo&bar" to firefox: ``` % firejail --debug /usr/bin/firefox http://example.com/\?foo\&bar … Starting /usr/bin/firefox http://example.com/?foo&bar execvp argument 0: /bin/bash execvp argument 1: -c execvp argument 2: /usr/bin/firefox http://example.com/?foo&bar Child process initialized /bin/bash: bar: command not found parent is shutting down, bye... ```
Author
Owner

@ghost commented on GitHub (Aug 20, 2015):

$ firejail --debug /usr/bin/firefox http://example.com/\\\?foo\\\&bar
...
Starting /usr/bin/firefox http://example.com/\?foo\&bar --new-instance 
execvp argument 0: /bin/bash
execvp argument 1: -c
execvp argument 2: /usr/bin/firefox http://example.com/\?foo\&bar --new-instance 
Child process initialized
<!-- gh-comment-id:133186645 --> @ghost commented on GitHub (Aug 20, 2015): ``` $ firejail --debug /usr/bin/firefox http://example.com/\\\?foo\\\&bar ... Starting /usr/bin/firefox http://example.com/\?foo\&bar --new-instance execvp argument 0: /bin/bash execvp argument 1: -c execvp argument 2: /usr/bin/firefox http://example.com/\?foo\&bar --new-instance Child process initialized ```
Author
Owner

@ghost commented on GitHub (Aug 20, 2015):

And if you don't like specifying three backslashes, you can do it with single backslashes (like your example) with this:

$ firejail --debug --shell=none /usr/bin/firefox firefox http://example.com/\?foo\&bar --new-instance
...
User namespace (noroot) installed
execvp argument 0: /usr/bin/firefox
execvp argument 1: firefox
execvp argument 2: http://example.com/?foo&bar
execvp argument 3: --new-instance
Child process initialized
<!-- gh-comment-id:133188722 --> @ghost commented on GitHub (Aug 20, 2015): And if you don't like specifying three backslashes, you can do it with single backslashes (like your example) with this: ``` $ firejail --debug --shell=none /usr/bin/firefox firefox http://example.com/\?foo\&bar --new-instance ... User namespace (noroot) installed execvp argument 0: /usr/bin/firefox execvp argument 1: firefox execvp argument 2: http://example.com/?foo&bar execvp argument 3: --new-instance Child process initialized ```
Author
Owner

@ghost commented on GitHub (Aug 21, 2015):

If you're using the latest version of firejail from Github, the command is now:

firejail --debug --shell=none /usr/bin/firefox http://example.com/\?foo\&bar
<!-- gh-comment-id:133379433 --> @ghost commented on GitHub (Aug 21, 2015): If you're using the latest version of firejail from Github, the command is now: ``` firejail --debug --shell=none /usr/bin/firefox http://example.com/\?foo\&bar ```
Author
Owner

@netblue30 commented on GitHub (Aug 21, 2015):

Yes, --shell=none is the solution. It was suggested by a an user trying to pass all kind of arguments form a shell script.

<!-- gh-comment-id:133404385 --> @netblue30 commented on GitHub (Aug 21, 2015): Yes, --shell=none is the solution. It was suggested by a an user trying to pass all kind of arguments form a shell script.
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#19
No description provided.