Repository navigation
fix(security): harden provider plaintext egress paths - #612
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 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".
| case 400, 422: | ||
| return .invalidRequest |
There was a problem hiding this comment.
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 👍 / 👎.
| `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. |
There was a problem hiding this comment.
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 👍 / 👎.
| The production shared overflow queue is disabled. Explicitly injected queue | ||
| instances remain only for compatibility tests. |
There was a problem hiding this comment.
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 👍 / 👎.
| case 400, 422: | ||
| return .invalidRequest |
There was a problem hiding this comment.
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)") |
There was a problem hiding this comment.
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 👍 / 👎.
| failure: InferenceFailure( | ||
| code: statusCode == 503 ? .capacity : .modelUnavailable, | ||
| statusCode: statusCode, | ||
| errorReason: .modelLoad)), |
There was a problem hiding this comment.
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 👍 / 👎.
2d4687f to
ae06eed
Compare
There was a problem hiding this comment.
💡 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()) |
There was a problem hiding this comment.
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 👍 / 👎.
| safe.ErrorReason = safeInferenceErrorReason(safe.FailureCode, msg.ErrorReason) | ||
| safe.StatusCode = safeInferenceFailureStatus(safe.FailureCode, safe.ErrorReason, safe.TerminalCause) |
There was a problem hiding this comment.
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 👍 / 👎.
| // Lock acquisition and legacy plaintext-media housekeeping are one | ||
| // ordered operation shared with coordinator-connected foreground mode. | ||
| try ProcessLifecycle.acquireMediaServingLock() |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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. |
There was a problem hiding this comment.
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 👍 / 👎.
eedf929 to
b685300
Compare
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 reportremains operator-controlled with macOS privacy redaction, local--dry-runreview, 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-lmpin (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
darkbloom report, scoped to provider unified logs with macOS privacy redaction, local--dry-runreview, authenticated upload, a 10 MiB cap, and admin-only retrieval.vlm-<UUID>.mp4files, once after the shared media-serving single-instance lock, for coordinator-connected and standalone launch paths.Before
After
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.make provider-test— 2,079 tests in 213 suites passed on the post-merge branch.Components touched
coordinator/protocolandProviderCore/Protocol; symmetry tests cover casing and omissionlibs/mlx-swift-lmpin already contains fix(media): decode inline video without plaintext temp files mlx-swift-lm#105Notes for reviewers
ProviderLoggerfree-form strings are private while bounded operational messages remain public.--dry-run, and never runs automatically from trust status; upload is authenticated and retrieval is admin-only.provider_log_reportsrows remain usable and are not destructively purged.