fix/3811-pipe-validation-issue#3814
Conversation
0c187fd to
e4e8781
Compare
Review SummaryRebased onto Changes from the original PRThe original PR removed What this PR now does (2 commits)Commit 1 —
Commit 2 —
Verification
Closes #3811 |
crivetimihai
left a comment
There was a problem hiding this comment.
Reviewed, rebased, reworked, and verified. LGTM.
43e5140 to
d4307fc
Compare
079f939 to
aed20e2
Compare
There was a problem hiding this comment.
Thanks for tackling this. I found three issues:
-
Default-secret detection is now inconsistent with the new published JWT secret. This PR changes examples/defaults to
my-test-key-but-now-longer-than-32-bytes, but the runtime still only treatsmy-test-keyas the insecure default, so users can follow the new docs and bypass the existing warning/guard paths. See.env.example:22,mcpgateway/config.py:1087, andmcpgateway/main.py:1955. -
The helper/doc defaults now disagree with the actual app default, which can break standalone local flows. The application still defaults
JWT_SECRET_KEYtomy-test-key, but updated helpers/docs mint tokens with the new long secret, so no-envmake devstyle setups can generate invalid tokens. Seemcpgateway/config.py:285andsmoketest.py:236. -
The
|fix may not cover the full request path. The schema validators now allow single pipe characters in tool descriptions, but the broader dangerous-pattern middleware still appears to reject|in JSON bodies, so LogQL-style descriptions may still fail when validation middleware is enabled. Seemcpgateway/config.py:360,mcpgateway/config.py:368, andmcpgateway/middleware/validation_middleware.py:143.
16b153e to
0c6f44e
Compare
Follow-up: Review feedback addressed + JWT secret alignmentFeedback responsePoint 1 (guards inconsistent with new default) — Fixed in Point 2 (helper/doc defaults disagree with app default) — By design. Point 3 (validation middleware Additional changes since last review
Verification
|
Remove single pipe character ("|") from the default
TOOL_DESCRIPTION_FORBIDDEN_PATTERNS list. The pipe is a valid character in
LogQL (|=, |~), PromQL, regex patterns, and Markdown tables. The dangerous
shell OR operator "||" remains blocked.
Also aligns ToolUpdate.validate_description with ToolCreate by using the
configurable settings.tool_description_forbidden_patterns instead of a
hardcoded list, ensuring consistent behavior when the pattern list is
customized via environment variables.
Closes #3811
Signed-off-by: NAYANA.R <nayana.r7813@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
.env.example still used the old short `my-test-key` while docker-compose.yml and the E2E test helpers were updated to `my-test-key-but-now-longer-than-32-bytes` in #3716. Users who copied .env.example to .env got a secret mismatch that caused `make test-mcp-cli` to hang. See #3889 for the remaining files that need the same update. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
PR #3716 updated docker-compose.yml and mcp_test_helpers.py to use `my-test-key-but-now-longer-than-32-bytes` (meeting the 32-byte minimum for HS256 per RFC 7518 §3.2) but missed ~70 other files that still hardcoded the old `my-test-key`. This caused test failures (make test-mcp-cli hangs, load tests fail auth) when .env is derived from .env.example. Updated: - All docker-compose variant files (debug, embedded, performance, verbose) - All E2E and load test defaults - All scripts and smoketests - Helm chart values, schema, and docs - Makefile targets - All documentation examples - Added long key to validate_env.py weak_jwt list Not changed (intentionally): - mcpgateway/config.py:286 — Python config default (source of truth for standalone `make dev`) - mcpgateway/config.py:888 — already lists both keys in weak_secrets - mcpgateway/config.py:1088, main.py:1955,2040 — guards checking for the default value - tests/unit/test_main_helpers_extra.py:55 — test that mocks the default Closes #3889 Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
The secure_secrets flag and critical-issues check only matched the short `my-test-key` default. Users running with the docker-compose default `my-test-key-but-now-longer-than-32-bytes` would bypass the security warning and the `secure_secrets: false` status flag. - config.py get_security_status(): `!=` → `not in (short, long)` - main.py validate_security_configuration(): same - main.py security recommendations log: same - validate_env.py already had both (updated in prior commit) - config.py:888 weak_secrets already had both Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
0c6f44e to
d5582d2
Compare
Pre-commit detect-secrets hook requires line numbers to match. The linter/formatter commit shifted lines in db_util.py. All entries remain is_secret=false (confirmed false positives). Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
The longer JWT default triggers IBM detect-secrets "Secret Keyword" detection on 7 lines that are all test/dev defaults. Added `pragma: allowlist secret` inline comments. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
dima-zakharov
left a comment
There was a problem hiding this comment.
The default key optimization is possible (extract key from .env) but should work as is as well.
Pre-commit detect-secrets hook removed entries that are now covered by inline `pragma: allowlist secret` comments, and adjusted line numbers. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
890d3c2 to
d9ab152
Compare
|
Merged with admin override for this issue. |
Signed-off-by: NAYANA.R nayana.r7813@gmail.com
closes #3811
💡 Fix Description
Fixes false-positive validation that rejected tool descriptions containing the pipe (
|) character.Problem
The validation logic blocked "|" as an unsafe character, causing legitimate tool descriptions (e.g., LogQL queries like
{app="foo"} |= "error") to fail.This prevented critical tools such as
query_loki_logsfrom being registered.Solution
Removed "|" from the forbidden patterns list, while keeping "||" to block shell OR injection.
Changes
Testing
|=) succeeds&&are still blockedImpact
🧪 Verification
make lintmake test📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)