Bug #4380

[security] users can read any file using image path

Added by Jan "Yenya" Kasprzak over 5 years ago. Updated about 5 years ago.

Status:ClosedStart date:03/22/2016
Priority:NormalDue date:
Assignee:Ruben S. Montero% Done:

0%

Category:Core & System
Target version:Release 5.0
Resolution:fixed Pull request:
Affected Versions:OpenNebula 4.6

Description

Unless I missed something, there is a security issue in Sunstone, and probably also in oned: I want users of a particular VDC to be able to create their own images. However, when I give them the CREATE permission on the particular datastore (CEPH-based in my case), their "user" view in Sunstone allows to create a new image with the "provide a path" radiobutton. Checking this radiobutton and entering any path (say, /etc/passwd) leads to a new image, which can then be mapped to the user's VM as a secondary disk, and read from this VM.

I was not able to use /var/lib/one/.ssh/id_dsa as a source file, so probably only world-readable files from the CEPH bridge servers can be abused this way.

Associated revisions

Revision 1bef231f
Added by Ruben S. Montero about 5 years ago

bug #4380: Secure defaults for SAFE_DIRS & RESTRICTED_DIRS.

History

#1 Updated by Ruben S. Montero over 5 years ago

There is a SAFE_DIRS variable to list the directories that can be included in the PATH when creating an image. Is SAFE_DIRS not working for you?

#2 Updated by Jan "Yenya" Kasprzak over 5 years ago

I had no SAFE_DIRS variable in the CEPH datastore config. I have added SAFE_DIRS=/none in the datastore view of Sunstone, but I am still able to create an /etc/passwd-based DATABLOCK image in Sunstone as an ordinary user.

Reading the documentation further, RESTRICTED_DIRS=/ is probably what I want. Maybe it should be the default?

#3 Updated by Jan "Yenya" Kasprzak over 5 years ago

Anyway, I forgot an important thing: thanks very much for the fast reply!

#4 Updated by Jan "Yenya" Kasprzak over 5 years ago

Jan "Yenya" Kasprzak wrote:

I had no SAFE_DIRS variable in the CEPH datastore config. I have added SAFE_DIRS=/none in the datastore view of Sunstone, but I am still able to create an /etc/passwd-based DATABLOCK image in Sunstone as an ordinary user.

Reading the documentation further, RESTRICTED_DIRS=/ is probably what I want. Maybe it should be the default?

With RESTRICTED_DIRS=/ the image upload does not work, as Sunstone probably uploads them to /var/tmp/, and then copying to Ceph DS fails when it cannot access /var/tmp. Does it have a clean solution, for example a dedicated file-upload directory, which can then be marked as safe?

#5 Updated by Carlo Daffara over 5 years ago

In NodeWeaver (that integrates OpenNebula) we have chosen the following approach:
- a dedicated /upload directory
- a Samba share that exposes that directory (so that you can upload large images in an efficient way)
- a small change in the sunstone frontend, so that the /upload/ path is prefixed in front of the path that is added by the user in the PATH field.

This prevents the user in adding other paths, or load images from unsafe places. We need to add a bit of safeguards as well (like escaping ..) but as an initial step works quite well.

#6 Updated by Carlos Martín about 5 years ago

  • Category changed from Sunstone to Drivers - Storage
  • Target version set to Release 5.0

#7 Updated by Javi Fontan about 5 years ago

To fix the upload problem you'll have to enable image imports from /var/tmp. Add to the datastore:

RESTRICTED_DIRS="/" 
SAFE_DIRS="/var/tmp" 

#8 Updated by Jan "Yenya" Kasprzak about 5 years ago

I think the configuration you mention should be the default. Anyway, it is more-or-less sufficient for deployments where there are no ordinary users on the oned/sunstone host. When it is not the case, ONe is full of insecure temporary file name security holes. For example, deployment scripts are created in /var/tmp/one by default. Maybe the default should be to use something like /var/lib/one/tmp, and set up the tmpwatch job to prune the old files periodically. In a similar way, there should be a separate directory to which Sunstone stores the file uploads, and (only) this directory should be in SAFE_DIRS by default.

What I want to say is that even though some hardening by configuration modifications is indeed possible, the secure configuration should be the default, not something a new ONe user has to discover.

#9 Updated by Ruben S. Montero about 5 years ago

  • Assignee set to Javi Fontan

#10 Updated by Ruben S. Montero about 5 years ago

  • Category changed from Drivers - Storage to Core & System
  • Assignee changed from Javi Fontan to Ruben S. Montero
We are going to add as default, if not specified:
  • RESTRICTED_DIRS="/"
  • SAFE_DIRS="/var/tmp"

#11 Updated by Ruben S. Montero about 5 years ago

  • Status changed from Pending to Closed
  • Resolution set to fixed
  • Affected Versions OpenNebula 4.6 added

Also available in: Atom PDF