Commit 6b9d07cde4

6b9d07cde421b86a14b379f975d84fb0fa705c61

parent: d3d7a60402

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-01 05:44 UTC

Reject non-http(s) TSA URLs in timestamp submit

Ref #1

Layout: unified · split

evidence_seal/timestamp.py +4
@@ -19,6 +19,7 @@ from __future__ import annotations
1919
2020import base64
2121import secrets
22import urllib.parse
2223import urllib.request
2324from datetime import timezone
2425from pathlib import Path
@@ -76,6 +77,9 @@ def submit(request_der: bytes, tsa_url: str, timeout: float = 30.0) -> bytes:
7677
7778 Network call — the caller is responsible for choosing a trusted TSA URL.
7879 """
80 scheme = urllib.parse.urlsplit(tsa_url).scheme.lower()
81 if scheme not in ("http", "https"):
82 raise ValueError(f"TSA URL must use http or https: {tsa_url}")
7983 req = urllib.request.Request(
8084 tsa_url,
8185 data=request_der,
tests/test_timestamp.py +8
@@ -17,6 +17,7 @@ from evidence_seal.timestamp import (
1717 apply_timestamp,
1818 build_request,
1919 parse_token,
20 submit,
2021 verify_timestamp,
2122)
2223
@@ -223,6 +224,13 @@ def test_verify_unstamped_manifest(manifest):
223224 assert "not timestamped" in message
224225
225226
227def test_submit_rejects_non_http_url(manifest, tmp_path):
228 target = tmp_path / "tsa.tsr"
229 target.write_bytes(b"")
230 with pytest.raises(ValueError, match="http or https"):
231 submit(build_request(manifest["id"]), target.as_uri())
232
233
226234# --- full CMS signature verification (needs cryptography) ---
227235
228236