fix(server): prevent duplicate request id attack on peer adapter#1474
fix(server): prevent duplicate request id attack on peer adapter#1474dinwwwh merged 1 commit intomiddleapi:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a potential vulnerability where duplicate request IDs could be exploited. It introduces a robust mechanism to identify and discard redundant requests, ensuring that each unique request is processed only once. This enhancement improves the server's resilience against malicious or erroneous duplicate message floods, thereby bolstering its stability and security. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA duplicate request guard is added to the server's message handler to prevent event iterator requests with the same ID from being processed multiple times. When a duplicate request arrives while one is already in flight, the handler returns early without creating a new controller, ensuring only one handler invocation per unique request ID. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses a potential duplicate request ID attack. The change in packages/standard-server-peer/src/server.ts prevents processing a request if another request with the same ID is already being handled. A new test case in packages/standard-server-peer/src/server.test.ts has been added to verify this behavior. The changes are correct and effectively resolve the issue.
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/experimental-pino
@orpc/experimental-publisher
@orpc/experimental-publisher-durable-object
@orpc/experimental-ratelimit
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fastify
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Pull request overview
Prevents a duplicate request-id attack against the standard server peer adapter that could leave earlier request AbortSignals un-aborted (causing event iterators to continue running after the client disconnects), as described in #1473.
Changes:
- Ignore duplicate
REQUESTmessages when an id is already active (clientControllers.has(id)). - Add a unit test asserting duplicate request messages are ignored while the first request is in flight.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/standard-server-peer/src/server.ts | Adds a guard to ignore duplicate request ids while the original request is still open. |
| packages/standard-server-peer/src/server.test.ts | Adds a test case intended to validate the duplicate-id guard behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Fixes #1473
Summary by CodeRabbit