web: remove dns rebinding protection

this is not necessary anymore with token-based auth
This commit is contained in:
Maximilian Hils 2025-01-17 19:18:47 +01:00
parent 0bd573a599
commit 62693aff9a

View file

@ -708,15 +708,6 @@ class SaveOptions(RequestHandler):
pass
class DnsRebind(RequestHandler):
def get(self):
raise tornado.web.HTTPError(
403,
reason="To protect against DNS rebinding, mitmweb can only be accessed by IP at the moment. "
"(https://github.com/mitmproxy/mitmproxy/issues/3234)",
)
class State(RequestHandler):
# Separate method for testability.
@staticmethod
@ -815,7 +806,7 @@ class Application(tornado.web.Application):
self.master = master
auth_addon: WebAuth = master.addons.get("webauth")
super().__init__(
default_host="dns-rebind-protection",
handlers=handlers, # type: ignore # https://github.com/tornadoweb/tornado/pull/3455
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
xsrf_cookies=True,
@ -826,10 +817,3 @@ class Application(tornado.web.Application):
transforms=[GZipContentAndFlowFiles],
is_valid_password=auth_addon.is_valid_password,
)
self.add_handlers("dns-rebind-protection", [(r"/.*", DnsRebind)])
self.add_handlers(
# make mitmweb accessible by IP only to prevent DNS rebinding.
r"^(localhost|[0-9.]+|\[[0-9a-fA-F:]+\])$",
handlers, # type: ignore # https://github.com/tornadoweb/tornado/pull/3455
)