Skip to content

Strengthen session hijacking prevention types and tests#4067

Merged
yrobla merged 1 commit intomainfrom
issue-3867-v3
Mar 10, 2026
Merged

Strengthen session hijacking prevention types and tests#4067
yrobla merged 1 commit intomainfrom
issue-3867-v3

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Mar 10, 2026

Summary

  • Change PreventSessionHijacking to accept sessiontypes.MultiSession directly instead of interface{}, enforcing the contract at compile time and removing the runtime type assertion
  • Update tests to call the decorated methods (CallTool, ReadResource, GetPrompt) rather than the internal validateCaller, verifying that validation is correctly integrated end-to-end
  • Remove TestConcurrentValidation as the decorator holds no mutable state, making a concurrency test unnecessary

Fixes #3867

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

Affected: pkg/vmcp/session/internal/security

File Change

Does this introduce a user-facing change?

Special notes for reviewers

@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Mar 10, 2026
@github-actions github-actions bot removed the size/XS Extra small PR: < 100 lines changed label Mar 10, 2026
@yrobla yrobla requested a review from Copilot March 10, 2026 08:48
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Mar 10, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b99f3c96f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Mar 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the session hijacking prevention wrapper to enforce the sessiontypes.MultiSession contract at compile time and updates tests to validate the behavior through the decorator’s public methods rather than its internal helper.

Changes:

  • Change PreventSessionHijacking to accept sessiontypes.MultiSession directly (removing the runtime type assertion).
  • Update edge-case tests to exercise CallTool, ReadResource, and GetPrompt end-to-end through the decorator.
  • Remove the concurrent validation unit test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/vmcp/session/internal/security/security.go Tightens the PreventSessionHijacking API to take MultiSession directly and removes the runtime type assertion logic.
pkg/vmcp/session/internal/security/hijack_prevention_test.go Adjusts mocks and rewrites validation edge-case tests to call decorated methods instead of validateCaller; removes concurrency test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Mar 10, 2026
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Mar 10, 2026
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Mar 10, 2026
@yrobla yrobla requested a review from Copilot March 10, 2026 09:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yrobla yrobla requested a review from Copilot March 10, 2026 09:13
@github-actions github-actions bot removed the size/S Small PR: 100-299 lines changed label Mar 10, 2026
@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Mar 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 10, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.53%. Comparing base (a2824e0) to head (0f3783b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4067      +/-   ##
==========================================
- Coverage   68.56%   68.53%   -0.03%     
==========================================
  Files         446      446              
  Lines       45574    45573       -1     
==========================================
- Hits        31246    31235      -11     
- Misses      11914    11926      +12     
+ Partials     2414     2412       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amirejaz
Copy link
Copy Markdown
Contributor

@yrobla Approved. Could you please check failing e2e tests. I re-ran one of those.

@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 10, 2026
- Change PreventSessionHijacking to accept sessiontypes.MultiSession
  directly instead of interface{}, enforcing the contract at compile
  time and removing the runtime type assertion
- Update tests to call the decorated methods (CallTool, ReadResource,
  GetPrompt) rather than the internal validateCaller, verifying that
  validation is correctly integrated end-to-end
- Remove TestConcurrentValidation as the decorator holds no mutable
  state, making a concurrency test unnecessary
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 10, 2026
@yrobla yrobla merged commit 9031587 into main Mar 10, 2026
57 of 58 checks passed
@yrobla yrobla deleted the issue-3867-v3 branch March 10, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vMCP] Implement session token hash binding (blocks Phase 2 production rollout)

4 participants