Repository navigation
Conversation
When REDIS_URL was configured without FERNET_KEY, _build_oauth_client_storage() returned the bare RedisStore instead of wrapping it with FernetEncryptionWrapper. Because FastMCP only applies its own encryption when client_storage is None, passing an unwrapped store caused OAuth state (including upstream access and refresh tokens in mcp-upstream-tokens) to be stored in Redis in plaintext. Fail fast at startup with ValueError when REDIS_URL is set without FERNET_KEY in HTTP mode, and remove the dead ImportError fallback branch since cryptography is a required dependency. Only construct OAuth client_storage in HTTP transport mode so STDIO usage is unaffected. Update Helm values (values.yaml, values-dev.example.yaml), Docker Compose deployment examples (docs/mcp/DEPLOYMENT_GUIDE.md, docs/web/docs/deployment.md), and src/rosetta-mcp-server/README.md to mark FERNET_KEY required whenever REDIS_URL is configured. Bump rosetta-mcp to 3.0.9 and the Helm chart to 0.4.8 (appVersion 3.0.9). Closes griddynamics#485 Signed-off-by: zooqueen <a@zoo.ngo>
This branch has not been deployed
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
When
REDIS_URLwas set withoutFERNET_KEY,_build_oauth_client_storage()insrc/rosetta-mcp-server/rosetta_mcp/server.pyreturned the bareRedisStore. Because FastMCP only applies its built-in encryption whenclient_storageisNone, passing an unwrappedRedisStoredisabled encryption and stored OAuth state—including users' upstreamaccess_tokenandrefresh_tokeninmcp-upstream-tokens—in plaintext in Redis without any error or warning.This PR enforces encryption at rest for Redis-backed OAuth storage:
_build_oauth_client_storage()now raisesValueErrorat startup when_REDIS_STOREis configured andFERNET_KEYis unset/empty, matching the fail-fast security-by-default pattern inbuild_oauth_provider().except ImportErrorfallback in_build_oauth_client_storage()(cryptography>=43.0.0is a required package dependency)._build_oauth_client_storage()only in HTTP transport mode (_CONFIG.transport == TRANSPORT_HTTP), keeping STDIO mode unaffected even ifREDIS_URLis present in the environment.values.yamlandvalues-dev.example.yamlto moveFERNET_KEYout of the optional section and dropoptional: truewhen Redis is configured.docs/mcp/DEPLOYMENT_GUIDE.md,docs/web/docs/deployment.md) andsrc/rosetta-mcp-server/README.mdto includeFERNET_KEYalongsideREDIS_URL.rosetta-mcpto3.0.9and the Helm chart to0.4.8(appVersion: "3.0.9") to stay in sync with CI release checks.src/rosetta-mcp-server/tests/test_oauth_storage.pycovering missing/invalidFERNET_KEY, encrypted-at-rest storage verification, HTTP startup failure/success, and STDIO startup isolation.AI assistance disclosure: This PR was drafted with AI coding assistance; all changes, security behavior, and test runs were reviewed and verified locally.
Closes #485
Type of change
src/rosetta-mcp-server,src/rosetta-cli,src/ims-mcp-server,src/rosettify,src/curiocity)docs/,*.md,docs/web/)Behavior impact
REDIS_URLset andFERNET_KEYunset started silently and persisted OAuth tokens in Redis in plaintext JSON.REDIS_URLset andFERNET_KEYunset fails fast at startup withValueErrorinstructing the operator to setFERNET_KEY. Deployments withoutREDIS_URLor running inSTDIOmode are unaffected.Migration path: Any existing HTTP deployment using
REDIS_URLwithoutFERNET_KEYmust generate and configureFERNET_KEY(python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())") before upgrading. Previously stored plaintext entries in Redis will be treated as cache misses on decryption (raise_on_decryption_error=False), prompting clients to re-authenticate cleanly.Validation
src/validate-types.sh: Pythonmypy --config-file mypy.inipassed (0 errors; JS/TS packages skipped becausenode_modulesnot installed).PYTHONPATH=src/rosetta-mcp-server ./venv/bin/pytest src/rosetta-mcp-server/tests/ -v: 398 passed (including 8 new tests intests/test_oauth_storage.py, 3 of which failed before the fix).PYTHONPATH=src/rosetta-cli ./venv/bin/pytest src/rosetta-cli/tests/ -q: 188 passed.python3 scripts/pre_commit.py --only verify-structure --only verify-crossrefs --only verify-hooks-content --only verify-counts --only verify-links: all passed.helm lint src/helm-charts/rosetta-mcp-serverandhelm template(default andvalues-dev.example.yaml): 0 errors;Chart.yamlappVersion(3.0.9) matchessrc/rosetta-mcp-server/pyproject.toml(3.0.9).python -m buildandtwine check dist/*insrc/rosetta-mcp-server: PASSED.Risk and rollback
rosetta-mcp-serverHTTP mode whenREDIS_URLis configured. Default chart deployments (no Redis) andvalues-prod.example.yaml(which already requiresFERNET_KEY) are unaffected. Any misconfigured deployment that previously stored plaintext OAuth tokens in Redis will now fail startup untilFERNET_KEYis provided.Checklist