fix: authoritative managed-settings.json applied after all user config#22296
Open
Daviey wants to merge 8 commits intoanomalyco:devfrom
Open
fix: authoritative managed-settings.json applied after all user config#22296Daviey wants to merge 8 commits intoanomalyco:devfrom
Daviey wants to merge 8 commits intoanomalyco:devfrom
Conversation
9 tests that fail on unpatched code, proving two bypass vectors: 1. OPENCODE_PERMISSION env var overwrites managed deny rules (mergeDeep second-arg-wins semantics) 2. Additive object merging lets users inject entries into managed fields (agent, mcp, instructions, provider, formatter, lsp, command, experimental, skills) that survive alongside managed config instead of being replaced
Introduce managed-settings.json (with managed-settings.d/ drop-in fragments) loaded after OPENCODE_PERMISSION and legacy tools, making it the authoritative final word. Object/array fields (agent, command, experimental, formatter, instructions, lsp, mcp, mode, provider, skills) are replaced entirely rather than additively merged, preventing users from injecting entries alongside managed ones.
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #22292
Type of change
What does this PR do?
Two bypass vectors allowed users to override enterprise managed config:
OPENCODE_PERMISSIONenv var was merged after managed config, so it won. A managed deny rule could be overwritten to allow.mcp,agent,provideretc. were additively merged. Users could inject extra entries alongside managed ones (e.g. adding anevilMCP server or an extra provider).The fix introduces
managed-settings.json(and amanaged-settings.d/drop-in directory) in the system config location. It is loaded last, after all user config, project config, andOPENCODE_PERMISSION, so it cannot be overridden. Object fields in that file replace rather than merge, closing the injection vector.The existing
opencode.jsonmanaged config is unchanged and still loads earlier in the chain (for non-authoritative defaults).managed-settings.jsonis the opt-in high enforcement layer.How did you verify your code works?
Three commits in this PR, each with a specific purpose:
Commit 1:
5c25db2(tests only, no fix)11 tests fail against unpatched code. Run with:
Output:
Commit 2:
c5ca9d1(the fix)Same tests, now all pass:
Output:
The 3 tests that already passed at commit 1 (permission deny via OPENCODE_PERMISSION, drop-in fragment ordering, dotfile ignore) continue to pass.
Commit 3:
3a3c2f2(docs)Adds documentation for
managed-settings.jsonandmanaged-settings.d/drop-in fragments topackages/web/src/content/docs/config.mdx. No code changes.Screenshots / recordings
N/A, no UI changes.
Checklist