From 7f89b83844e7c80471d787f78d8dfb33a5fc53a9 Mon Sep 17 00:00:00 2001 From: owizdom Date: Fri, 27 Nov 2026 15:27:41 +0200 Subject: [PATCH 1/2] Treat a deeply nested log response as malformed in the monitor's reader json.loads raises RecursionError on a response nested beyond the decoder's depth, and LogMonitor.run catches only OSError, ValueError, TypeError and KeyError. A log that answered with 65,536 bytes of "[" stopped the monitor before it raised any coverage alert. The reader now raises ValueError for it, as for other malformed responses. --- CHANGELOG.md | 1 + log/reader.py | 2 ++ tests/test_log_monitor.py | 49 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e40ee49..aacffe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- The independent log monitor treats a public log response nested too deeply to decode as malformed. It keeps running and raises the coverage alert for overdue promises instead of stopping without one. [Independent monitor](log/README.md#independent-monitor) - Rename the project to Akashi. The repository moved to `Lucid-Computing/akashi`. The CLI is now `akashi`, the wheel `akashi-verify`, the environment prefix `AKASHI_`, and the service units and paths `akashi*`. Protocol domains, the `x-akashi-receipt` header, `/.well-known/akashi.json` and the `akashi-pickup/1` envelope replace their `vig` forms. Receipts, pickups and verdicts made under the old domains no longer verify, and the reference vectors were regenerated. [Data model](docs/spec/03-data-model.md) - Document the recorded Maverick request and both offline CLI verdicts with exact measurement boundaries and machine-readable evidence. [Recorded demo](docs/demo/README.md) - Give contributors a CPU quickstart and issue forms that direct vulnerability reports to the private security channel. [Quickstart](README.md#try-it) · [Security reporting](SECURITY.md) diff --git a/log/reader.py b/log/reader.py index 997d9dd..a0afbb6 100644 --- a/log/reader.py +++ b/log/reader.py @@ -82,3 +82,5 @@ def unique(items: list[tuple[str, object]]) -> dict[str, object]: return json.loads(data.decode("utf-8"), object_pairs_hook=unique) except HTTPException: raise OSError("Log read unavailable") from None + except RecursionError: + raise ValueError("Public log response nests too deeply") from None diff --git a/tests/test_log_monitor.py b/tests/test_log_monitor.py index 27cadc9..caa47ad 100644 --- a/tests/test_log_monitor.py +++ b/tests/test_log_monitor.py @@ -238,3 +238,52 @@ def test_pinned_https_reader_observes_actual_log(self) -> None: finally: http.shutdown() thread.join() + + @unittest.skipUnless(shutil.which("openssl"), "requires OpenSSL for test-only TLS") + def test_deeply_nested_log_response_is_malformed_and_raises_a_coverage_alert( + self, + ) -> None: + make_certificates(self.root, cast(str, shutil.which("openssl"))) + tls = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + tls.load_cert_chain(self.root / "proxy.pem", self.root / "proxy.key") + nested = b"[" * 65536 # nests too deeply for json on Python 3.10 to 3.14 + + def hostile(env: dict[str, Any], start_response: Any) -> list[bytes]: + start_response("200 OK", [("Content-Type", "application/json")]) + return [nested] + + with make_server( + "127.0.0.1", 0, cast(Any, hostile), handler_class=Quiet + ) as http: + http.socket = tls.wrap_socket(http.socket, server_side=True) + thread = threading.Thread( + target=http.serve_forever, kwargs={"poll_interval": 0.02}, daemon=True + ) + thread.start() + try: + read = LogReader( + f"https://127.0.0.1:{http.server_port}/log/v1/", + timeout=2, + max_response_bytes=65536, + context=ssl.create_default_context( + cafile=str(self.root / "ca.pem") + ), + ) + with self.assertRaisesRegex(ValueError, "nests too deeply"): + read("sth") + self.monitor.hold(self.issue(self.log)) + self.now += timedelta(seconds=11) + stop = threading.Event() + alerts: list[dict[str, Any]] = [] + + def emit(report: dict[str, Any]) -> None: + alerts.append(report) + stop.set() + + self.monitor.run(read, stop, interval=0.01, emit=emit) + self.assertEqual( + [a["kind"] for a in alerts], ["observation_unavailable"] + ) + finally: + http.shutdown() + thread.join() From 0e05dfb025751a2ae499ffa132de81284c084def Mon Sep 17 00:00:00 2001 From: owizdom Date: Fri, 27 Nov 2026 15:57:40 +0200 Subject: [PATCH 2/2] Move the changelog line to the end of Unreleased The verifier fix in #115 adds its line at the top of the same list. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aacffe9..9c6a0c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ ## Unreleased -- The independent log monitor treats a public log response nested too deeply to decode as malformed. It keeps running and raises the coverage alert for overdue promises instead of stopping without one. [Independent monitor](log/README.md#independent-monitor) - Rename the project to Akashi. The repository moved to `Lucid-Computing/akashi`. The CLI is now `akashi`, the wheel `akashi-verify`, the environment prefix `AKASHI_`, and the service units and paths `akashi*`. Protocol domains, the `x-akashi-receipt` header, `/.well-known/akashi.json` and the `akashi-pickup/1` envelope replace their `vig` forms. Receipts, pickups and verdicts made under the old domains no longer verify, and the reference vectors were regenerated. [Data model](docs/spec/03-data-model.md) - Document the recorded Maverick request and both offline CLI verdicts with exact measurement boundaries and machine-readable evidence. [Recorded demo](docs/demo/README.md) - Give contributors a CPU quickstart and issue forms that direct vulnerability reports to the private security channel. [Quickstart](README.md#try-it) · [Security reporting](SECURITY.md) +- The independent log monitor treats a public log response nested too deeply to decode as malformed. It keeps running and raises the coverage alert for overdue promises instead of stopping without one. [Independent monitor](log/README.md#independent-monitor) ## 0.0.0 development candidate