Skip to content

fix(security): remove unsafe ledger append endpoint#266

Open
chitcommit wants to merge 2 commits into
mainfrom
fix/remove-unsafe-ledger-append
Open

fix(security): remove unsafe ledger append endpoint#266
chitcommit wants to merge 2 commits into
mainfrom
fix/remove-unsafe-ledger-append

Conversation

@chitcommit

@chitcommit chitcommit commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Finding

POST /api/v1/ledger/append was mounted in src/api/router.js despite earlier reporting that the route was dead. The global API-key guard blocks anonymous callers, but the route only checked that a sovereignty header existed; certificate validation was commented out and any authenticated caller could supply an arbitrary signer_id before an immutable context_ledger insert.

Change

  • Remove the ledgerRoutes import and /api/v1/ledger mount.
  • Delete src/api/routes/ledger.js.
  • Leave the separate [SPEC] /api/v1/ledger/emit contract untouched. A replacement must be built against the actual ChittyCert contract, mounted explicitly, and covered by authorization tests.

Deployment

No deployment performed. Draft PR for CI and review.

Summary by CodeRabbit

  • New Features

    • Added API routes for tenant management, tenant migrations, and session handling.
  • Removed

    • Removed the ledger API endpoint and its associated functionality.

Copilot AI review requested due to automatic review settings July 25, 2026 01:02
@linear-code
linear-code Bot marked this pull request as ready for review July 25, 2026 01:02
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 280507a8-c6d5-433c-b16d-5f975a4a9339

📥 Commits

Reviewing files that changed from the base of the PR and between 5c3c550 and f5d4870.

📒 Files selected for processing (2)
  • src/api/router.js
  • src/api/routes/ledger.js
💤 Files with no reviewable changes (2)
  • src/api/routes/ledger.js
  • src/api/router.js

📝 Walkthrough

Walkthrough

The API router removes the ledger route and ledger module, then registers tenant, tenant migration, and session routes while preserving subsequent API routes.

Changes

API routing

Layer / File(s) Summary
Replace ledger routing with tenant routes
src/api/router.js, src/api/routes/ledger.js
Ledger route imports and registration are removed, the ledger route module is deleted, and tenant, migration, and session routes are registered under /api/v1.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has the right intent but misses the required template sections and checklist items. Rewrite it to match the template: add Summary, Security & Access, Docs, and Validation sections with the requested details and checkboxes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing the unsafe ledger append endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-unsafe-ledger-append

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
chittyconnect f5d4870 Jul 25 2026, 01:02 AM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes the unsafe POST /api/v1/ledger/append route surface from the ChittyConnect API router to prevent authenticated callers from appending arbitrary events into the immutable context_ledger table without certificate validation.

Changes:

  • Deleted the src/api/routes/ledger.js route implementation (including /append).
  • Removed the ledgerRoutes import and /api/v1/ledger mount from src/api/router.js.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/api/router.js Removes the /api/v1/ledger route mount and associated import to eliminate the endpoint from the public API surface.
src/api/routes/ledger.js Deletes the unsafe ledger append implementation that lacked enforced certificate validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants