GeezerVison is showing github.com — cold-store-reaper(worker): Google token response is shape-trusted and cached — a wrong-shape 200 poisons the DO token cache (Bearer undefined) for up to an hour · Issue #6989 · developing-today/code
cold-store-reaper(worker): Google token response is shape-trusted and cached — a wrong-shape 200 poisons the DO token cache (Bearer undefined) for up to an hour #6989DescriptionProblem
pkgs/cold-store-reaper/worker/src/index.js — BundleFlight.accessToken() (the
rehydrator Worker's Google token exchange) trusts the token endpoint's 200
response body completely:
const payload = await resp.json();
const entry = {
token: payload.access_token,
expires_at_ms: Date.now() + (payload.expires_in ?? 3600) * 1000,
};
await this.state.storage.put("google_token", entry);
return entry.token;
There is no validation that payload is an object, that access_token is a
non-empty string, or that expires_in is a usable number — and the
unvalidated result is written to Durable Object storage as the cached
token. The cached entry is then trusted by the early return at the top of
accessToken() (cached.expires_at_ms > Date.now() + 60_000), so one
wrong-shape 200 poisons every later rehydration on that bundle DO until the
bogus expiry passes.
Verified (laptop, main @7c8fb3e1ee, probe ~/git/fleet/probe-reaper-token)
Real src/index.js + src/decoder.js copied verbatim (md5-checked against
the laptop primary), stub DO storage + stub token endpoint, BundleFlight
driven directly (the shipped tests' own harness shape):
- Control
{access_token:"good", expires_in:3600} → returns "good",
second call served from cache, token endpoint called once. Correct.
{} (200, no access_token) → accessToken() returns undefined and
caches it (google_token entry with a ~1h future expires_at_ms);
the second call returns undefined again with the token endpoint still
called only once. Every rehydrate() in that window sends
Authorization: Bearer undefined to Drive and fails 502 — even after the
token endpoint recovers.
{access_token:123, expires_in:3600} → returns the number 123 and
caches it the same way.
- JSON
null body → raw TypeError: Cannot read properties of null (reading 'access_token').
- Non-JSON 200 body → raw
SyntaxError out of resp.json().
In BundleFlight.fetch the raw errors surface as a 502 with the raw
runtime message (rehydration failed: Cannot read properties of null…),
not the module's HttpError vocabulary (google token exchange failed (HTTP …) is the only shaped failure, and it covers only non-200 status).
Why it matters
The rehydrator is the read door for cold-store restores. A single
malformed-but-200 token response (proxy/error-page JSON, a Google-side
shape change, a partial deploy) currently converts a transient exchange
hiccup into up to an hour of hard 502s per bundle DO, with no re-exchange
attempt and an error message that does not say the token response was the
problem. The Python sibling got exactly this boundary shaped in #6846
(cold_store.py token endpoint); the Worker door was not covered by it.
Acceptance criteria
accessToken() validates the parsed body before caching: it must be a
plain object with a non-empty string access_token; anything else
(null, scalar, array, missing/wrong-typed access_token) throws
HttpError(502, …) naming the token exchange as the failure, and
nothing is written to the google_token storage entry.
- A non-JSON 200 body produces the same shaped 502, not a raw
SyntaxError.
expires_in is used only when it is a finite positive number;
otherwise the existing 3600s default applies (no NaN/negative expiry
is ever cached).
- A cached entry whose
token is not a non-empty string is treated as
absent (re-exchange), so an already-poisoned entry self-heals.
- Regression tests in the package's node test style (stub token endpoint,
as in test/range-ignored.test.mjs) cover: control cached once;
{}/numeric-token/null/non-JSON responses → shaped 502, no cache
write, and a following call re-exchanges and succeeds.
- Existing worker tests still pass (
npm test in
pkgs/cold-store-reaper/worker).
Dedup note: #6846 covers the Python cold_store.py access_token /
auth_exchange parsing only; #6845/#6855 are the Python state/Drive
surfaces; #6590/#6182 are this Worker's decompression/range bounds. No
open or closed issue covers the Worker's JS token exchange. Activitydeveloping-today commented on Nov 8, 2026 dezren39 commented on Nov 8, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a, run 2026-11-07 18:05 CST
- Found via: filed this run
- Task: Validate the Google token-exchange response in the cold-store-reaper Worker's
BundleFlight.accessToken() before caching it, so a wrong-shape 200 cannot poison the DO token cache.
- Expectation: effort/s — done when accessToken() rejects non-object / missing-or-non-string access_token / non-JSON bodies with a shaped HttpError 502 and writes nothing to the cache, expires_in is used only when finite and positive, a poisoned cached entry self-heals, and regression tests in the package's node test style cover the shapes while the existing worker tests still pass.
- Links: verified this run on laptop main @7c8fb3e1ee, probe ~/git/fleet/probe-reaper-token (real src/index.js + src/decoder.js, md5-checked; control cached-once OK, {} → undefined token cached ~1h, numeric token cached, null body raw TypeError, non-JSON raw SyntaxError)
dezren39 commented on Nov 9, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 11, 2026 🤖 Agent note · parked (review wait)
Both Codex P1s on PR #8702 are fixed in head 25b3d3c and dispositioned on their threads:
- 4539080444 (property coverage): new test/token-response-properties.test.mjs — 64 seeded generated cases (cache states × response shapes) with named oracles (no-write-on-reject, accept-returns-supplied with oracle expiry, cache discipline incl. the 60s margin), wired into npm test. Reply 4539623579.
- 4539080455 (stale deployment bundle): dist/worker.js rebuilt via the package's own npm run build and committed; the artifact now contains the validated accessToken. Reply 4539623887.
Verified on the laptop at the new head: npm test green, 57 ok checks, no failures (56 prior + the property aggregate). Parked for the Codex re-review of 25b3d3c: if clean, merge PR #8702 and complete task 11380 as fixed_merged. dezren39 commented on Nov 11, 2026
Agent note - picked up (resume)
dezren39 commented on Nov 11, 2026
Agent note - done (fixed_merged)
- Agent: queue worker (repo-worker-code), lane code-b
- Task: task 11380 (small_fix) for issue cold-store-reaper(worker): Google token response is shape-trusted and cached — a wrong-shape 200 poisons the DO token cache (Bearer undefined) for up to an hour #6989; PR fix(cold-store-reaper): validate the Google token response before caching it (#6989) #8702 squash-merged, merge commit 50d73cc; issue cold-store-reaper(worker): Google token response is shape-trusted and cached — a wrong-shape 200 poisons the DO token cache (Bearer undefined) for up to an hour #6989 CLOSED.
- Resume taken: the previous park fixed both Codex P1s in head 25b3d3c (property coverage + dist bundle rebuild, replies 4539623579 / 4539623887). The Codex re-review summary for that head reports completed with no findings and no unresolved findings; both review threads are now resolved.
- Re-verified fresh this shift on the laptop at head 25b3d3c: npm test in pkgs/cold-store-reaper/worker - exit 0, 57 ok checks, all token-response and property checks passed. PR diff is exactly the five in-scope files (src/index.js, dist/worker.js, package.json, both token-response test files).
- CI: PR check runs were CANCELLED in the repo-wide runner stall (not failures); the merge rests on the local targeted verification above plus the clean Codex re-review, per standing merge authority.
- Labels: in-flight labels (status/in-progress, queue/claimed, work/assigned) removed at completion.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|