Large X-Delete-At values cause object-server to 500

Bug #1860149 reported by Tim Burke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
High
Unassigned

Bug Description

So you can create objects with X-Delete-At timestamps in the far future:

$ curl -v http://saio:8090/v1/AUTH_test/c/o -X PUT -d 1234 -H x-delete-at:1579753284000
* Trying 127.0.1.1...
* TCP_NODELAY set
* Connected to saio (127.0.1.1) port 8090 (#0)
> PUT /v1/AUTH_test/c/o HTTP/1.1
> Host: saio:8090
> User-Agent: curl/7.58.0
> Accept: */*
> x-delete-at:1579753284000
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 4 out of 4 bytes
< HTTP/1.1 201 Created
< Content-Type: text/html; charset=UTF-8
< Content-Length: 0
< Etag: 81dc9bdb52d04dc20036dbd8313ed055
< Last-Modified: Fri, 17 Jan 2020 15:51:01 GMT
< X-Trans-Id: txb9beeddcc97142ed8f9d5-005e21d7e4
< X-Openstack-Request-Id: txb9beeddcc97142ed8f9d5-005e21d7e4
< Date: Fri, 17 Jan 2020 15:51:01 GMT
<
* Connection #0 to host saio left intact

This might happen if you've got a JavaScript client accidentally using milliseconds instead of seconds, for example. But then you can't GET the data!

$ curl -v http://saio:8090/v1/AUTH_test/c/o
* Trying 127.0.1.1...
* TCP_NODELAY set
* Connected to saio (127.0.1.1) port 8090 (#0)
> GET /v1/AUTH_test/c/o HTTP/1.1
> Host: saio:8090
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 503 Service Unavailable
< Content-Type: text/html; charset=UTF-8
< Content-Length: 118
< X-Trans-Id: txfa97de0ed5664597adf42-005e21d7f0
< X-Openstack-Request-Id: txfa97de0ed5664597adf42-005e21d7f0
< Date: Fri, 17 Jan 2020 15:51:13 GMT
<
* Connection #0 to host saio left intact
<html><h1>Service Unavailable</h1><p>The server is currently unavailable. Please try again at a later time.</p></html>

Object-server logs show

Jan 17 15:56:20 saio object-6040: ERROR __call__ error with GET /sdb4/312/AUTH_test/c/o :
Traceback (most recent call last):
  File "/vagrant/swift/swift/obj/server.py", line 1318, in __call__
    res = getattr(self, req.method)(req)
  File "/vagrant/swift/swift/common/utils.py", line 1985, in _timing_stats
    resp = func(ctrl, *args, **kwargs)
  File "/vagrant/swift/swift/obj/server.py", line 1087, in GET
    with disk_file.open(current_time=req_timestamp):
  File "/vagrant/swift/swift/obj/diskfile.py", line 2441, in open
    current_time=current_time, modernize=modernize, **file_info)
  File "/vagrant/swift/swift/obj/diskfile.py", line 2716, in _construct_from_data_file
    self._verify_data_file(data_file, fp, current_time)
  File "/vagrant/swift/swift/obj/diskfile.py", line 2583, in _verify_data_file
    if x_delete_at <= current_time and not self._open_expired:
  File "/usr/lib/python3.6/functools.py", line 112, in _ge_from_lt
    op_result = self.__lt__(other)
  File "/vagrant/swift/swift/common/utils.py", line 1369, in __lt__
    other = Timestamp(other)
  File "/vagrant/swift/swift/common/utils.py", line 1281, in __init__
    raise ValueError('timestamp too large')
ValueError: timestamp too large (txn: txbc10a8f255df48f78880c-005e21d924)

Similar things happen if you try to overwrite it with a PUT, update the expiration time with a POST, or even just DELETE the damn thing! (Exact tracebacks may vary, of course). Since we've seen this in the wild [0][1], the fix ought to have two parts:

1. Stop tripping exceptions when working with existing data that has a bad x-delete-at timestamp.

2. Stop allowing new PUTs and POSTs with such large x-delete-at timestamps; it almost certainly means there's a client bug.

[0] http://eavesdrop.openstack.org/irclogs/%23openstack-swift/%23openstack-swift.2020-01-16.log.html#t2020-01-16T07:17:22
[1] https://bugs.launchpad.net/swift/+bug/1821204

clayg (clay-gerrard)
Changed in swift:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.opendev.org/702950
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=57ca3570e911bd290ce0e44bdebaa4b5b4ceca13
Submitter: Zuul
Branch: master

commit 57ca3570e911bd290ce0e44bdebaa4b5b4ceca13
Author: Tim Burke <email address hidden>
Date: Thu Jan 16 10:07:33 2020 -0800

    Allow Timestamp comparisons against out-of-range values

    Prior to the related change, clients may have written down X-Delete-At headers
    that are outside of the Timestamp range, for example.

    Change-Id: Ib8ae7ebcbdb32e0aa58446bd1ef949e5e2f63e74
    Related-Change: I23666ec8a067d829eaf9bfe54bd086c320b3429e
    Related-Bug: 1821204
    Partial-Bug: 1860149

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

Reviewed: https://review.opendev.org/703155
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=7bba3ad04dec35a6d12f950c862846a7377df190
Submitter: Zuul
Branch: master

commit 7bba3ad04dec35a6d12f950c862846a7377df190
Author: Tim Burke <email address hidden>
Date: Fri Jan 17 08:32:34 2020 -0800

    Store normalized x-delete-at on PUT/POST

    Change-Id: I81e5d49623e884def8b5f6cbbf82f9b0d667d64a
    Closes-Bug: 1860149

Changed in swift:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.24.0

This issue was fixed in the openstack/swift 2.24.0 release.

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

Fix proposed to branch: feature/losf
Review: https://review.opendev.org/713632

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

Reviewed: https://review.opendev.org/713632
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=79bd2e59e5c15ee84814ec1c4f0893176ba79412
Submitter: Zuul
Branch: feature/losf

commit f2ffd900593db2829a39a073f0c033d82985c40f
Author: Clay Gerrard <email address hidden>
Date: Fri Feb 28 11:09:51 2020 -0600

    Apply limit to list versioned containers

    Change-Id: I28e062273d673c4f07cd3c5da088aa790b77a599
    Closes-Bug: #1863841

commit dc40779307095b8d0b2761b77b9cb2904ec721ae
Author: Clay Gerrard <email address hidden>
Date: Fri Feb 28 10:00:25 2020 -0600

    Use float consistently for proxy timeout settings

    Change-Id: I433c97df99193ec31c863038b9b6fd20bb3705b8

commit 55049beda5b9d7038a3604a87f28312d7702ccb2
Author: Tim Burke <email address hidden>
Date: Fri Feb 28 18:59:32 2020 -0800

    tests: Use timedelta to adjust dates, not string manipulations

    Change-Id: I8f65ccd7f2a79d5b877bfbef0274fb7857e21391

commit 3b65a5998cc921d2763cf1a9ec1e40b88491262d
Author: Tim Burke <email address hidden>
Date: Wed Jan 10 06:16:41 2018 +0000

    Fix up some Content-Type handling in account/container listings

    Update content type on 204 (not just 200) to properly handle HEAD
    requests from xml/txt listings.

    Add "Vary: Accept" header to listings, since otherwise, browsers may
    serve the wrong content type from cache (even though we *would have*
    sent the *right* type if it actually sent the request).

    Change-Id: Iaa333aaca36a8dc2df65d38ef2173e3a6e2000ee

commit ecca23eb806e11cf6517f0456483da7a065350a8
Author: Clay Gerrard <email address hidden>
Date: Fri Feb 21 15:33:21 2020 -0600

    Extend eventlet_debug logging to GreenAsyncPile

    Change-Id: Ibd9fe5c9a1e75b86eb7d540594d5cf516758e17e

commit 0fb3371484f1d0f629d0b0e33f6aafbff0e43ee9
Author: Sam Morrison <email address hidden>
Date: Tue Feb 18 10:17:50 2020 +1100

    Delay importing swiftclient until after monkey-patching

    Commit message below partly copied from nova:

    Eventlet monkey patching should be as early as possible

    We were seeing infinite recursion opening an ssl socket when running
    various combinations of python3, eventlet, and urllib3. It is not
    clear exactly what combination of versions are affected, but for
    background there is an example of this issue documented here:

    https://github.com/eventlet/eventlet/issues/371

    The immediate cause in swift's case was that we were calling
    eventlet.monkey_patch() after importing swiftclient (which imported
    requests, which finally imported urllib3).

    We only use the imported function in one place, however; hold off on
    importing until we actually need it to ensure that monkey patching
    happens first. Note that we *don't* want to monkey-patch at import time,
    as we've previously had bugs related to import-time side-effects.

    Change-Id: I24f4bcc3d62dc37fd9559032bfd25f5b15f98745
    Closes-bug: #1863680
    Related-bug: #1380815

commit a5afe767581d2cb97cf3690067e6d626c7682c2c
Author: Tim Burke <email address hidden>
Date: Wed Feb 19 10:09:49 2020 -0800

    Revert "Make roll...

tags: added: in-feature-losf
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.