Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@

# Changelog

## 1.0.3 (2026-11-24)

The follow-up to 1.0.2, in the Python SDK, from the review of its fix. The TypeScript SDK
parses URLs as a browser does (WHATWG `URL`) and does not change.

- **A host a browser reads as another IPv4 address is refused.** A browser reads a host whose
last label is a number as an IPv4 address, abbreviated, octal or hexadecimal:
`https://0x7f.1/` and `https://0177.0.0.1/` are 127.0.0.1, and `https://3.1.2/` is
3.1.0.2, while the SDK read the names as written. Such a host is now accepted only as a
canonical dotted-quad address (`browser_safe`), and an IP address has no subdomains:
`3.1.2` is not within `1.2` (`host_within`, used for device sign-in links, a company's
device page and Browser Control's company hosts).
- **The URLs 1.0.2 missed are checked too:** a company's logo (`PapSignIn.organization_logo`),
a UCP profile's endpoint (`UcpProfile.endpoint`), the platform profile (`ucp_agent_header`),
a Signature-Agent (sent and verified), a Session JWT's issuer before it is fetched, and the
entries of `protected_resources`. 1.0.2 said every accepted HTTPS URL was checked; with
these it is.

## 1.0.2 (2026-11-24)

A security fix in the Python SDK: a URL the SDK accepts is one a browser reads on the same
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/protocol/conformance-report.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Compatibility and conformance report

# Compatibility and conformance report

SDK version **1.0.2**, PAP profile **0.4** (as published 2026-11-10), Operations extension **v3**; the pairings run at protocol version **1.0**, the default (1.0 as published 2026-11-14); the suite also runs at 0.4 in every pairing. Each pairing runs every positive, negative and recovery fixture case over real TCP and TLS, the personal agent in one language and the reference company (Manzanita) in the other. A case is skipped, never passed, when a side lacks what it needs; the reason is listed below.
SDK version **1.0.3**, PAP profile **0.4** (as published 2026-11-10), Operations extension **v3**; the pairings run at protocol version **1.0**, the default (1.0 as published 2026-11-14); the suite also runs at 0.4 in every pairing. Each pairing runs every positive, negative and recovery fixture case over real TCP and TLS, the personal agent in one language and the reference company (Manzanita) in the other. A case is skipped, never passed, when a side lacks what it needs; the reason is listed below.

## Pairings

Expand Down
3 changes: 2 additions & 1 deletion docs/docs/releases/compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Compatibility

# Compatibility

This page is versioned with the SDK: it describes **SDK 1.0.2**.
This page is versioned with the SDK: it describes **SDK 1.0.3**.

## The PAP version implemented

Expand Down Expand Up @@ -35,6 +35,7 @@ profile, never picked up from an unattended fetch.

| SDK (PyPI and npm) | PAP profile | Specification revision | Operations | Breaking changes |
| --- | --- | --- | --- | --- |
| `1.0.3` | `0.4` | 2026-11-10 | v3 | none: the Python SDK refuses a host a browser reads as another IPv4 address (abbreviated, octal or hexadecimal, such as `0x7f.1` or `3.1.2`), an IP address has no subdomains, and a company's logo, a UCP endpoint, a Signature-Agent and a Session's issuer are checked as every HTTPS URL is |
| `1.0.2` | `0.4` | 2026-11-10 | v3 | none: the Python SDK refuses a URL a browser reads on another host (a backslash, whitespace or a control character anywhere, an authority with anything but RFC 3986 ASCII characters), so a device sign-in link is shown only on the host it was checked on (§4.3) |
| `1.0.1` | `0.4` | 2026-11-10 | v3 | none: the four case decks (`./decks`) and the docs describe the cases at Poppy 1.0 as published, with Operations version 3, no longer draft 0.3 |
| `1.0.0` | `0.4` | 2026-11-10 | v3 | none: the SDK's version follows Poppy's own, 1.0; the code is 0.37.5's |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datalayer/personal-agent-protocol",
"version": "1.0.2",
"version": "1.0.3",
"description": "TypeScript SDK for Personal Agent Protocol 0.4 (2026-11-10) and its Operations extension v3",
"repository": {
"type": "git",
Expand Down
107 changes: 107 additions & 0 deletions personal_agent_protocol/__tests__/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,110 @@ def test_every_https_check_of_the_sdk_asks_it_first() -> None:
}
for name, check in places.items():
assert check in (PACKAGE / name).read_text(), name


# --- the review of 1.0.2 -------------------------------------------------------------


@pytest.mark.parametrize(
"url",
[
"https://0x7f.1/device", # hexadecimal and abbreviated: 127.0.0.1 to a browser
"https://0177.0.0.1/device", # octal: 127.0.0.1
"https://127.1/device", # abbreviated: 127.0.0.1
"https://3.1.2/device", # abbreviated: 3.1.0.2
"https://2130706433/device", # one number: 127.0.0.1
"https://1.2.3.04/device", # a leading zero: octal to a browser
"https://1.2.3.256/device", # out of range: refused by a browser
"https://v.example.0x1/device", # a name that ends in a hexadecimal number
"https://v.example.42/device", # a name that ends in a number
"https://1.2.3.4./device", # a trailing dot
],
)
def test_a_host_a_browser_reads_as_another_ipv4_address_is_refused(url: str) -> None:
assert not browser_safe(url)


@pytest.mark.parametrize(
"url",
[
"https://127.0.0.1/device",
"https://10.0.0.1:8443/device",
"https://0.0.0.0/",
"https://v.example42/device", # a name whose last label is not all digits
"https://0xv.example/device", # not hexadecimal
],
)
def test_a_canonical_ipv4_address_or_a_name_is_read_alike(url: str) -> None:
assert browser_safe(url)


def test_an_ip_address_has_no_subdomains() -> None:
from personal_agent_protocol.urls import host_within

assert host_within("login.m.example", "m.example")
assert host_within("m.example", "m.example")
assert not host_within("evilm.example", "m.example")
# `3.1.2` read as a subdomain of `1.2` (a browser opens 3.1.0.2), and an address within another.
assert not host_within("3.1.2", "1.2")
assert not host_within("10.1.2.3", "1.2.3")
assert host_within("10.1.2.3", "10.1.2.3")
assert not host_within("a.2001:db8::1", "2001:db8::1")
assert not host_within("", "m.example")


def test_a_company_logo_is_checked_as_every_https_url() -> None:
from personal_agent_protocol.ui import PapSignIn

def sign_in(logo: str) -> PapSignIn:
return PapSignIn(
mode="device",
open="https://login.m.example/device",
code="WDJB-MJHT",
organization_name="M",
organization_domain="m.example",
organization_logo=logo,
)

assert sign_in("https://m.example/logo.svg").organization_logo == "https://m.example/logo.svg"
for logo in ("https://v.example\\.m.example/../logo.svg", "https://0x7f.1/logo.svg"):
with pytest.raises(ValueError):
sign_in(logo)


def test_a_ucp_endpoint_is_checked_as_every_https_url() -> None:
from personal_agent_protocol.ucp import UcpProfile

def endpoint(url: str) -> str | None:
return UcpProfile.model_validate(
{
"version": "2026-04-08",
"services": {"dev.ucp.shopping": [{"transport": "rest", "endpoint": url}]},
}
).endpoint()

assert endpoint("https://shop.m.example/ucp") == "https://shop.m.example/ucp"
assert endpoint("https://v.example\\.m.example/../ucp") is None
assert endpoint("https://0177.0.0.1/ucp") is None


def test_every_https_prefix_check_also_asks_it() -> None:
"""Where a URL is accepted on its `https://` prefix alone, `browser_safe` is asked too."""

places = {
"ucp.py": ["and browser_safe(endpoint)", "not browser_safe(platform_profile)"],
"operator_signatures.py": [
"not browser_safe(signature_agent)",
"if not browser_safe(agent):",
],
"company/verify.py": ["not browser_safe(issuer)"],
"models.py": ["not browser_safe(entry)"],
"ui.py": ["not browser_safe(value) or urlsplit(value).scheme"],
"device.py": ["return host_within(host, domain)"],
"browser_control.py": ["return host_within(host, domain)"],
"company/service.py": ["if not host_within(host, own):"],
}
for name, checks in places.items():
text = (PACKAGE / name).read_text()
for check in checks:
assert check in text, (name, check)
2 changes: 1 addition & 1 deletion personal_agent_protocol/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

"""Personal Agent Protocol."""

__version__ = "1.0.2"
__version__ = "1.0.3"
3 changes: 2 additions & 1 deletion personal_agent_protocol/browser_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from .errors import PersonalAgentProtocolError
from .models import DiscoveryDocument, domain_host
from .sessions import PapSession
from .urls import host_within

BROWSER_CONTROL_EXTENSION = "browser-control"
#: The version this SDK implements (Browser Control 3).
Expand Down Expand Up @@ -267,7 +268,7 @@ def on_company_host(host: str, organization_domain: str) -> bool:
that get `navigator.poppy` (Browser Control 6)."""

host, domain = host.lower().rstrip("."), domain_host(organization_domain)
return host == domain or host.endswith(f".{domain}")
return host_within(host, domain)


def controller_script(organization_domain: str, channel: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion personal_agent_protocol/company/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def build_company(
reactor.register_plugin(
PluginManifest(
name="personal-agent-protocol.company",
version="1.0.2",
version="1.0.3",
contribution_points=[
COMPANY_STORES.id,
COMPANY_ACCOUNTS.id,
Expand Down
4 changes: 2 additions & 2 deletions personal_agent_protocol/company/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
UCP_SHOPPING,
UCP_VERSION,
)
from ..urls import browser_safe
from ..urls import browser_safe, host_within
from .points import (
CLIENT_POLICIES,
CLIENT_RESOLVERS,
Expand Down Expand Up @@ -785,7 +785,7 @@ def __post_init__(self) -> None: # noqa: C901 - one branch per protocol rule
if self.device_page is not None:
host = (urlsplit(self.device_page).hostname or "").lower()
own = domain_host(self.domain)
if not (host == own or host.endswith(f".{own}")):
if not host_within(host, own):
# A personal agent shows the link only on the issuer's host or
# `organization.domain`, or a subdomain of either (§4.3). The issuer is on
# `domain`, and an agent that found the company at an alias knows only that
Expand Down
3 changes: 2 additions & 1 deletion personal_agent_protocol/company/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
)
from ..errors import ProofError, SessionError
from ..models import ClientMetadata, JsonWebKeySet
from ..urls import browser_safe
from .points import ReplayCache

#: Companies accept client assertions and delegations signed with these (§4.1, §5.2): both
Expand Down Expand Up @@ -248,7 +249,7 @@ def unverified_session_issuer(compact: str) -> str:
except jwt.PyJWTError as exc:
raise _refused("The Session header is not a JWT") from exc
issuer = claims.get("iss")
if not isinstance(issuer, str) or not issuer.startswith("https://"):
if not isinstance(issuer, str) or not issuer.startswith("https://") or not browser_safe(issuer):
raise _refused("The Session JWT names no personal agent")
return issuer

Expand Down
3 changes: 2 additions & 1 deletion personal_agent_protocol/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
proves_with_dpop,
)
from .telemetry import sign_in_method, sign_in_result, signed_in_as, traced
from .urls import host_within

DEVICE_CODE_GRANT = "urn:ietf:params:oauth:grant-type:device_code"

Expand All @@ -69,7 +70,7 @@ def _host(url: str) -> str:


def _within(host: str, domain: str) -> bool:
return host == domain or host.endswith(f".{domain}")
return host_within(host, domain)


def verification_host_allowed(url: str, *, issuer: str, domain: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion personal_agent_protocol/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def lists_resource(self, domain: str) -> bool:

wanted = domain.lower().rstrip(".")
for entry in self.protected_resources:
if not entry.startswith("https://"):
if not entry.startswith("https://") or not browser_safe(entry):
continue
host = entry[len("https://") :]
if host and not any(char in host for char in "/?#@") and host.lower() == wanted:
Expand Down
10 changes: 9 additions & 1 deletion personal_agent_protocol/operator_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .crypto import jwk_thumbprint
from .errors import PersonalAgentProtocolError, ProofError
from .reactor import OperatorSignature, OperatorSignatureRequest
from .urls import browser_safe

#: The headers of a signed request (RFC 9421 §4; Web Bot Auth §5.2.5).
SIGNATURE_HEADER = "Signature"
Expand Down Expand Up @@ -204,7 +205,11 @@ async def sign_operator_request(
`poppy-session` when the request has one.
"""

if not signature_agent.startswith("https://") or re.search(r'["\\\s]', signature_agent):
if (
not signature_agent.startswith("https://")
or not browser_safe(signature_agent)
or re.search(r'["\\\s]', signature_agent)
):
raise ValueError("a Signature-Agent is an HTTPS URL")
label = OPERATOR_SIGNATURE_LABEL
authorization = request.authorization
Expand Down Expand Up @@ -519,6 +524,9 @@ async def _checked(
keyid = cast(str, offered.parameters["keyid"])
if offered.parameters.get("alg", OPERATOR_SIGNATURE_ALGORITHM) != OPERATOR_SIGNATURE_ALGORITHM:
return OperatorVerdict("unverified")
if not browser_safe(agent):
# A Signature-Agent a browser reads on another host names no key: it decides nothing.
return OperatorVerdict("unverified")
try:
published = await keys(agent, keyid)
except PersonalAgentProtocolError:
Expand Down
2 changes: 1 addition & 1 deletion personal_agent_protocol/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ def build_pap_reactor(
platform.register_plugin(
PluginManifest(
name="personal-agent-protocol.core",
version="1.0.2",
version="1.0.3",
contribution_points=[
DISCOVERY_TRANSPORTS.id,
URL_SAFETY_POLICIES.id,
Expand Down
8 changes: 6 additions & 2 deletions personal_agent_protocol/ucp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .refusals import challenge_parameters
from .sessions import AccessToken, PapSession
from .transport import SessionHttpClient, session_error
from .urls import browser_safe

#: The extension's name and version in `extensions` and `Poppy-Extensions` (UCP extension 2).
UCP_EXTENSION = "ucp"
Expand Down Expand Up @@ -78,6 +79,7 @@ def endpoint(self, service: str = UCP_SHOPPING, transport: str = "rest") -> str
entry.get("transport") == transport
and isinstance(endpoint, str)
and endpoint.startswith("https://")
and browser_safe(endpoint)
):
return endpoint
return None
Expand Down Expand Up @@ -123,8 +125,10 @@ def ucp_agent_header(platform_profile: str) -> str:
URL would let Companies match a User across Companies (UCP extension 3, 10).
"""

if not platform_profile.startswith("https://") or any(
char in platform_profile for char in '"\\ \t\r\n'
if (
not platform_profile.startswith("https://")
or not browser_safe(platform_profile)
or any(char in platform_profile for char in '"\\ \t\r\n')
):
raise ValueError("The platform profile is an HTTPS URL")
return f'profile="{platform_profile}"'
Expand Down
2 changes: 1 addition & 1 deletion personal_agent_protocol/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _needs(cls, value: list[str]) -> list[str]:
@field_validator("organization_logo")
@classmethod
def _logo(cls, value: str | None) -> str | None:
if value is not None and urlsplit(value).scheme != "https":
if value is not None and (not browser_safe(value) or urlsplit(value).scheme != "https"):
raise ValueError("a company's logo is an HTTPS URL")
return value

Expand Down
Loading
Loading