You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Store: a transition's stamp: actor stores an unvalidated principal id from StoreExports/host transactions (lone surrogate, over maxLength), then reads 503 and restart is refused #1015
Trusted host code (StoreExports) then runs a transition with a principal id that is not valid:
const{ record }=awaitexports.records('docs').create(null,{title: 'a'});awaitexports.records('docs').transition({id: '\ud800x'},record.id,'finish');// accepted
A host transaction behaves the same: tx.records('docs').transition({ id: '\udc00' }, id, 'finish').
Expected: 422 invalid_record, as SECURITY.md says for StoreExports and host transactions ("Every stored string is well-formed Unicode").
Actual: the transition is accepted and the stored by is not well-formed. After that:
GET /api/docs and GET /api/docs/<id> answer 503;
the next activation is refused;
writes of other records still succeed.
The same path also skips schema validation of the stamped value. A 200-character id against maxLength: 128, or 'x y' (outside principalIdPattern), is stored. The 200-character case also breaks reads with 503 and refuses restart ("a stored record no longer matches the collection schema").
HTTP is not affected, because core asserts principalIdPattern on principals from authorize(). The gap is reachable only by trusted code that passes a principal. It becomes a denial of service for the collection if application code derives a principal from caller input.
Relevant output
lone surrogate transition: accepted
stored by (len, wellFormed): 2 false
GET list after: 503 {"error":{"code":"storage_unavailable","message":"This collection was redeclared by a reload; try again"}}
restart refused: Collection docs: record … holds by as a string with an unpaired UTF-16 surrogate …
200 chars > maxLength 128 transition: accepted
200 chars > maxLength 128 restart refused: Collection docs: a stored record no longer matches the collection schema
Root cause (from reading the code)
packages/store/src/collection.ts around line 1637 stamps actor ?? 'anonymous' without validated(), the unicode check or principalIdPattern.
caller() (around line 1483) does not validate the principal for a by: any transition without members.
packages/store/src/records.tsownerOf/actorOf (around lines 125-127) take principal.id as given.
Suggested fix: validate the principal id in records.ts, the same way the owned-collection path does through principal(), and run stamped values through the property checks.
Second, smaller problem
When a stored row fails validation on read, the answer is 503 with the message "This collection was redeclared by a reload; try again" (collection.ts around line 915). For a bad row that message is wrong, and retrying never helps.
Activity
fix(store): activation refuses stored balances outside the declaratio…