[FIX][PLUGINS]: Fix X-Vault-Token header leaking to MCP servers on misconfiguration#3033
Merged
crivetimihai merged 3 commits intoIBM:mainfrom Feb 20, 2026
Merged
Conversation
93aa232 to
7c6a992
Compare
crivetimihai
previously approved these changes
Feb 19, 2026
Member
crivetimihai
left a comment
There was a problem hiding this comment.
Good security fix. The X-Vault-Tokens header was leaking to the upstream MCP server in three cases:
- JSON parse error — returned
ToolPreInvokeResult()without removing the header - No token match — returned
ToolPreInvokeResult()without removing the header - Only removed on
if modified— missed the case where processing happened but no auth header was added
Moving the del headers[vault_header_name] immediately after parsing (and also in the error path) ensures the header is always stripped regardless of downstream logic. Tests correctly verify removal in both error and no-match scenarios.
Signed-off-by: popagruia <adrian.popa@ro.ibm.com>
…d validate parsed token type - Strip vault header even when system cannot be determined from gateway metadata - Validate that parsed vault tokens are a JSON object (dict), not array/string/etc. - Remove misleading type annotation on orjson.loads result - Update test to verify header stripping on missing system tag Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Add two new test cases: - test_no_system_tag_no_vault_header_returns_empty: covers the branch where system key cannot be determined and no vault header is present - test_non_dict_json_vault_tokens_stripped: covers the isinstance guard ensuring non-dict JSON (e.g. arrays) strips the vault header without injecting auth headers Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
7c6a992 to
0275a4d
Compare
Member
Review ChangesRebased onto Triage
Fixes
Tests
Notes
@popagruia — please review the changes and let me know if anything looks off. |
vishu-bh
pushed a commit
that referenced
this pull request
Feb 24, 2026
…sconfiguration (#3033) * x-vault-tokens is not propagated even if the system is misscomfigured Signed-off-by: popagruia <adrian.popa@ro.ibm.com> * fix(vault): strip X-Vault-Tokens header when system tag is missing and validate parsed token type - Strip vault header even when system cannot be determined from gateway metadata - Validate that parsed vault tokens are a JSON object (dict), not array/string/etc. - Remove misleading type annotation on orjson.loads result - Update test to verify header stripping on missing system tag Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * test: add coverage for no-system-tag and non-dict vault tokens paths Add two new test cases: - test_no_system_tag_no_vault_header_returns_empty: covers the branch where system key cannot be determined and no vault header is present - test_non_dict_json_vault_tokens_stripped: covers the isinstance guard ensuring non-dict JSON (e.g. arrays) strips the vault header without injecting auth headers Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: popagruia <adrian.popa@ro.ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: popagruia <adrian.popa@ro.ibm.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
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.
📝 Summary
Security fix for vault_plugin. When a MCP server is added with header passthrough for X-Vault-Tokens but system tag is none or missing the X-Vault-Tokens is send to server.
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)