New user wrongly given access permissions to databases

Bug #1380880 reported by Martin Paulo
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
High
Petr Malik
OpenStack Security Advisory
Won't Fix
Undecided
Unassigned

Bug Description

Running the trove client against the Icehouse service I have encountered the following odd situation:

Create a datastore instance with, say two databases and a user:

$ trove create nextTestdb 1 --size 1 --databases DbOne DbTwo --users Bob:AVeryBadPassw0rd
+-------------------+--------------------------------------+
| Property | Value |
+-------------------+--------------------------------------+
| created | 2014-10-14T03:14:46 |
| datastore | MySQL |
| datastore_version | 5.5 |
| flavor | 1 |
| hostname | cqhuwzshhzz.db.cloud.unimelb.edu.au |
| id | 66d95162-6d60-499b-a797-72955acaf165 |
| name | nextTestdb |
| status | BUILD |
| updated | 2014-10-14T03:14:46 |
| volume | 1 |
+-------------------+--------------------------------------+

Then change the user Bob's name:
$ trove user-update-attributes 66d95162-6d60-499b-a797-72955acaf165 Bob --new_name VaderJakob

Just to show the ordinary permissions for a new user, create one called, say, Ben:
$ trove user-create 66d95162-6d60-499b-a797-72955acaf165 Ben ADifferentBadPassword

$ trove user-list 66d95162-6d60-499b-a797-72955acaf165
+------------+------+--------------+
| Name | Host | Databases |
+------------+------+--------------+
| Ben | % | |
| VaderJakob | % | DbOne, DbTwo |
+------------+------+--------------+

Now create a new user, named Bob:
$ trove user-create 66d95162-6d60-499b-a797-72955acaf165 Bob AnotherBadPassword

$ trove user-list 66d95162-6d60-499b-a797-72955acaf165
+------------+------+--------------+
| Name | Host | Databases |
+------------+------+--------------+
| Ben | % | |
| Bob | % | DbOne, DbTwo |
| VaderJakob | % | DbOne, DbTwo |
+------------+------+--------------+

And it can be seen that Bob has picked up access rights to the databases that the old user Bob used to have before he/she/it was renamed to VaderJakob. Which is, IMHO wrong. I did a search and didn't find a bug report along these lines.

Although a very minor hole, I've taken the liberty of checking the security vulnerability flag, as I think that a user accidentally finding themselves with access to a database that they weren't supposed to see might cause some pain in someone's life.

Revision history for this message
Grant Murphy (gmurphy) wrote :

Hi Martin,

Thanks for your bug report. I agree. It looks like this could have security implications. I've added an OSSA task to the bug and marked it incomplete pending confirmation from a member of the Trove coresec team.

Changed in ossa:
status: New → Incomplete
Revision history for this message
Nikhil Manchanda (slicknik) wrote :

Looks like it is a valid trove issue that I was able to reproduce. The crux of the issue is that when renaming a mysql db user, the grants that are associated with the previous username are preserved, so when the owner of the instance creates a new user with the old name — this new user inherits the grants that existed previously.

Imo it's more of a minor bug that's a surprising corner case only for mysql, and less of a concerning security issue for a few reasons:
- You need to have access to the (valid) trove creds that created the instance, and the first user in order to create the second user.
- The previously created user needs to be renamed to a different user name.
- The second user MUST have the same name as the previously created user.

Changed in trove:
status: New → Triaged
importance: Undecided → High
milestone: none → kilo-1
Revision history for this message
Tristan Cacqueray (tristan-cacqueray) wrote :

Considering the attack vector is quite unrealistic, we are willing to mark this bug public security and remove the OSSA task next wednesday (2014/10/29) unless someone raises a concern.

Revision history for this message
Martin Paulo (martin-paulo) wrote :

Yeah: I don't think that its a major bug either. Mind you, when I discussed it with the database people at work they were horrified...

Revision history for this message
Tristan Cacqueray (tristan-cacqueray) wrote :

Marking this bug public security and removing the OSSA task...

Changed in ossa:
status: Incomplete → Won't Fix
information type: Private Security → Public Security
Revision history for this message
Martin Paulo (martin-paulo) wrote :

Whilst I agree that it might not be a major security bug, I'm somewhat surprised that you've marked this as a "won't fix". MySQL is probably the database that is most likely to be deployed (does it also affect MariaDB?) Although unlikely, having new users potentially granted the rights of older users is one of those edge cases that might cause a lot of pain if triggered :(

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

The security advisory task is marked "won't fix" but the bug is still open against Trove and triaged as "high" priority.

Revision history for this message
Martin Paulo (martin-paulo) wrote : Re: [Bug 1380880] Re: New user wrongly given access permissions to databases

Ah: My misunderstanding. Apologies - and thanks for the clarification!

On 18 November 2014 11:23, Jeremy Stanley <email address hidden> wrote:

> The security advisory task is marked "won't fix" but the bug is still
> open against Trove and triaged as "high" priority.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1380880
>
> Title:
> New user wrongly given access permissions to databases
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ossa/+bug/1380880/+subscriptions
>

--
=================================================================

Martin Paulo, BSc.
Software Developer

Tel : +61-3-9434 2508 (Home)
Tel : 04 205 20339 (Mobile)
Site: http://www.thepaulofamily.net

"Nobody goes there any more. It's too crowded" - Yogi Berra.

Thierry Carrez (ttx)
information type: Public Security → Public
Revision history for this message
Sushil Kumar (sushil-kumar2) wrote :

same is the problem if u try to update the host for a give user and recreate the older combination of user and host.

Changed in trove:
assignee: nobody → Sushil Kumar (sushil-kumar2)
Revision history for this message
Sushil Kumar (sushil-kumar2) wrote :

the reason this problem is occurring is because in order to update a user's name or host we are updating the mysql.user table.
However for every database access there goes a record in mysq.db which is left behind when we are updating the user info in mysql.user.

So, basically the mysql.db also needs a cleanup while updating mysql.user for username or hostname.

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/137942

Changed in trove:
status: Triaged → In Progress
Changed in trove:
milestone: kilo-1 → kilo-2
Changed in trove:
milestone: kilo-2 → kilo-3
Changed in trove:
milestone: kilo-3 → kilo-rc1
Changed in trove:
milestone: kilo-rc1 → liberty-1
Changed in trove:
milestone: liberty-1 → liberty-2
Changed in trove:
milestone: liberty-2 → liberty-3
Changed in trove:
milestone: liberty-3 → ongoing
Revision history for this message
Amrith Kumar (amrith) wrote :

Sushil, do you have an update on a fix for this?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on trove (master)

Change abandoned by amrith (<email address hidden>) on branch: master
Review: https://review.openstack.org/137942
Reason: abandoning for inactivity. Please reinstate if you are still working on this and address earlier comments.

Revision history for this message
Martin Paulo (martin-paulo) wrote :

So a fix for a security hole (albeit a minor one) is being abandoned? Sad.

Amrith Kumar (amrith)
Changed in trove:
milestone: ongoing → newton-1
status: In Progress → Triaged
assignee: Sushil Kumar (sushil-kumar2) → nobody
Changed in trove:
assignee: nobody → Petr Malik (pmalik)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to trove (master)

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

commit dc7ccce006980cc3b6c908eb381088f61b0d8a5d
Author: Petr Malik <email address hidden>
Date: Mon Jul 18 16:23:23 2016 -0400

    Use proper queries to update user properties

    Bug 1380880 occurs when a user gets renamed
    and another one gets created wit its original name.

    It turns out that the new user wrongly inherits
    access rights of the original user.

    MySQL guest currently updates user properties by
    changing fields in the internal 'mysql' database.

    This patch set replaces the UPDATE with more generic
    SET PASSWORD and RENAME statements that should work on
    all MySQL versions.

    We no longer need to transfer privileges on a user name/host
    change since the RENAME statement does it for us under the covers.

    As an additional benefit this solution is also fully compatible
    with MySQL 5.7 which has changed the definition of the
    internal 'user' table and the current code no longer works.

    Closes-Bug: 1380880
    Change-Id: I37fdec77184715ed889d8ea6d446282c98903258

Changed in trove:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/trove 6.0.0.0b3

This issue was fixed in the openstack/trove 6.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

This issue was fixed in the openstack/trove 6.0.0.0b3 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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