---
title: "url_guard.validate_fetch_url does not decode…"
description: "GHSA-5rmp-p632-6prf: url_guard.validate_fetch_url does not decode a percent-encoded host, so metadata and private… Affected and fixed versions of qwed."
url: https://qwedai.tech/security/advisories/ghsa-5rmp-p632-6prf
---

[Security](https://qwedai.tech/security) · [Advisories](https://qwedai.tech/security/advisories) · GHSA-5rmp-p632-6prf

# url\_guard.validate\_fetch\_url does not decode a percent-encoded host, so metadata and private addresses written with %XX escapes are fetched

low Fixed in 13.0.0 GHSA-5rmp-p632-6prf · Published 2 December 2026

## Impact

`validate_fetch_url` refuses a fetch URL whose host is a cloud metadata, loopback, link-local or private address. It reads `urlparse(url).hostname`, which keeps percent-escapes, so an address written with them is not recognised, while `urllib.request` and requests decode the host before they connect.

Checked on `main` @ `ec50c2ac`:

| URL | `validate_fetch_url` | Host `urllib.request` connects to |
| --- | --- | --- |
| `http://169.254.169.254/latest/meta-data/` (control) | refused |  |
| `http://%31%36%39.254.169.254/latest/meta-data/` | **allowed** | `169.254.169.254` |
| `http://%31%32%37.0.0.1:6379/` | **allowed** | `127.0.0.1:6379` |
| `http://%5b::ffff:a9fe:a9fe%5d/` | **allowed** | `[::ffff:a9fe:a9fe]` (169.254.169.254) |

requests decodes the host the same way: `requests.Request("POST", "http://%31%36%39.254.169.254/latest/meta-data/").prepare().url` is `http://169.254.169.254/latest/meta-data/`.

Callers:

-   provider import (`src/qwed_new/providers/config_manager.py:155`), which checks the import URL and every redirect hop. The import URL is set by the operator, but a redirect is set by the server it fetches from, so an `https` provider URL whose server redirects to an escaped private address passes the check. The import requires `https` on every hop, which limits this to services that speak TLS.
-   `SLACK_WEBHOOK_URL` (`src/qwed_new/core/alerting.py:50`), posted with requests. It is set by the operator.

## Affected

`qwed` (PyPI) 7.2.2 through 12.0.0: `qwed_new.core.url_guard`, since it was added.

## Reproduction

```python
import urllib.request
from qwed_new.core.url_guard import validate_fetch_url

url = "http://%31%36%39.254.169.254/latest/meta-data/"
validate_fetch_url(url)                 # returns url: allowed
print(urllib.request.Request(url).host)  # 169.254.169.254
```

## Details

`validate_fetch_url` (`src/qwed_new/core/url_guard.py:120`) takes `host = (parsed.hostname or "").strip("[]")` (`:145`) and passes it to `_literal_ip`, which does not decode `%XX`, so the host is not read as an address and the URL is returned unchanged. `urllib.request.Request` unquotes the host, and requests requotes the URL, which decodes unreserved escapes in the host.

## Patches

Fixed in [13.0.0](https://github.com/QWED-AI/qwed-verification/releases/tag/v13.0.0). Upgrade with `pip install -U "qwed>=13.0.0"`. `validate_fetch_url` refuses a URL unless its authority is userinfo of RFC 3986 characters, then a host of ASCII letters, digits, dots, hyphens and underscores or a bracketed IPv6 address, then a numeric port, and refuses whitespace and control characters anywhere in it. The check runs before the address check, whatever `allow_local` and `require_https` say, and on every redirect. It also closes a backslash before the `@` (`https://169.254.169.254\@evil.example/`), which `urlparse` and requests read as different hosts. Write a host that is not ASCII in its `xn--` form.

## Workarounds

Import provider configuration only from a server you control, and set `SLACK_WEBHOOK_URL` to the Slack hostname as written.

Advisory page: [https://qwedai.tech/security/advisories/ghsa-5rmp-p632-6prf](https://qwedai.tech/security/advisories/ghsa-5rmp-p632-6prf)

[All advisories](https://qwedai.tech/security/advisories)

Affected and fixed

qwed

Affected \>= 7.2.2, <= 12.0.0 Fixed in 13.0.0

Weakness

CWE-918 Server-Side Request Forgery

[View on GitHub](https://github.com/QWED-AI/qwed-verification/security/advisories/GHSA-5rmp-p632-6prf)
