Skip to content

fix: bump MCP SDK/sample dependencies and harden log sanitization for control-character injection - #1382

Open
YasiruDEX wants to merge 3 commits into
wso2:mainfrom
YasiruDEX:fix/security-remediation-phase-2
Open

fix: bump MCP SDK/sample dependencies and harden log sanitization for control-character injection#1382
YasiruDEX wants to merge 3 commits into
wso2:mainfrom
YasiruDEX:fix/security-remediation-phase-2

Conversation

@YasiruDEX

@YasiruDEX YasiruDEX commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Purpose

Continues the security-remediation effort on this branch. Two issues addressed:

  1. agent-manager-observer and agent-manager-service were pinned to outdated versions of modelcontextprotocol/go-sdk and google/jsonschema-go, and the crewai/langgraph sample agents were pinned to older releases — all had newer patched versions available.
  2. _sanitize_for_log in the hotel-booking-agent sample only escaped \r/\n, leaving other ASCII control characters (including ESC, enabling terminal escape-sequence injection) unsanitized when untrusted user input is logged.

Resolves: N/A (no linked issue — add one if this maps to a tracked ticket)

Goals

  • Bring the MCP Go SDK and its transitive jsonschema-go dependency up to the latest patched release on both Go services.
  • Bump the crewai/crewai-tools and langgraph sample-agent pins to current releases (note: langgraph moves 0.5.0 → 1.2.9, a major version jump).
  • Harden _sanitize_for_log to strip all non-printable control characters, not just CR/LF, closing a log/terminal injection gap.
  • Add an explicit, justified nosec suppression for the "api_key": "gateway" placeholder in amp-evaluation's Groq client construction, which bandit's B105 (hardcoded password) rule flags as a false positive — the real credential is injected separately via default_headers, never through api_key.

Approach

  • go.mod/go.sum updated via go get -u for github.com/modelcontextprotocol/go-sdk (1.5.0 → 1.6.1) and github.com/google/jsonschema-go (0.4.2 → 0.4.3) in both agent-manager-observer and agent-manager-service.
  • requirements.txt pins bumped for crewai/crewai-tools (1.15.2 → 1.15.5) and langgraph (0.5.0 → 1.2.9) in the sample agents.
  • Added a compiled regex (_OTHER_CONTROL_CHARS_RE) matching the C0 control-character range plus DEL, applied after the existing CR/LF escaping in _sanitize_for_log (samples/hotel-booking-agent/agent/app.py).
  • Added an inline # nosec B105 comment with rationale directly on the return in libs/amp-evaluation/src/amp_evaluation/evaluators/base.py where the gateway placeholder api_key is constructed.

No UI changes — screenshot/GIF not applicable.

User stories

N/A — internal security hardening, not user-facing functionality.

Release note

Updated MCP SDK and related dependencies to their latest patched versions; hardened log sanitization to strip control characters from user-supplied input before logging.

Documentation

N/A — no user-facing behavior changed; dependency bumps and internal log-sanitization hardening only.

Training

N/A — no training content impact.

Certification

N/A — no certification-exam impact; internal dependency/security hardening only.

Marketing

N/A — no marketing impact.

Automation tests

  • Unit tests

    None. No test file exists for samples/hotel-booking-agent/agent/app.py, so _sanitize_for_log's new control-character stripping (added in c4ccb6ac) has no automated assertion behind it — verified manually only by code review.

  • Integration tests

    None specific to this bump. Manually ran the Go test suites post-bump: agent-manager-observer (go-sdk 1.6.1, jsonschema-go 0.4.3) passes in full — all 10 packages, fresh (non-cached) run, including mcp/tools which exercises the SDK directly. agent-manager-service's suite could not be fully verified in this environment — all packages except catalog and instrumentation (including its mcp/tools) fail on missing DB_HOST/DB_USER/DB_PASSWORD/DB_NAME/OPEN_CHOREO_BASE_URL env vars, a pre-existing local DB-setup gap, not a regression from the bump. The langgraph 1.2.9 bump in samples/hotel-booking-agent and the crewai bump in samples/crewai-agent have no test coverage at all — neither sample has a test suite.

Security checks

Samples

samples/crewai-agent and samples/hotel-booking-agent/agent had their dependency pins bumped; hotel-booking-agent/agent/app.py's log sanitization was hardened.

Related PRs

N/A

Migrations (if applicable)

N/A — dependency version bumps only, no schema or data migration.

Test environment

Local K3d Setup

Learning

The B105 bandit rule (hardcoded password) pattern-matches on string literals passed to api_key-shaped fields regardless of whether the value is a real secret — same class of false positive as SAST tools flagging req.SetBasicAuth(...) calls by call-site pattern rather than true taint analysis. Suppressing with a justified inline comment (rather than restructuring working code) is the appropriate fix when the underlying design is intentional and documented.

Summary by CodeRabbit

  • Bug Fixes
    • Improved log sanitization in the hotel booking sample to prevent untrusted control characters from polluting error output.
  • Maintenance
    • Updated supporting components used by agent services and sample applications for improved compatibility and reliability.
    • Refreshed the CrewAI and hotel booking sample integrations to align with newer releases.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@YasiruDEX, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d1f6940c-d4bc-4bbc-b36d-a09cd2a94596

📥 Commits

Reviewing files that changed from the base of the PR and between c4ccb6a and f0f05c9.

📒 Files selected for processing (1)
  • samples/hotel-booking-agent/agent/test_app.py
📝 Walkthrough

Walkthrough

Changes

Dependency updates

Layer / File(s) Summary
Dependency version updates
agent-manager-observer/go.mod, agent-manager-service/go.mod, samples/crewai-agent/requirements.txt, samples/hotel-booking-agent/agent/requirements.txt
Go SDK, JSON schema, CrewAI, CrewAI tools, and LangGraph versions were updated.

Groq gateway configuration

Layer / File(s) Summary
Groq gateway configuration formatting
libs/amp-evaluation/src/amp_evaluation/evaluators/base.py
The Groq gateway kwargs dictionary was reformatted and annotated with a security-scanner suppression; its values remain unchanged.

Log sanitization

Layer / File(s) Summary
Control-character sanitization
samples/hotel-booking-agent/agent/app.py
_sanitize_for_log now removes additional ASCII control characters while continuing to escape carriage returns and newlines.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: menakaj

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change set: dependency bumps plus log-sanitization hardening.
Description check ✅ Passed The description matches the template and covers purpose, goals, approach, tests, security, samples, and other required sections.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
samples/hotel-booking-agent/agent/app.py (1)

54-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for the sanitizer.

Cover CR/LF escaping, removal of C0 controls/DEL/ESC, and preservation of printable content. Based on the PR objective, no automated tests currently cover this updated sample-agent behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@samples/hotel-booking-agent/agent/app.py` around lines 54 - 67, Add
regression tests for _sanitize_for_log covering CR and LF escaping, removal of
C0 control characters, DEL, and ESC, while asserting printable content remains
unchanged. Place the tests with the existing sample-agent test suite and
preserve the sanitizer’s current behavior.
samples/crewai-agent/requirements.txt (1)

1-2: 🔒 Security & Privacy | 🔵 Trivial

Audit the resolved dependency tree before merging. crewai==1.15.5 pulls in chromadb directly; check whether the resolved chromadb release is in the affected range. Pillow and python-multipart are not direct dependencies of these pins.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@samples/crewai-agent/requirements.txt` around lines 1 - 2, Audit the resolved
dependency tree for the pinned crewai and crewai-tools requirements,
specifically determining which chromadb version is installed and whether it
falls within the affected range. Update the dependency pins or related
configuration only if needed to avoid the affected chromadb release, and do not
treat Pillow or python-multipart as direct dependencies.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@samples/crewai-agent/requirements.txt`:
- Around line 1-2: Audit the resolved dependency tree for the pinned crewai and
crewai-tools requirements, specifically determining which chromadb version is
installed and whether it falls within the affected range. Update the dependency
pins or related configuration only if needed to avoid the affected chromadb
release, and do not treat Pillow or python-multipart as direct dependencies.

In `@samples/hotel-booking-agent/agent/app.py`:
- Around line 54-67: Add regression tests for _sanitize_for_log covering CR and
LF escaping, removal of C0 control characters, DEL, and ESC, while asserting
printable content remains unchanged. Place the tests with the existing
sample-agent test suite and preserve the sanitizer’s current behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ddedfefc-8822-4844-b455-533dc95d9202

📥 Commits

Reviewing files that changed from the base of the PR and between 3234cc6 and c4ccb6a.

⛔ Files ignored due to path filters (2)
  • agent-manager-observer/go.sum is excluded by !**/*.sum
  • agent-manager-service/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • agent-manager-observer/go.mod
  • agent-manager-service/go.mod
  • libs/amp-evaluation/src/amp_evaluation/evaluators/base.py
  • samples/crewai-agent/requirements.txt
  • samples/hotel-booking-agent/agent/app.py
  • samples/hotel-booking-agent/agent/requirements.txt

@github-actions

Copy link
Copy Markdown

Dependency Validation Results

Dependency name: github.com/modelcontextprotocol/go-sdk
Version: v1.6.1 (was v1.5.0)
Allowed range: >=v1.2.0
Approved: ✅ Yes

Dependency name: github.com/modelcontextprotocol/go-sdk
Version: v1.6.1 (was v1.5.0)
Allowed range: >=v1.2.0
Approved: ✅ Yes

⚠️ Please verify the scope of the dependencies usage is necessary

@github-actions

Copy link
Copy Markdown

Dependency Validation Results

Dependency name: github.com/modelcontextprotocol/go-sdk
Version: v1.6.1 (was v1.5.0)
Allowed range: >=v1.2.0
Approved: ✅ Yes

Dependency name: github.com/modelcontextprotocol/go-sdk
Version: v1.6.1 (was v1.5.0)
Allowed range: >=v1.2.0
Approved: ✅ Yes

⚠️ Please verify the scope of the dependencies usage is necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant