-
Notifications
You must be signed in to change notification settings - Fork 4.5k
SECVULN-29092 DoS handled for kvs_endpoint.go #22916
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
Changes from 3 commits
635cda0
14f630c
9ebb5e0
db69840
b8fa0b4
6ed93a9
ebec61b
37727e3
3a0d477
870f498
1542fbf
91475c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,20 +234,30 @@ | |
| } | ||
|
|
||
| // Check the content-length | ||
| if req.ContentLength > int64(s.agent.config.KVMaxValueSize) { | ||
| maxSize := int64(s.agent.config.KVMaxValueSize) | ||
|
|
||
| switch { | ||
| case req.ContentLength < 0: | ||
| return nil, HTTPError{ | ||
| StatusCode: http.StatusBadRequest, | ||
| Reason: fmt.Sprintf("Request does not specify content-length .Expected content-length between 1 and %d .", maxSize), | ||
| } | ||
| case req.ContentLength > maxSize: | ||
| return nil, HTTPError{ | ||
| StatusCode: http.StatusRequestEntityTooLarge, | ||
| Reason: fmt.Sprintf("Request body(%d bytes) too large, max size: %d bytes. See %s.", | ||
| req.ContentLength, s.agent.config.KVMaxValueSize, "https://developer.hashicorp.com/docs/agent/config/config-files#kv_max_value_size"), | ||
| req.ContentLength, maxSize, "https://developer.hashicorp.com/docs/agent/config/config-files#kv_max_value_size"), | ||
| } | ||
| } | ||
|
|
||
| // Copy the value | ||
| buf := bytes.NewBuffer(nil) | ||
| if _, err := io.Copy(buf, req.Body); err != nil { | ||
| return nil, err | ||
| default: | ||
| // Copy the value | ||
| buf := bytes.NewBuffer(nil) | ||
| if _, err := io.Copy(buf, req.Body); err != nil { | ||
| return nil, err | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't add jira tickets to oss repo prs. |
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add unit tests for this. |
||
| applyReq.DirEnt.Value = buf.Bytes() | ||
|
Check failure on line 260 in agent/kvs_endpoint.go
|
||
|
|
||
| // Make the RPC | ||
| var out bool | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.