A user is able to remove his/her own Account Quota

Bug #1204110 reported by Joe Hakim Rahme
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Medium
Jon Snitow Solera

Bug Description

On a standard devstack account, I want to put an account quota on the user demo (tenant_id = c5ed34278aea420abf23896e805f05fc)

$admin_token and $demo_token are retrieved in advance.

# I use the ResellerAdmin account to set a Bytes Quota on the account
$ curl -i -X POST -H "X-Auth-Token: $admin_token" -H "X-Account-Meta-Quota-Bytes: 20" http://192.168.33.10:8080/v1/AUTH_c5ed34278aea420abf23896e805f05fc
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txdfb060b872614d7598553-0051ee84ef
Date: Tue, 23 Jul 2013 13:28:15 GMT

# I check that the quota has been set correctly
$ source demorc # get the demo credentials
$ swift stat
   Account: AUTH_c5ed34278aea420abf23896e805f05fc
Containers: 0
   Objects: 0
     Bytes: 0
Meta Quota-Bytes: 20
X-Timestamp: 1374586095.80445
X-Trans-Id: tx95f304c793a44d3197811-0051ee84f7
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes

# Using the a token of the demo (non-priviledged) account, I can remove the quota metadata on the demo account
$ curl -i -X POST -H "X-Auth-Token: $demo_token" -H "X-Remove-Account-Meta-Quota-Bytes: 20" http://192.168.33.10:8080/v1/AUTH_c5ed34278aea420abf23896e805f05fc
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: tx08ba4bea795b4f0a93596-0051ee853a
Date: Tue, 23 Jul 2013 13:29:30 GMT

# I check, the quota has been removed.
$ swift stat
   Account: AUTH_c5ed34278aea420abf23896e805f05fc
Containers: 0
   Objects: 0
     Bytes: 0
Accept-Ranges: bytes
X-Timestamp: 1374586095.80445
X-Trans-Id: txf66ff7b4a61840a4a30d6-0051ee8547
Content-Type: text/plain; charset=utf-8

Revision history for this message
Fabien Boucher (fabien-boucher) wrote :

Hi Joe,

It's seem there are two way to remove a metadata in swift by using X-Remove-* stuff or by using X-Account-Meta- stuff with an empty value. The reason there two way seems to be due to cURL.
Have a look here :
 http://docs.openstack.org/api/openstack-object-storage/1.0/content/delete-account-metadata.html

Please can you try to remove that meta with the common way (without X-Remove) and validate you cannot remove the meta as
regular user.

Beside of that, after looking at the middleware code, it seems the middleware does not handle X-Remove but it should.

Changed in swift:
status: New → Confirmed
Changed in swift:
assignee: nobody → Samuel Merritt (torgomatic)
Changed in swift:
importance: Undecided → Medium
Revision history for this message
Joe Hakim Rahme (rahmu) wrote :

Hi Fabien,

When I try to remove the metadata the "common" way, here's what happens:

$ curl -i -X POST -H "X-Auth-Token: $demo_token" -H "X-Account-Meta-Quota-Bytes: " http://192.168.33.10:8080/v1/AUTH_64b8fce216c749d8b167d1641ea46e1c
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txc8d9ddfb9ee44ac7af367-0051ef978a
Date: Wed, 24 Jul 2013 08:59:54 GMT

$ swift stat
   Account: AUTH_64b8fce216c749d8b167d1641ea46e1c
Containers: 0
   Objects: 0
     Bytes: 0
Meta Quota-Bytes: 40
X-Timestamp: 1374656119.71895
X-Trans-Id: tx96272785067b4929acd88-0051ef9790
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes

As you can see, it doesn't remove the metadata. However, it returns a 204 success code. Shouldn't return an error code like 403?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

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

Changed in swift:
assignee: Samuel Merritt (torgomatic) → Jon Snitow (otherjon)
status: Confirmed → In Progress
Revision history for this message
Jon Snitow Solera (otherjon) wrote :

Hi Joe,

cURL can't send empty headers without hackery. (See http://curl.haxx.se/mail/lib-2010-08/0171.html for more info.) If you run the above command with the "-v" flag, you'll see that it isn't actually sending what you want it to.

If you really want to test this with cURL, try something like the following:

curl -v -i -X POST -H "$(printf "X-Account-Meta-Quota-Bytes:\r\nX-Auth-Token: ")$demo_token" http://192.168.33.10:8080/v1/AUTH_64b8fce216c749d8b167d1641ea46e1c

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/38563
Committed: http://github.com/openstack/swift/commit/eb0629fc8210cc8bb4275d70408dddab67f667f7
Submitter: Jenkins
Branch: master

commit eb0629fc8210cc8bb4275d70408dddab67f667f7
Author: Jon Snitow <email address hidden>
Date: Wed Jul 24 15:58:55 2013 -0700

    Make sure users can't remove their account quotas

    Protect X-Remove-Account-Meta-Quota-Bytes same as X-Account-Meta-Quota-Bytes

    Fixes bug 1204110

    Change-Id: Ibac5b555f50b1fe41b2999c0d5776d90f9c9f3d1

Changed in swift:
status: In Progress → Fix Committed
Revision history for this message
Joe Hakim Rahme (rahmu) wrote :

Hey Jon,

Thanks for the tip about cURL, I did not know this.
Also, thanks for fixing this bug fast :)

Revision history for this message
Jon Snitow Solera (otherjon) wrote :

You're very welcome, Joe. Good luck!

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (feature/ec)

Fix proposed to branch: feature/ec
Review: https://review.openstack.org/39740

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (feature/ec)
Download full text (12.7 KiB)

Reviewed: https://review.openstack.org/39740
Committed: http://github.com/openstack/swift/commit/7a404cdea400e12d1ee8660c9f9477a87e419602
Submitter: Jenkins
Branch: feature/ec

commit 3035a93ed2c467fb248a77389274033ff540590c
Author: David Goetz <email address hidden>
Date: Tue Jul 30 11:52:23 2013 -0700

    Tell swift to figure out content type

    Be able to tell swift to figure out the content-type even if it is
    sent because old client code / curl has trouble sending blank
    content-type headers.

    Change-Id: Ie65ddf8993a19ea74e0b85a2ae56da84a617c19d

commit 47e34cf15eb652bd54d53b0cfb5238d04e4416d1
Author: TheSriram <email address hidden>
Date: Tue Jul 30 14:57:48 2013 -0400

    fix(gitignore) : ignore *.egg and *.egg-info

    Change-Id: I9496dab9e8f779a7ae045bb73b2cf8e77bda0d30

commit 22e7cbceed4730f93ee601a9955215e208e64295
Author: Alex Gaynor <email address hidden>
Date: Mon Jul 29 22:41:29 2013 -0700

    When iterating over a range of a file, always close it

    This is needed on Pythons without reference counting garbage collectors (e.g.
    PyPy).

    Change-Id: I1d06eb8fe08ee6eeb45caa47b653d6af0bb18267

commit 1e3ad44784bed7cbd8a8f367d633cc1d7c1d4172
Author: Peter Portante <email address hidden>
Date: Mon Jul 29 15:49:37 2013 -0400

    Merge object base module into diskfile.

    All of the module methods of the (now defunct) base module we really
    concerned with the on-disk layout which is what the DiskFile module is
    really about.

    Change-Id: I96e022c5f96e31537ced74139185851a2751701c
    Signed-off-by: Peter Portante <email address hidden>

commit eb99e8f84cf78c20e03f4a4fd92e243a22171b23
Author: Donagh McCabe <email address hidden>
Date: Tue Jul 23 15:10:09 2013 +0100

    Obscure the X-Auth-Token in proxy log

    The X-Auth-Token is sensitive data. If revealed to an unauthozied person,
    they can now make requests against an account until the token expires.

    This implementation maintains current behavior (i.e, the token
    is logged). Implementers can choose to set reveal_sensitive_prefix
    to (e.g.) 12 so only first 12 characters of the token are logged.
    Or, set to 0 to replace the token with "...".

    DocImpact

    Part of bug #1004114

    Change-Id: Iecefa843d8f9ef59b9dcf0860e7a4d0e186a6cb5

commit f9e73a0fe6da7da94955c40ffb50ddc6526c1466
Author: Pete Zaitcev <email address hidden>
Date: Mon Jul 29 19:12:10 2013 -0600

    Eliminate can_delete_db

    The method can_delete_db() appears to be not only unused, but has
    always been so. I verified this going back to Austin release. It is
    very strange that we never noticed it until now, but here it is.

    Change-Id: I4445c4b2c4721f880c9dbb1eac055c0601ae6372

commit be688c31562a5789fba678a0675eff1040308202
Author: Alex Gaynor <email address hidden>
Date: Fri Jul 19 20:07:27 2013 -0700

    Encode unicode from JSON before using it as a string.

    Right now this code fails when used with a JSON
    decoder that always produces unicode. This isn't
    usually the case with CPython, where simplejson
    is used most of the time, however w...

Thierry Carrez (ttx)
Changed in swift:
milestone: none → 1.9.1
status: Fix Committed → Fix Released
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.