8000 jsonrpc: add a batch size limit for RPC requests · Issue #2867 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jsonrpc: add a batch size limit for RPC requests #2867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cason opened this issue Apr 22, 2024 · 3 comments · Fixed by #2939
Closed

jsonrpc: add a batch size limit for RPC requests #2867

cason opened this issue Apr 22, 2024 · 3 comments · Fixed by #2939
Assignees
Milestone

Comments

@cason
Copy link
Contributor
cason commented Apr 22, 2024

Our homemade RPC implementation, jsonrpc, allows users to invoke multiple RCP methods using a single request, using batching. While this is not a problem, it may constitute a form of attack vector.

By investigating the code, batching is implemented by this method:

// first try to unmarshal the incoming request as an array of RPC requests

Not sure if this is the only method implementing batched requests, but this one was identified by running a test client.

We should consider adding a configuration parameter to limit the size/length of batched RPC requests submitted to Comet. To preserve backwards compatibility, the default value for this parameter can be 0, meaning no limit.

@cason
Copy link
Contributor Author
cason commented Apr 22, 2024

@ValarDragon
Copy link
Contributor

I'm very supportive of doing this w/ a config option!

@adizere adizere added this to the 2024-Q2 milestone Apr 22, 2024
@andynog andynog self-assigned this Apr 23, 2024
@andynog
Copy link
Contributor
andynog commented Apr 24, 2024

I'll look into this and try to push a PR in the next couple of days

@andynog andynog moved this from Todo to In Progress in CometBFT Apr 25, 2024
andynog added a commit that referenced this issue Apr 25, 2024
andynog added a commit that referenced this issue Apr 29, 2024
andynog added a commit that referenced this issue Apr 30, 2024
@andynog andynog moved this from In Progress to Ready for Review in CometBFT May 1, 2024
github-merge-queue bot pushed a commit that referenced this issue May 2, 2024
close: #2867 

Adds middleware for the JSONRPC server to enforce a configurable maximum
batch size for RPC requests.

---

#### PR checklist

- [ ] Tests written/updated
- [X] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in CometBFT May 2, 2024
mergify bot pushed a commit that referenced this issue May 2, 2024
close: #2867

Adds middleware for the JSONRPC server to enforce a configurable maximum
batch size for RPC requests.

---

#### PR checklist

- [ ] Tests written/updated
- [X] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit aa1caba)
mergify bot pushed a commit that referenced this issue May 2, 2024
close: #2867

Adds middleware for the JSONRPC server to enforce a configurable maximum
batch size for RPC requests.

---

#### PR checklist

- [ ] Tests written/updated
- [X] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit aa1caba)

# Conflicts:
#	docs/references/config/config.toml.md
andynog added a commit that referenced this issue May 3, 2024
…#2939) (#2980)

close: #2867 

Adds middleware for the JSONRPC server to enforce a configurable maximum
batch size for RPC requests.

---

#### PR checklist

- [ ] Tests written/updated
- [X] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #2939 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
github-merge-queue bot pushed a commit that referenced this issue May 6, 2024
Related to #2867 

Quick fix for a comment in the code added about a default value for a
config parameter.

During backport to `v0.38.x`, @melekes made a suggestion that the
default value in a comment was inaccurate. Instead of updating the
default value in the comment, I've decided to remove the comment about
the default value.

In my opinion, we should not have default value for config parameters in
comments if it's clear specified in the configuration docs what are the
default and possible values. Realized that having the default values in
comments is not beneficial and updating in the comment might be a not as
straightforward as changing it in code/config.


#### PR checklist

- [ ] ~~Tests written/updated~~
- [ ] ~~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
mergify bot pushed a commit that referenced this issue May 6, 2024
Related to #2867

Quick fix for a comment in the code added about a default value for a
config parameter.

During backport to `v0.38.x`, @melekes made a suggestion that the
default value in a comment was inaccurate. Instead of updating the
default value in the comment, I've decided to remove the comment about
the default value.

In my opinion, we should not have default value for config parameters in
comments if it's clear specified in the configuration docs what are the
default and possible values. Realized that having the default values in
comments is not beneficial and updating in the comment might be a not as
straightforward as changing it in code/config.

#### PR checklist

- [ ] ~~Tests written/updated~~
- [ ] ~~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit cac1fd8)
mergify bot pushed a commit that referenced this issue May 6, 2024
Related to #2867

Quick fix for a comment in the code added about a default value for a
config parameter.

During backport to `v0.38.x`, @melekes made a suggestion that the
default value in a comment was inaccurate. Instead of updating the
default value in the comment, I've decided to remove the comment about
the default value.

In my opinion, we should not have default value for config parameters in
comments if it's clear specified in the configuration docs what are the
default and possible values. Realized that having the default values in
comments is not beneficial and updating in the comment might be a not as
straightforward as changing it in code/config.

#### PR checklist

- [ ] ~~Tests written/updated~~
- [ ] ~~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit cac1fd8)

# Conflicts:
#	rpc/jsonrpc/server/http_server.go
melekes added a commit that referenced this issue May 6, 2024
Related to #2867 

Quick fix for a comment in the code added about a default value for a
config parameter.

During backport to `v0.38.x`, @melekes made a suggestion that the
default value in a comment was inaccurate. Instead of updating the
default value in the comment, I've decided to remove the comment about
the default value.

In my opinion, we should not have default value for config parameters in
comments if it's clear specified in the configuration docs what are the
default and possible values. Realized that having the default values in
comments is not beneficial and updating in the comment might be a not as
straightforward as changing it in code/config.


#### PR checklist

- [ ] ~~Tests written/updated~~
- [ ] ~~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #3000 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
melekes added a commit that referenced this issue May 6, 2024
Related to #2867 

Quick fix for a comment in the code added about a default value for a
config parameter.

During backport to `v0.38.x`, @melekes made a suggestion that the
default value in a comment was inaccurate. Instead of updating the
default value in the comment, I've decided to remove the comment about
the default value.

In my opinion, we should not have default value for config parameters in
comments if it's clear specified in the configuration docs what are the
default and possible values. Realized that having the default values in
comments is not beneficial and updating in the comment might be a not as
straightforward as changing it in code/config.


#### PR checklist

- [ ] ~~Tests written/updated~~
- [ ] ~~Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- [X] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #3000 done by
[Mergify](https://mergify.com).

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants
0