Skip to content

Address audit findings: security, durable publishing, TLS and gateway reliability - #20

Draft
magiccodingman wants to merge 2 commits into
masterfrom
agent/audit-stabilization
Draft

magiccodingman wants to merge 2 commits into
masterfrom
agent/audit-stabilization

Conversation

@magiccodingman

@magiccodingman magiccodingman commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Why this change is needed

The audit found failures at several application boundaries: executable IPFS content shared the management origin, cookie operations lacked consistent CSRF protection, live rate counters were reset by persistence, incomplete publications/IPNS targets could replace working content, and TLS persistence omitted intermediates.

This draft implements the TG-01–TG-24 remediation matrix and prepares a branch for the requested independent ground testing. It targets master at a4c5ab91740b8c9302022bcdca632219d5016778. PR #19's connected-version pruning work is included, retaining its original commit as a merge parent; this PR adds acquisition, recovery and regression fixes around it.

What changes

  • Management security: separate raw-content browsing from the management origin; protect fallback routes; authenticate keys before rate decisions; validate a key once; add same-origin/antiforgery checks, host-only secure cookies, account-version revocation and interactive circuit revalidation. Public metadata retains its own read-only CORS policy.
  • Gateway correctness: preserve negative cache results and path case, invalidate mutable pointers, revalidate mutable URLs, decide retries before response commitment, translate mapped directory redirects, preserve unknown-length uploads, stream internal RPC content and pass cancellation. Remove browser-storage deletion and repair IPNS asset routing.
  • Publishing and IPNS: persist bounded publication jobs and immutable promotion checkpoints; expose status/history/retry routes; recover interrupted work and restore old mappings on failure; keep incomplete watched targets from replacing/pruning complete versions. Compute the final site CID after identity files, preserve stable domain storage leaves, repair generated TGP JavaScript, quoted filenames, empty assets and staging cleanup.
  • TLS and configuration: persist/send complete certificate chains, cache SNI contexts, bound issuance to configured exact hosts (including explicitly configured management hosts), atomically persist configuration before exposing a new snapshot, and preserve JSON false in Kubo settings.
  • Maintenance: update .NET package pins to 10.0.15 and SQLitePCLRaw to 2.1.13, include both test projects in the solution, run the expanded regression suites and shell matrix in CI, and correct unsupported role/scoped-key documentation claims.

Deployment and client changes

  1. Arbitrary /ipfs/ and /ipns/ browsing needs Gateway__ContentGatewayOrigin pointing to an independent HTTPS gateway on a different hostname; otherwise it returns 409. Mapped sites remain available. The local Kubo WebUI is the explicit trusted exception.
  2. Existing browser sessions must sign in again. Cookie-authenticated admin mutations and all cookie-authenticated Kubo RPC calls require a same-origin request plus X-TruthGate-CSRF from GET /auth/csrf. Explicit valid API keys do not need that token.
  3. Keep publication journals on persistent storage: by default state/publications beside the configuration. 202 now returns a durable job ID and status URL; it does not mean publication has finished.
  4. Nonzero CLI --batch-size is rejected before upload because publishing separate batches can replace a site with partial content.
  5. Development __host, X-Dev-Host, and DevEmulateHost authority overrides are removed. Use real separate hostnames.
  6. Users and API keys currently have full node administration access; per-domain key scopes and user roles are not claimed.

Verification

Verified PR head: 24cae7722d0d5d13aee79da58dc9a93ad3903df0.

Gate Result
Application regression CI Passed. Clean Release build; 130/130 tests passed: 66 configuration/TLS/publication/IPNS tests and 64 rate/auth/gateway tests. Kubo boolean precedence matrix also passed.
Docker appliance CI Passed. Production and development image builds, start/replace/revalidate smoke checks and diagnostics on native AMD64 and ARM64; Compose and shell validation passed.
Repository migration CI Passed.
Documentation CI Passed. 44 Markdown files validated.
Local focused validation 24 configuration/TLS, 44 rate/auth and 42 publishing/IPNS/upload tests passed in component runs. CLI loopback checks rejected batching before connection and honored a one-second timeout with nonzero exit.

The clean GitHub runner completed the combined build and all suites normally. Locally, a temporary uncommitted MSBuild registration worked around blocked WebAssembly task-host IPC, but aggregate compilation later hit sandbox resource limits; no workaround is included in application code or CI.

The Release build has 0 errors and 49 non-failing warnings, principally nullable model/UI references, deprecated API calls and inherited-member hiding. Those warnings remain visible; they were not suppressed. A separate warning cleanup is outside the 24-finding remediation matrix.

Review handoff

Finding-by-finding remediation, settings, API behavior, and acceptance matrix

Before merging, run the documented real-browser/WebUI, production/development Docker (AMD64 and ARM64), external Kubo/IPNS, ACME staging, large-upload, and process-kill recovery checks. Publication journals/SQLite assume one active appliance process; promotion uses durable recovery across sequential MFS/IPNS operations. Historical immutable roots remain pinned for safe recovery, with ownership-aware pin cleanup left to the operator.

No merge or deployment is requested by this PR.

… gateway reliability

Integrate the connected IPNS version pruning work from PR #19, retaining its original commit as a merge parent. Add origin isolation, session revocation and CSRF protection, durable publication recovery, atomic configuration and rate-counter persistence, full TLS chains, streaming proxy behavior and regression coverage.

Include the complete audit finding matrix and deployment/acceptance handoff in docs/developer/audit-remediation.md.
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