Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.22.0-rc2(October 16, 2025)

SECURITY:

* security: Fix Consul's KV endpoint is vulnerable to denial of service address CVE-2025-11374 [[GH-22916](https://github.com/hashicorp/consul/pull/22916)]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not where we add changelog.


## 1.22.0-rc1 (September 30, 2025)

SECURITY:
Expand Down
23 changes: 16 additions & 7 deletions agent/kvs_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,29 @@
}

// Check the content-length
if req.ContentLength > int64(s.agent.config.KVMaxValueSize) {
maxSize := int64(s.agent.config.KVMaxValueSize)

switch {
case req.ContentLength <= 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if contentlength is omitted. If omitted, raise error

Copy link
Collaborator Author

@Manishakumari-hc Manishakumari-hc Oct 13, 2025

Choose a reason for hiding this comment

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

In the case of no content-length it is taken as content-lenth=-1 .So it is handled here @sanikachavan5

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"),
}
default:
// Copy the value
buf := bytes.NewBuffer(nil)
if _, err := io.Copy(buf, req.Body); err != nil {
return nil, err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't add jira tickets to oss repo prs.


Copy link
Contributor

Choose a reason for hiding this comment

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

Please add unit tests for this.

// Copy the value
buf := bytes.NewBuffer(nil)
if _, err := io.Copy(buf, req.Body); err != nil {
return nil, err
}
applyReq.DirEnt.Value = buf.Bytes()

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / build-386

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / dev-build / build

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / dev-build / build

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / integration-test-with-deployer

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / build-amd64

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / goldenfile-check

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint-enums

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint-enums

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint-enums

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint-enums

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint-enums

undefined: buf

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint / lint

undefined: buf) (typecheck)

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / lint-32bit / lint

undefined: buf (typecheck)

Check failure on line 259 in agent/kvs_endpoint.go

View workflow job for this annotation

GitHub Actions / build-arm

undefined: buf

// Make the RPC
var out bool
Expand Down
1 change: 1 addition & 0 deletions agent/kvs_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
for _, key := range keys {
buf := bytes.NewBuffer([]byte("test"))
Copy link

@santoshpulluri santoshpulluri Oct 14, 2025

Choose a reason for hiding this comment

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

Please ensure test cases are covered for all the scenarios (basically 3 switch cases as well as default case.)

req, _ := http.NewRequest("PUT", "/v1/kv/"+key, buf)
req.ContentLength = int64(buf.Len())
resp := httptest.NewRecorder()
obj, err := a.srv.KVSEndpoint(resp, req)
if err != nil {
Expand Down
Loading