Multiple vulnerabilities in Couchbase implementation of restore strategy

Bug #1349939 reported by Travis McPeak
262
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
Critical
Amrith Kumar
OpenStack Security Advisory
Won't Fix
Undecided
Unassigned

Bug Description

In the Couchbase implementation of restore in Trove, the following takes place:

1) pre-restore removes previous temp directory contents here: https://github.com/openstack/trove/blob/master/trove/guestagent/strategies/restore/couchbase_impl.py#L45

2) run_restore of the parent class is executed which puts together and runs the following command:
"openssl enc -d -aes-256-cbc -salt -pass pass:%s | gzip -d -c | sudo tar xPf -"

3) post-restore reads the secret key from an extracted file here:
https://github.com/openstack/trove/blob/master/trove/guestagent/strategies/restore/couchbase_impl.py#L54

4) a command is built from inputs from a JSON file in the directory created above starting here:
https://github.com/openstack/trove/blob/master/trove/guestagent/strategies/restore/couchbase_impl.py#L67

5) the command built in step 4 is executed

At no point in this process are permissions explicitly set. Presumably the files will be created based on the umask of the user that Trove runs as. This opens up the possibility for a couple of vulnerabilities:

1) malicious user can read the secret key if the default permissions are world readable (which is pretty common for many system's default umask)

2) malicious user can write arbitrary commands to be executed in step 5 with a shell injection vulnerability if the default permissions are world writeable. An example of this vulnerability would be something like setting bucket type in this line:

https://github.com/openstack/trove/blob/master/trove/guestagent/strategies/restore/couchbase_impl.py#L75

to something like "; rm -rf /etc". The possibilities for exploits are nearly endless as any command that the Trove user can run, the attacker can run.

Revision history for this message
Jeremy Stanley (fungi) wrote :

I've added an advisory task in an incomplete state pending feedback from the trove-coresec team, whom I've also just subscribed to this bug.

Changed in ossa:
status: New → Incomplete
Revision history for this message
Thierry Carrez (ttx) wrote :

It looks like this is a new feature in Juno. If that's confirmed to be the case, then we would just fix this in master before final release, and not issue an advisory about it.

Revision history for this message
Travis McPeak (travis-mcpeak) wrote :

Any word on this?

Revision history for this message
Nikhil Manchanda (slicknik) wrote :

This is a new feature in Juno, so I think doing what ttx says above makes sense. I'm going to follow up with the author of this feature to figure out a timeline for getting this fixed.

Revision history for this message
Jeremy Stanley (fungi) wrote :

In that case, we should also switch this bug to public security since there's no need to embargo a vulnerability only on the master branch, and for which we're not going to be publishing an advisory. If no one objects within the next couple days, I'll open up the bug report.

Thierry Carrez (ttx)
information type: Private Security → Public Security
Changed in ossa:
status: Incomplete → Won't Fix
Changed in trove:
milestone: none → juno-3
importance: Undecided → Critical
status: New → Confirmed
Amrith Kumar (amrith)
Changed in trove:
assignee: nobody → Amrith (amrith)
assignee: Amrith (amrith) → nobody
Revision history for this message
Amrith Kumar (amrith) wrote :

Per conversation with Nikhil

Changed in trove:
assignee: nobody → Amrith (amrith)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

Fix proposed to branch: master
Review: https://review.openstack.org/117174

Changed in trove:
status: Confirmed → In Progress
Revision history for this message
Amrith Kumar (amrith) wrote :

Found a problem with my proposed fix. This ain't likely to make it for j3.

Changed in trove:
milestone: juno-3 → next
Revision history for this message
Travis McPeak (travis-mcpeak) wrote :

I really think this needs to be fixed prior to release. This could really be a major security issue.

Revision history for this message
Nikhil Manchanda (slicknik) wrote :

Yes - it still has time to make it in for the Juno release between J3, and the RC.

Changed in trove:
milestone: next → juno-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to trove (master)

Reviewed: https://review.openstack.org/117174
Committed: https://git.openstack.org/cgit/openstack/trove/commit/?id=89e9a429f4b59801b9acca01bd7dabbeaf91269d
Submitter: Jenkins
Branch: master

commit 89e9a429f4b59801b9acca01bd7dabbeaf91269d
Author: Amrith Kumar <email address hidden>
Date: Wed Aug 27 06:06:21 2014 -0400

    Partially address concerns in Couchbase restore strategy

    This is a preliminary fix for community review. I expect to be making
    some changes as well.

    This change addresses some concerns about the Couchbase restore
    strategy. In particular, the concerns that are addressed include
    string injection in some execute calls, and issues around the
    permissions on the secret file used to store the password.

    This change set aims to fully address the issue around the password
    file but is a partial solution to the string injection
    problem. Additional changes are required to completely address
    that. Some additional bugs have also been raised to address issues
    related to other concerns discovered while fixing this bug. More to
    come.

    Change-Id: Icd8033caea4866f57f8cb4c5861d21797136ff90
    Partial-Bug: #1349939

Changed in trove:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in trove:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in trove:
milestone: juno-rc1 → 2014.2
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.