From 87206bc9db759dc142305860ea214b8f65f5444d Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Wed, 2 Sep 2026 19:07:23 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]?= =?UTF-8?q?=20=EB=B9=88=20=ED=98=B8=EC=8A=A4=ED=8A=B8=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=95=85=EC=9A=A9=ED=95=9C=20SSRF=20=EC=9A=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=B7=A8=EC=95=BD=EC=A0=90=20=ED=8C=A8=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/sentinel.md | 5 +++++ appguardrail_core/controlplane.py | 2 ++ scanner/cli/appguardrail.py | 2 ++ 3 files changed, 9 insertions(+) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index 1600d432..e8f5bc82 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -127,3 +127,8 @@ **Vulnerability:** The `/api/v1/webhook` POST endpoint in `appguardrail_core/controlplane.py` failed to validate the `url` property when accepting it into the database, leading to Stored SSRF risks. In addition, the core SSRF validation logic (`_is_safe_url`) in both the CLI and control-plane did not verify the input type (e.g. `isinstance(url, str)`). Passing non-string types (like integers) resulted in unhandled `AttributeError` exceptions inside `urllib.parse.urlparse`, which led to API 500 crashes on malicious JSON payloads. **Learning:** Network endpoints must explicitly validate the data type of user-provided configurations prior to execution or storage. Furthermore, webhooks configured by users should always be checked for SSRF when saved, as trusting them later assumes input has already been safely validated, bypassing downstream network guardrails. **Prevention:** Apply `_is_safe_url` checks directly upon ingestion (e.g., in `/api/v1/webhook`) and enforce type checks `if not isinstance(url, str): return False` prior to using library parsing functions like `urlparse`. Always return gracefully failing responses (like `400 Bad Request`) for unsafe URLs instead of allowing unhandled 500 server errors. + +## 2026-07-29 - [SSRF Bypass with Empty Hostnames] +**Vulnerability:** Server-Side Request Forgery (SSRF) bypass due to `urllib.parse.urlparse` returning an empty string for the hostname of malformed URLs (e.g., `http://` or `http://user@`). The subsequent host parsing logic resulted in an empty string being passed to `ipaddress.ip_address` and `socket.getaddrinfo`. These functions threw `ValueError` and `socket.gaierror` exceptions respectively, which were caught and ignored, leading the `_is_safe_url` function to incorrectly return `True`. +**Learning:** `urllib.parse.urlparse` can produce empty strings for hostnames on certain malformed URLs. When this empty string is processed by underlying networking and IP resolution libraries, the resulting exceptions might be handled in a way that accidentally bypasses the security check. +**Prevention:** Always explicitly check that a valid, non-empty hostname was successfully extracted by `urlparse` before attempting to validate the IP address or perform DNS resolution. Reject any URL that does not have a recognizable hostname. diff --git a/appguardrail_core/controlplane.py b/appguardrail_core/controlplane.py index 576b990f..3dfef099 100644 --- a/appguardrail_core/controlplane.py +++ b/appguardrail_core/controlplane.py @@ -236,6 +236,8 @@ def _is_safe_url(url: str) -> bool: return False host = (parsed.hostname or "").lower() + if not host: + return False raw = host.split("%", 1)[0].strip("[]") def is_bad_ip(ip) -> bool: diff --git a/scanner/cli/appguardrail.py b/scanner/cli/appguardrail.py index 0d853d64..2c9a0b43 100644 --- a/scanner/cli/appguardrail.py +++ b/scanner/cli/appguardrail.py @@ -1648,6 +1648,8 @@ def _is_safe_url(url: str) -> bool: return False host = (parsed.hostname or "").lower() + if not host: + return False raw = host.split("%", 1)[0].strip("[]") def is_bad_ip(ip) -> bool: From fa5c24bff57b535a007ce8196fa61e48e299d3e2 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Thu, 3 Sep 2026 08:48:33 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]?= =?UTF-8?q?=20=EB=B9=88=20=ED=98=B8=EC=8A=A4=ED=8A=B8=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=95=85=EC=9A=A9=ED=95=9C=20SSRF=20=EC=9A=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=B7=A8=EC=95=BD=EC=A0=90=20=ED=8C=A8=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 6109aa9c3dd44355db3b2af2668cd57437731a36 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Thu, 3 Sep 2026 18:01:47 +0900 Subject: [PATCH 3/4] test(ssrf): cover empty-host rejection --- tests/test_ssrf_protection.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_ssrf_protection.py b/tests/test_ssrf_protection.py index 0efe994b..90e4912b 100644 --- a/tests/test_ssrf_protection.py +++ b/tests/test_ssrf_protection.py @@ -11,6 +11,7 @@ def test_is_safe_url_public_domains(): assert _is_safe_url("http://google.com/") assert _is_safe_url("https://github.com/") + @pytest.mark.parametrize( "validator", [_is_safe_url, _cli_is_safe_url], @@ -25,6 +26,20 @@ def test_is_safe_url_invalid_types(validator, value): assert not validator(value) +@pytest.mark.parametrize( + "validator", + [_is_safe_url, _cli_is_safe_url], + ids=["controlplane", "cli"], +) +@pytest.mark.parametrize( + "url", + ["http://", "https://", "http://user@", "https://user@"], + ids=["http", "https", "http-userinfo", "https-userinfo"], +) +def test_is_safe_url_rejects_empty_hostname(validator, url): + assert not validator(url) + + def test_is_safe_url_ipv4_localhost(): assert not _is_safe_url("http://127.0.0.1/") assert not _is_safe_url("http://127.0.0.1:8080/") @@ -86,10 +101,7 @@ def test_push_findings_unsafe_url_handled_properly(monkeypatch, capsys): _push_findings("http://127.0.0.1/", []) captured = capsys.readouterr() - assert ( - "URL must be a public HTTPS URL" - in captured.err - ) + assert "URL must be a public HTTPS URL" in captured.err def test_safe_redirect_handler_rejects_internal_target(): From 30fbcdcd345a0de9a597ab1ce03e199068770838 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Thu, 3 Sep 2026 09:07:41 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]?= =?UTF-8?q?=20=EB=B9=88=20=ED=98=B8=EC=8A=A4=ED=8A=B8=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=95=85=EC=9A=A9=ED=95=9C=20SSRF=20=EC=9A=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=B7=A8=EC=95=BD=EC=A0=90=20=ED=8C=A8=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit