LibreChat/api/server
Danny Avila a3e8426588
🛡️ fix: Reject Unknown Admin Config Sections and Scope Write Responses to Read Access (#17315)
* 🛡️ fix: Reject Unknown Admin Config Sections and Scope Write Responses to Read Access

- Admin config writes (PUT, PATCH, tombstone) now accept only top-level sections that configSchema defines. PUT reports `unknown_section` issues under CONFIG_OVERRIDE_INVALID; PATCH and tombstone return 400 UNKNOWN_SECTION without echoing the path. This closes override writes to AppService runtime state (`paths`, the raw-YAML `config`, `availableTools`, and the `interfaceConfig`/`turnstileConfig`/`mcpConfig` aliases).
- mergeConfigOverrides ignores stored override keys and tombstones outside configSchema, with one warning per document, so data an older server stored is neutralized without a migration. DELETE /fields still removes such stored entries, which is the only per-field way to clear a legacy tombstone.
- Write responses (PUT, PATCH, tombstone, field delete, toggle) are redacted and then filtered to the sections the caller can read plus the sections the write managed; broad managers see the whole document as before.
- Admin reads of the resolved config redact literal Azure group keys (merged `groups`, `groupMap`, raw YAML copy) and the Vertex `serviceKeyFile` (`vertex` and `vertexConfig`), keeping `${ENV}` and `user_provided` references readable. Write behaviour for these paths is unchanged.
- The experimental cluster entry boots from librechat.yaml only (`baseOnly`), like server/index.js, so `__base__` overrides no longer reach file storage, skill sync, skill deletion or the expired-file sweep at boot.

* 🛡️ fix: Resolve Admin Config Write Read Access Before Committing

- Section-scoped writes (PATCH, tombstone, field delete) resolve the caller's readable sections before the mutation, alongside the pre-write reads they already make, instead of after the write and audit have committed. The batched lookup covers every `configSchema` section, so it no longer waits on the stored document.
- A failed grant lookup now fails the request before anything is stored, so a 500 never follows a committed write and invites a duplicate retry. Response filtering after the write is pure.
- Assign-only scope creation and toggles match only empty documents (`expectEmpty`), so their responses skip the lookup entirely.

* 🚩 feat: Report the Section Allowlist and Read-Filtered Write Responses in Config Meta

- `GET /api/admin/config/meta` now reports `sectionAllowlist: true` and `readFilteredWriteResponses: true`, which this branch implements (BE-17, BE-18).
- The meta.spec probes check each flag against the handlers rather than the validator alone: PUT answers `unknown_section` with `segments`, PATCH and tombstone answer `UNKNOWN_SECTION`, a stored `paths` override and tombstone are ignored at merge, and PATCH, tombstone and field delete responses omit a section the caller cannot read.
- A dotted top-level key is reported once, as `dotted_key`, instead of also as `unknown_section`.
- The unknown-section handler and integration tests expect the `segments` that issues carry since #17322.

* 🧪 test: Type the Tombstoned Meta Probe Document Through storedConfig

* 🧪 test: Align Allowlist and Filtered-Response Specs with Version-Checked Web Search Writes

dev's version-checked webSearch writes pass a session and precondition to
patchConfigFields/unsetConfigField, read the stored document before removing a
binding path, and have getBaseConfig load the librechat.yaml config beside a
merged read. The field delete spec now stores the document it removes from and
asserts the precondition alongside the filtered response.

* 🧪 test: Pin Section-Manager Write Responses to What a Read Shows

The grant layer resolves read:configs:<section> from the same section's
manage:configs:<section> (getParentCapabilities, #14472), so a section
manager's GET already returns the whole managed section. The comment on
resolveWriteReadAccess said the opposite; it now states the model.

A new integration spec runs the handlers over real SystemGrant documents
through generateCapabilityCheck: a caller holding only
manage:configs:endpoints patches one endpoints field, and its write
response equals what GET returns it, other endpoint overrides and
tombstones included, with memory and webSearch left out of both.

* 🧪 test: Mark Config-Service Generation Tests With a Schema Section

The base-config generation tests that came with the portable config store marked each base
config and override layer with an `x` key, which no section in `configSchema` defines. This
branch dropped `x` from the spec's `TestConfig` and ignores such keys when overrides are merged,
so those tests no longer typechecked, and the override-layer ones would stop seeing the layer
they read. They now mark layers with the `version` section, as this branch's other service tests
do.

* 🧪 test: Expect the yamlMcpHide Flag Beside the Section Allowlist Flags

#17327 publishes features.yamlMcpHide on dev, so the exact feature list this PR asserts in
meta.spec now includes it.
2026-10-22 16:52:56 +02:00
..
controllers 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
middleware 🚡 fix: Restore Enforced Model Specs for Agent Continuations (#17229) 2026-10-22 11:43:19 +02:00
routes 📔 fix: Recover Subagent Content With Shared Chat Rendering (#17290) 2026-10-22 15:32:40 +02:00
services 📔 fix: Recover Subagent Content With Shared Chat Rendering (#17290) 2026-10-22 15:32:40 +02:00
utils 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
cleanup.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
csp.spec.js 🔌 fix: Close Leaked HTTP Server in Server Specs (#15821) 2026-09-10 15:17:06 -04:00
experimental.js 🛡️ fix: Reject Unknown Admin Config Sections and Scope Write Responses to Read Access (#17315) 2026-10-22 16:52:56 +02:00
experimental.spec.js 🛡️ fix: Reject Unknown Admin Config Sections and Scope Write Responses to Read Access (#17315) 2026-10-22 16:52:56 +02:00
index.js 🔑 feat: Keep Dotted Record Keys in Admin Config Writes and Publish the Config Contract (#17322) 2026-10-22 09:59:08 +02:00
index.metrics.spec.js 🔌 fix: Close Leaked HTTP Server in Server Specs (#15821) 2026-09-10 15:17:06 -04:00
index.spec.js 🔭 feat: Recover Stale Chunks Without the Error Page and Ship Client Logs to RUM (#16701) 2026-10-03 23:17:56 -04:00
socialLogins.js 🔁 feat: Retry OpenID Discovery After Startup Failures (#15899) 2026-09-13 23:16:26 -04:00
socialLogins.spec.js 🔁 feat: Retry OpenID Discovery After Startup Failures (#15899) 2026-09-13 23:16:26 -04:00
telemetry.js
telemetry.spec.js