Skip to content

fix(security): harden provider plaintext egress paths - #612

Merged
Gajesh2007 merged 4 commits into
masterfrom
fix/provider-confidentiality-3-4
Aug 14, 2026
Merged

Gajesh2007 merged 4 commits into
masterfrom
fix/provider-confidentiality-3-4

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Hardens provider confidentiality paths that could expose inference-derived error prose or decrypted inline video bytes outside their intended trust boundary. Normal inference failures now cross protocol, telemetry, and client paths only through a closed vocabulary; browser/provider free-form telemetry and trust-triggered automatic log reporting are retired; explicit darkbloom report remains operator-controlled with macOS privacy redaction, local --dry-run review, authenticated upload, and admin-only retrieval. Inline MP4/QuickTime is decoded from owned memory with exact-name cleanup for legacy temp files.

Layr-Labs/mlx-swift-lm#105 is already included in latest master’s libs/mlx-swift-lm pin (5b8e6e3991dce0c9702b49a7137f8d0dba101ca0), so after this rebase the PR carries no nested-dependency gitlink delta.

Linked issues

None — security hardening identified during the provider confidentiality review.

What changed

  • Added canonical Go/Swift inference-failure codes, reasons, and terminal causes; provider-rich text is classified in-process and never serialized.
  • Coordinator validates the closed vocabulary, ignores provider-authored error prose, and derives logs, failover decisions, telemetry, persistence, and client responses from coordinator-owned state plus bounded enums.
  • Disabled provider/browser free-form telemetry transport and removed trust-triggered automatic log reporting. Retained explicit darkbloom report, scoped to provider unified logs with macOS privacy redaction, local --dry-run review, authenticated upload, a 10 MiB cap, and admin-only retrieval.
  • Reworked provider inline-video ingestion to use the memory-backed MLX asset from fix(media): decode inline video without plaintext temp files mlx-swift-lm#105; MP4 and QuickTime remain in memory through metadata probing and frame sampling.
  • Purged only exact legacy vlm-<UUID>.mp4 files, once after the shared media-serving single-instance lock, for coordinator-connected and standalone launch paths.
  • Updated threat-model entries, operator/provider docs, changelog, and cross-language symmetry/privacy tests.

Before

flowchart TB
  A[Encrypted consumer request] --> B[MediaIngest.decodeVideo]
  B --> C[Write decrypted vlm-UUID.mp4]
  C --> D[EngineV2VisionPrefill / AVFoundation]
  D --> E[Provider inference]
  E --> F[Rich Swift error text]
  F --> G[WebSocket error and local logs]
  F --> H[Free-form telemetry and automatic log-report upload]
  G --> I[Coordinator logs / persistence / client error]
  J[Browser events] --> H
Loading

After

flowchart TB
  A[Encrypted consumer request] --> B[MediaIngest.decodeVideo]
  B --> C[MemoryBackedVideoAsset from MLX PR 105]
  C --> D[EngineV2VisionPrefill metadata + frame sampling]
  D --> E[Provider inference]
  E --> F[InferenceErrorClassifier]
  F --> G[InferenceFailure code + reason + cause]
  G --> H[ProviderLoop protocol encoder]
  H --> I[Coordinator vocabulary validation]
  I --> J[Coordinator-owned log / failover / telemetry / client response]
  K[Provider and browser telemetry facades] --> L[drop locally; no free-form upload]
  M[ProcessLifecycle after single-instance lock] --> N[purge exact legacy vlm-UUID.mp4 files]
  O[Operator invokes darkbloom report] --> P[Report.logShowArguments: provider subsystem + OS redaction]
  P --> Q[handleUploadLogReport: auth + 10 MiB cap + store]
  Q --> R[Admin-only list / retrieval]
Loading

Test plan

  • make coordinator-test — all Go packages passed on the post-merge branch.
  • cd console-ui && npm test — 56 files / 498 tests passed.
  • cd console-ui && npx eslint src/ — 0 errors, 104 existing warnings.
  • cd console-ui && npm run build — production build and all 44 static pages succeeded.
  • Focused Swift media, inference-failure privacy, protocol, telemetry-removal, startup-cleanup, explicit-report, standalone-server, and coordinator-integration tests passed.
  • Nested MLX media suite passed: 17 tests, including real AVFoundation memory-backed decoding, lifetime, range, container, cancellation, and no-temp-file coverage.
  • make provider-test — 2,079 tests in 213 suites passed on the post-merge branch.
  • System E2E not run; it requires Postgres, a provider binary, and a downloaded MLX model.

Components touched

  • Coordinator (Go)
  • Provider (Swift / Apple Silicon)
  • Console UI (Next.js)
  • Docs / threat model / changelog
  • Interface changes — canonical failure vocabulary is mirrored in coordinator/protocol and ProviderCore/Protocol; symmetry tests cover casing and omission
  • Nested dependency — no PR gitlink delta after rebase; latest master’s libs/mlx-swift-lm pin already contains fix(media): decode inline video without plaintext temp files mlx-swift-lm#105

Notes for reviewers

  • Detailed provider error prose is excluded from normal protocol, telemetry, and client surfaces. ProviderLogger free-form strings are private while bounded operational messages remain public.
  • Explicit provider reports are intentionally retained as an operator action. The command preserves macOS privacy redaction, offers --dry-run, and never runs automatically from trust status; upload is authenticated and retrieval is admin-only.
  • Historical provider_log_reports rows remain usable and are not destructively purged.
  • Plaintext necessarily exists in provider process memory and AVFoundation/GPU objects during inference. This patch removes the targeted on-disk video artifact and unintended automatic/free-form client telemetry egress, not in-process plaintext.
  • The legacy cleanup rejects symlinks/non-regular files and exact-name mismatches, and runs only while holding the shared media-serving lock.

@Gajesh2007 Gajesh2007 added security Security-sensitive issue or fix area:coordinator Coordinator (Go) area:provider Provider (Rust, runs on Apple Silicon) area:console-ui Console UI (Next.js) area:docs Documentation work specific to a component or feature labels Aug 12, 2026
@vercel

vercel Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
d-inference Ready Ready Preview Aug 14, 2026 8:54pm
d-inference-console-ui-dev Ready Ready Preview Aug 14, 2026 8:54pm
d-inference-landing Ready Ready Preview Aug 14, 2026 8:54pm

Request Review

@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: ddcb09179c

ℹ️ 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".

Comment on lines +185 to +186
case 400, 422:
return .invalidRequest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve failover for retryable 422 output failures

MLXOpenAIServiceError.invalidResponseFormatOutput and multipleToolCallsNotAllowed still map to status 422, but this fallback assigns them .invalidRequest without toolNoncompliance. The coordinator consequently normalizes them to client_error/400 and stops dispatch after the first provider, even though invalid model-generated JSON or extra tool calls can succeed on a re-sample; classify these output-dependent failures as a retryable closed-vocabulary failure rather than a deterministic request error.

Useful? React with 👍 / 👎.

Comment on lines +106 to +109
`POST /v1/telemetry/events` is retained only for compatibility and returns HTTP
410 without reading or forwarding the body. Provider and console clients also
drop events before buffering, disk I/O, or network I/O. A field-name allowlist
cannot make arbitrary messages, stacks, URLs, or field values privacy-safe.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add code citations to the new architecture claims

These new architecture-level claims cover behavior across the coordinator endpoint and both clients, but they provide no canonical file or line references. Cite the relevant telemetry_handlers.go, TelemetryClient.swift, and TypeScript route/facade locations so future changes can be checked against the documented flow.

AGENTS.md reference: docs/AGENTS.md:L21-L22

Useful? React with 👍 / 👎.

Comment on lines +135 to +136
The production shared overflow queue is disabled. Explicitly injected queue
instances remain only for compatibility tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the stale panic-hook disk-flow description

The disabled-queue statement is immediately contradicted by the Panic Hook section at lines 142–144, which still says crashes write the event and flush the in-memory buffer to disk. TelemetryOverflowQueue.push is now a no-op and shutdownSync only purges legacy artifacts, so update that sequence to describe the fixed stderr marker and no-op compatibility calls.

AGENTS.md reference: docs/AGENTS.md:L21-L22

Useful? React with 👍 / 👎.

Comment on lines +185 to +186
case 400, 422:
return .invalidRequest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve failover for retryable 422 output failures

MLXOpenAIService.invalidResponseFormatOutput and multipleToolCallsNotAllowed still map to status 422, but this fallback assigns them .invalidRequest without toolNoncompliance. The coordinator consequently normalizes them to client_error/400 and stops dispatch after the first provider, even though invalid model-generated JSON or extra tool calls can succeed on a re-sample; classify these output-dependent failures as a retryable closed-vocabulary failure rather than a deterministic request error.

Useful? React with 👍 / 👎.

func info(_ message: String) {
#if canImport(os)
osLogger.info("\(message, privacy: .public)")
osLogger.info("\(message, privacy: .private)")

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 Keep bounded operational logs visible to providers

On macOS this wraps the entire already-formatted message as .private, so ordinary darkbloom logs output renders every ProviderLogger entry as <private>, including fixed startup, connection, attestation, and failure-category messages. Because LogsCommand does not enable private-data logging—and this change also removes remote log reports—the documented local troubleshooting path loses essentially all provider diagnostics; keep request-derived values private while emitting bounded operational text through a public logging path.

Useful? React with 👍 / 👎.

Comment on lines +310 to +313
failure: InferenceFailure(
code: statusCode == 503 ? .capacity : .modelUnavailable,
statusCode: statusCode,
errorReason: .modelLoad)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve model-load fault and cooldown semantics

When ensureModelLoaded throws an ordinary provider fault, loadErrorStatusCode deliberately returns 500, but this ternary assigns .modelUnavailable to every non-503 result; the coordinator then ignores the supplied 500, derives 503, and exempts the broken provider from job-failure health tracking. Conversely, a 503 memory/load rejection becomes plain .capacity, whose sanitized reason is capacity_timeout, so the existing provider/model load-failure cooldown no longer runs. Preserve distinct bounded signals for missing models, transient load pressure, and genuine load faults rather than collapsing them here.

Useful? React with 👍 / 👎.

@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: ae06eed5ac

ℹ️ 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".

// accepted engine-health signal as a Datadog counter. Use the
// registry snapshot, never the raw heartbeat: its slot model IDs have
// been constrained to this connection's coordinator-known inventory.
s.recordBackendWedgeTelemetry(provider.BackendCapacitySnapshot())

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 Guard heartbeats received before registration

If a WebSocket peer sends a heartbeat before its register frame, the local provider is still nil; Registry.Heartbeat safely ignores the unknown ID, but this new snapshot call immediately dereferences nil. Because the provider WebSocket is accepted before authentication or registration, a malformed peer can repeatedly panic the HTTP handler, terminate connections, and generate server panic logs instead of receiving a controlled rejection.

Useful? React with 👍 / 👎.

Comment on lines +45 to +46
safe.ErrorReason = safeInferenceErrorReason(safe.FailureCode, msg.ErrorReason)
safe.StatusCode = safeInferenceFailureStatus(safe.FailureCode, safe.ErrorReason, safe.TerminalCause)

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 Preserve legacy 429 status during rollout

When a pre-upgrade provider sends its established queue-full frame (status_code: 429 with no failure_code or error_reason), this normalization derives capacity_timeout, after which safeInferenceFailureStatus rewrites the status to 503. Old Swift providers only supplied structured reasons for Jinja/tool failures, so this occurs during the intended mixed-fleet rollout; paths that directly use the sanitized status, including /v1/messages and /v1/completions, consequently expose a provider-capacity rejection as a server failure instead of the uptime-neutral 429.

Useful? React with 👍 / 👎.

Comment on lines +78 to +80
// Lock acquisition and legacy plaintext-media housekeeping are one
// ordered operation shared with coordinator-connected foreground mode.
try ProcessLifecycle.acquireMediaServingLock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Purge the legacy telemetry queue in standalone mode

When an operator upgrades and launches darkbloom start --local, this branch performs only the legacy video cleanup and never calls TelemetryClient.configure or shutdown, which are the sole normal paths that purge ~/.darkbloom/telemetry-queue.jsonl. That file can contain free-form, request-derived events written by the previous provider build, so local-only operators retain the plaintext artifact indefinitely despite upgrading to the release intended to remove this disk sink; include telemetry-queue removal in the common locked startup housekeeping.

Useful? React with 👍 / 👎.

@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: b9a57779ef

ℹ️ 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".

code: Int(ProviderLoop.mapInferenceErrorToStatus(error))
),
message: error.localizedDescription
message: InferenceFailureCode.internalFailure.message

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 Preserve bounded messages for local service errors

When darkbloom start --local surfaces MLXOpenAIServiceError cases such as responseNotFound, embeddingsNotConfigured, or output-validation failures, the status remains 404, 501, or 422 but every response now says “Internal inference failure.” This makes the OpenAI-compatible payload contradict its status and removes actionable client diagnostics. Map each enum case to fixed, privacy-safe text rather than using the raw localized description or collapsing all cases to an internal failure.

Useful? React with 👍 / 👎.

@Gajesh2007 Gajesh2007 changed the title fix(security): close provider plaintext egress paths fix(security): harden provider plaintext egress paths Aug 14, 2026

@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: eedf9298c1

ℹ️ 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".

For detailed failure logs, run `darkbloom report` or inspect unified logs with
`darkbloom logs --last 1h`.
For local diagnostics, inspect `darkbloom doctor` and `darkbloom logs --last 1h`.
Automatic and manual provider-log uploads are disabled for inference privacy.

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 Document the retained manual report upload

When an operator follows this attestation troubleshooting guidance, this sentence incorrectly says manual uploads are disabled. provider-swift/Sources/darkbloom/ReportCommand.swift:43-158 still implements the explicit darkbloom report upload, and coordinator/api/server.go still registers POST /v1/provider/log-report; only automatic reporting was removed. Update this statement so operators are not directed away from the supported diagnostic path.

AGENTS.md reference: docs/AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference — b6853001 Deployed Aug 14, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — b6853001 Deployed Aug 14, 2026 by vercel[bot]
Preview – d-inference-landing — b6853001 Deployed Aug 14, 2026 by vercel[bot]
benchmarks — b6853001 Deployed Aug 14, 2026 by Gajesh2007 via E2E Benchmarks #77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:console-ui Console UI (Next.js) area:coordinator Coordinator (Go) area:docs Documentation work specific to a component or feature area:provider Provider (Rust, runs on Apple Silicon) security Security-sensitive issue or fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant