mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-11-20 07:00:25 +00:00
Fixes #6185
This commit is contained in:
parent
8b78b676c1
commit
5db2e62884
3 changed files with 29 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.11.88"
|
||||
VERSION = "1.10.11.89"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import re
|
|||
import time
|
||||
import types
|
||||
|
||||
from lib.core.common import checkSameHost
|
||||
from lib.core.common import getHostHeader
|
||||
from lib.core.common import getSafeExString
|
||||
from lib.core.common import logHTTPTraffic
|
||||
|
|
@ -180,6 +181,10 @@ class SmartRedirectHandler(_urllib.request.HTTPRedirectHandler):
|
|||
if conf.authRefresh and not authrefresh.sameOrigin(req.get_full_url(), redurl):
|
||||
req.headers = authrefresh.stripHeaders(req.headers)
|
||||
req.unredirected_hdrs = authrefresh.stripHeaders(req.unredirected_hdrs)
|
||||
|
||||
# Note: credentials are not to be forwarded to a different host (like browsers, curl and requests do) (#6185)
|
||||
if not checkSameHost(req.get_full_url(), redurl):
|
||||
req.headers = dict((key, value) for key, value in req.headers.items() if key.upper() not in (HTTP_HEADER.COOKIE.upper(), HTTP_HEADER.AUTHORIZATION.upper()))
|
||||
result = _urllib.request.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
|
||||
except _urllib.error.HTTPError as ex:
|
||||
result = error = ex
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class _Handler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
def do_POST(self):
|
||||
body = self.rfile.read(int(self.headers.get('Content-Length', '0')))
|
||||
token = self.headers.get('X-Auth-Token')
|
||||
self.server.credentials = (self.headers.get('Cookie'), self.headers.get('Authorization'))
|
||||
if self.path == '/refresh':
|
||||
self.server.refreshes += 1
|
||||
code, body = 200, b'{"token":"fresh"}'
|
||||
|
|
@ -270,6 +271,28 @@ class TestAuthRefresh(unittest.TestCase):
|
|||
other.server_close()
|
||||
thread.join(5)
|
||||
|
||||
def test_redirect_to_another_host_does_not_receive_credentials(self):
|
||||
# Note: user-supplied Cookie/Authorization must not leak to a different host (#6185), while the same host keeps them
|
||||
conf.authRefresh = None
|
||||
conf.httpHeaders = [('X-Auth-Token', 'fresh'), ('Cookie', 'session=secret'), ('Authorization', 'Bearer secret')]
|
||||
other = _Server(('127.0.0.1', 0), _Handler)
|
||||
other.requests, other.token, other.expired = [], 'fresh', 0
|
||||
other.lock = threading.Lock()
|
||||
other.syncExpired = False
|
||||
thread = threading.Thread(target=other.serve_forever)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
try:
|
||||
for host, expected in (('localhost', (None, None)), ('127.0.0.1', ('session=secret', 'Bearer secret'))):
|
||||
other.credentials = None
|
||||
self.server.redirect = 'http://%s:%d/landing' % (host, other.server_port)
|
||||
Connect.getPage(url=conf.url.replace('/test', '/redirect'))
|
||||
self.assertEqual(other.credentials, expected)
|
||||
finally:
|
||||
other.shutdown()
|
||||
other.server_close()
|
||||
thread.join(5)
|
||||
|
||||
def test_auth_refresh_latency_is_excluded_from_query_timing(self):
|
||||
import lib.request.connect as connect
|
||||
originalPage, originalDelta = Connect.getPage, connect.calculateDeltaSeconds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue