Repository navigation
Description
Provide environment information
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1 Pro
Memory: 86.84 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.20.3 - ~/.nvm/versions/node/v18.20.3/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v18.20.3/bin/npm
Browsers:
Chrome: 126.0.6478.63
Edge: 126.0.2592.68
Safari: 16.0
npmPackages:
@tanstack/react-query: ^4.36.1 => 4.36.1
@trpc/client: 10.45.0 => 10.45.0
@trpc/next: 10.45.0 => 10.45.0
@trpc/react-query: 10.45.0 => 10.45.0
@trpc/server: 10.45.0 => 10.45.0
next: ^14.2.3 => 14.2.3
react: ^18.2.0 => 18.2.0
typescript: ^5.2.2 => 5.2.2
Describe the bug
Batching uses , to separate different TRPC calls, and the size of the batch is limited to the header size. A payload could be crafted to just pass in a string of commas ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, which could be in the
This can potentially lead to multiple 404s being returned for a single call. I would expect to have some sort of batch limiting that is enforced on the server side, but currently, the documentation limits it to the client side.
Link to reproduction
any trpc with batch enabled
To reproduce
eg, for the request
curl --request GET \
--url '<url>/api/trpc/example.procedureName,,,,,,,,,,,,,,,,,,,,,,,?batch=1&input=<input that works for the first procedure>'
we get a return response
[
{
"result": {
"data": {
<valid response for the first procedure call>
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
},
{
"error": {
"json": {
"message": "No \"query\"-procedure on path \"\"",
"code": -32004,
"data": {
"code": "NOT_FOUND",
"httpStatus": 404,
"path": "",
"zodError": null
}
}
}
}
]
Additional information
No response
👨👧👦 Contributing
- 🙋♂️ Yes, I'd be down to file a PR fixing this bug!
Activity
[-]bug: [/-][+]bug: Improper server side max batch size handling[/+]KATT commentedon Jun 24, 2024
Your
createContextreceives aninfo-object with the batch calls, you can implement logic about that thereKATT commentedon Jun 24, 2024
KATT commentedon Jun 24, 2024
Feel free to make a PR to the documentation.
KATT commentedon Jun 26, 2024
Closing this. Feel free to open a PR to the documentation or a more specific feature request.
There's no bug AFAICT, this should be handled in
createContext()kishore03109 commentedon Jun 27, 2024
Hey @KATT, I am not sure if I misunderstood this.
Following the docs, one can create a context as such
This opts it typed to a
CreateNextContextOptions, which only hasreqandres. When inspecting the object at runtime, I also could not find the keyinfoon theoptsobject.I understand there is no documentation to refer to regarding limiting the batch size at the server side. Where can I refer to get more info of getting the
infofrom theoptobject?KATT commentedon Jun 27, 2024
Upgrade to v11 where we have that info property, we won't do any non-critical security issues on the v10 branch
trpc/packages/server/src/adapters/node-http/types.ts
Lines 94 to 98 in a637664
KATT commentedon Jun 27, 2024
The main thing you need to do to upgrade
onLoadingwithonPendingtransformerhttps://trpc.io/docs/migrate-from-v10-to-v11#transformers-are-moved-to-links-breakingkishore03109 commentedon Jun 28, 2024
Hi @KATT, thanks for the timely response!
I do differ in opinion on this being a non-critical security issue. When this is run in a dockerised environment, using just one api call but spamming the requests within just one batch, I was able to observe some level of DOS within the service.
The below seems to fix this in v10.
Would this be something that you would consider fixing in v10?
[Outside the scope of this bug]
Noticed that the v11 branch is still in beta, am wondering if there are plans to release the non-beta branch soon. It seems like some of the libraries that we are using are expecting the stable branch to be in order to release support for this.
github-actions commentedon Jun 29, 2024
This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.