Skip to content

fix(security): reserve the system partition on client surfaces - #12

Merged
ChromaBeast merged 1 commit into
mainfrom
fix/system-partition-guard
Nov 24, 2026
Merged

ChromaBeast merged 1 commit into
mainfrom
fix/system-partition-guard

Conversation

@ChromaBeast

Copy link
Copy Markdown
Owner

What

Console users and API tokens were stored at keys the data APIs could address, so a client with write access could rewrite credentials:

  • a gRPC writer token could overwrite the admin user record and then sign in to the console
  • a viewer could read password hashes

Port of the security fix that had only lived on local branches (security/system-partition), rebased onto current main.

Changes

  • Partition 0x05 is a reserved system partition. gRPC Get, Put, Delete and BatchWrite (operations and conditions) reject its keys with PermissionDenied; Scan skips them.
  • The console's data routes hide it: keys read as absent, writes are refused with 403, and scans, search and partition counts leave it out.
  • Console user records move into the system partition. The admin account is migrated at startup; sign-in never falls back to the old key.
  • Followers reload API tokens every 15 s, so a token revoked on the leader stops working there without a restart.
  • Snapshots are written 0600 instead of 0644.

Porting notes

  • The guard sits next to the collection catalog checks on main.
  • The console's checkpoint, collection and index routes use the unguarded engine, because wrapping the engine hid the CollectionStore and IndexStore interfaces (501). They cannot reach the system partition: partition 0x05 cannot be bound to a collection.
  • Existing admin records at the old key are moved on first start; a record at that key that is not the admin account is left alone.

Testing

go build ./... && go vet ./... && go test ./... -race -p 1 passes locally. New tests cover gRPC rejection of system keys, the console guard, and the legacy-user migration.

Console users and API tokens were stored at keys the data APIs could
address. A gRPC writer token could overwrite the admin user record and
then sign in to the console; a viewer could read password hashes.

- Partition 0x05 is a reserved system partition. gRPC Get, Put, Delete
  and BatchWrite (operations and conditions) reject its keys with
  PermissionDenied, and Scan skips them. The console's data routes hide
  it: keys read as absent, writes are refused, and scans, search and
  partition counts leave it out.
- Console user records move into the system partition. The admin account
  is migrated at startup; sign-in never falls back to the old key, because
  clients can write there.
- Followers reload API tokens every 15 s, so a token revoked on the
  leader stops working there without a restart.
- Snapshots are written 0600 instead of 0644.

Ported onto current main: the guard sits beside the collection catalog
checks, and the console's checkpoint, collection and index routes use the
unguarded engine because they cannot reach the system partition.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T19:36:03.375898Z d4eb31c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4eb31c2cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


func (g systemGuard) Search(query string, limit int, prefix uint8) ([]api.RecordItem, error) {
items, err := g.EngineReader.Search(query, limit, prefix)
return withoutSystem(items), err

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Filter system matches before applying the search limit

For an unprefixed /api/search request using the fast path, Engine.Search has already stopped at the requested limit, and the handler marks any nonempty indexed result as having no more results. Because system matches are removed only here, they can consume slots ahead of later ordinary records and silently truncate results; if any ordinary matches remain, the fallback scan is skipped. Exclude system keys before applying the limit, or fall back when filtering removes candidates.

Useful? React with 👍 / 👎.

@ChromaBeast
ChromaBeast merged commit f4fd751 into main Nov 24, 2026
4 checks passed
@ChromaBeast
ChromaBeast deleted the fix/system-partition-guard branch November 24, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant