theupdateframework/tuf — pull request #93 by zhengyuyu (2013-08-20 07:56:34+00:00)
Title: Fix the slow retrieval attack issue

slow retrieval attack test:

(tuf)yuyuzheng@ubuntu:~/Documents/tuf/tuf/tests/system_tests$ python test_slow_retrieval_attack.py
Slow server is active on port: 37046 ...
Slow server terminated.

mode_1	Slow Retrieval Attack was Successful!

Slow server is active on port: 39963 ...
Slow server terminated.

mode_2	Slow Retrieval Attack was Successful!

Slow server is active on port: 34843 ...
TUF ...
Process Process-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "test_slow_retrieval_attack.py", line 60, in _download
urllib_tuf.urlretrieve(url, filename)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/interposition/__init__.py", line 124, in __urllib_urlretrieve
return updater.retrieve(url, filename=filename, reporthook=reporthook, data=data)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/interposition/updater.py", line 141, in retrieve
temporary_directory, temporary_filename = self.download_target(target_filepath)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/interposition/updater.py", line 57, in download_target
self.updater.refresh() # update TUF client repository metadata
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/client/updater.py", line 584, in refresh
STRICT_REQUIRED_LENGTH=False)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/client/updater.py", line 685, in _update_metadata
STRICT_REQUIRED_LENGTH=STRICT_REQUIRED_LENGTH)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/download.py", line 546, in download_url_to_tempfileobj
required_length)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/download.py", line 287, in _download_fixed_amount_of_data
data = connection.read(min(BLOCK_SIZE, required_length-total_downloaded))
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
File "/usr/lib/python2.7/httplib.py", line 561, in read
s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
timeout: timed out
Slow server terminated.

Slow server is active on port: 44190 ...
TUF ...
Process Process-4:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "test_slow_retrieval_attack.py", line 60, in _download
urllib_tuf.urlretrieve(url, filename)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/interposition/__init__.py", line 124, in __urllib_urlretrieve
return updater.retrieve(url, filename=filename, reporthook=reporthook, data=data)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/interposition/updater.py", line 141, in retrieve
temporary_directory, temporary_filename = self.download_target(target_filepath)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/interposition/updater.py", line 57, in download_target
self.updater.refresh() # update TUF client repository metadata
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/client/updater.py", line 584, in refresh
STRICT_REQUIRED_LENGTH=False)
File "/home/yuyuzheng/Documents/virtualenv-1.9.1/tuf/local/lib/python2.7/site-packages/tuf/client/updater.py", line 722, in _update_metadata
raise tuf.RepositoryError(message)
RepositoryError: Unable to update 'timestamp.txt'.
Slow server terminated.