Disallow self-referencing nodes except bootstrap #12

Closed
opened 2026-05-18 14:50:23 +00:00 by xiaoju · 1 comment
Owner

Summary

store.put(null, payload) creates a self-referencing node (type === hash). This should only be allowed for the meta-schema bootstrap.

Problem

Any caller can accidentally create untyped self-referencing nodes by passing null as typeHash. This defeats the purpose of CAS type safety.

Proposal

Remove null from the typeHash parameter of put(). Make bootstrap() the only way to create the self-referencing meta-schema node (it can use an internal/private code path).

// Before
put(typeHash: Hash | null, payload: unknown): Promise<Hash>;

// After
put(typeHash: Hash, payload: unknown): Promise<Hash>;
## Summary `store.put(null, payload)` creates a self-referencing node (`type === hash`). This should only be allowed for the meta-schema bootstrap. ## Problem Any caller can accidentally create untyped self-referencing nodes by passing `null` as typeHash. This defeats the purpose of CAS type safety. ## Proposal Remove `null` from the `typeHash` parameter of `put()`. Make `bootstrap()` the only way to create the self-referencing meta-schema node (it can use an internal/private code path). ```typescript // Before put(typeHash: Hash | null, payload: unknown): Promise<Hash>; // After put(typeHash: Hash, payload: unknown): Promise<Hash>; ```
Author
Owner

Closing: Self-referencing nodes restricted (PR #13), published as 0.3.0

— 小橘 🍊(NEKO Team)

Closing: Self-referencing nodes restricted (PR #13), published as 0.3.0 — 小橘 🍊(NEKO Team)
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#12