Skip to content

Commit 1083b40

Browse files
committed
move the zero-padded ip to its own separate test case
1 parent 9a8ffba commit 1083b40

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

aikido_zen/sinks/tests/requests_and_urllib3_test.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import aikido_zen.sinks.http_client
1010
import requests
1111
import urllib3
12+
from requests import ConnectTimeout
1213

1314

1415
@pytest.fixture(autouse=True)
@@ -95,8 +96,6 @@ def ssrf_check(monkeypatch, url, requests_only=False):
9596
"http://0x7f.0x0.0x0.0x1:8081/",
9697
# 127.0.0.1 ipv6 mapped
9798
"http://[::ffff:127.0.0.1]:8081",
98-
# 127.0.0.1 with 0 padding
99-
"http://0127.0.0.01:5000",
10099
],
101100
)
102101
def test_ssrf_1(monkeypatch, url):
@@ -193,3 +192,15 @@ def test_srrf_with_request_to_itself_urllib3(monkeypatch):
193192
def test_ssrf_encoded_chars(monkeypatch):
194193
# This type of URL only works for requests
195194
ssrf_check(monkeypatch, "http://127%2E0%2E0%2E1:4000", requests_only=True)
195+
196+
197+
def test_zero_padded_ip(monkeypatch):
198+
monkeypatch.setenv("AIKIDO_BLOCK", "1")
199+
reset_comms()
200+
201+
url = "http://0127.0.0.01:5000"
202+
set_context_and_lifecycle(url)
203+
# Can raise both errors : either connection times out -> 0127.0.0.01 not supported by platform
204+
# or it raises ssrf bug -> 0127.0.0.01 supported by platform
205+
with pytest.raises((AikidoSSRF, ConnectTimeout)):
206+
requests.get(url)

0 commit comments

Comments
 (0)