Headline
CVE-2023-27483: Merge pull request from GHSA-vfvj-3m3g-m532 · crossplane/crossplane-runtime@53508a9
crossplane-runtime is a set of go libraries used to build Kubernetes controllers in Crossplane and its related stacks. An out of memory panic vulnerability has been discovered in affected versions. Applications that use the Paved
type’s SetValue
method with user provided input without proper validation might use excessive amounts of memory and cause an out of memory panic. In the fieldpath package, the Paved.SetValue method sets a value on the Paved object according to the provided path, without any validation. This allows setting values in slices at any provided index, which grows the target array up to the requested index, the index is currently capped at max uint32 (4294967295) given how indexes are parsed, but that is still an unnecessarily large value. If callers are not validating paths’ indexes on their own, which most probably are not going to do, given that the input is parsed directly in the SetValue method, this could allow users to consume arbitrary amounts of memory. Applications that do not use the Paved
type’s SetValue
method are not affected. This issue has been addressed in versions 0.16.1 and 0.19.2. Users are advised to upgrade. Users unable to upgrade can parse and validate the path before passing it to the SetValue
method of the Paved
type, constraining the index size as deemed appropriate.
@@ -17,6 +17,7 @@ limitations under the License. package fieldpath
import ( “fmt” “testing”
“github.com/google/go-cmp/cmp” @@ -593,6 +594,7 @@ func TestSetValue(t *testing.T) { type args struct { path string value any opts []PavedOption } type want struct { object map[string]any @@ -737,6 +739,38 @@ func TestSetValue(t *testing.T) { }, }, }, "RejectsHighIndexes": { reason: "Paths having indexes above the maximum default value are rejected", data: []byte(`{"data":[“a”]}`), args: args{ path: fmt.Sprintf("data[%v]", MaxFieldPathIndex+1),
Check failure on line 746 in pkg/fieldpath/paved_test.go
** GitHub Actions / lint**
undeclared name: `MaxFieldPathIndex` (typecheck)
Check failure on line 746 in pkg/fieldpath/paved_test.go
** GitHub Actions / unit-tests**
undefined: MaxFieldPathIndex
value: "c", }, want: want{ object: map[string]any{ "data": []any{"a"}}, err: errors.Wrap(errors.Errorf("found index above max (%[1]v > %[2]v): data[%[1]v]", MaxFieldPathIndex+1, MaxFieldPathIndex), “invalid segments”),
Check failure on line 753 in pkg/fieldpath/paved_test.go
** GitHub Actions / lint**
undeclared name: `MaxFieldPathIndex` (typecheck)
Check failure on line 753 in pkg/fieldpath/paved_test.go
** GitHub Actions / unit-tests**
undefined: MaxFieldPathIndex
}, }, "NotRejectsHighIndexesIfNoDefaultOptions": { reason: "Paths having indexes above the maximum default value are not rejected if default disabled", data: []byte(`{"data":[“a”]}`), args: args{ path: fmt.Sprintf("data[%v]", MaxFieldPathIndex+1),
Check failure on line 760 in pkg/fieldpath/paved_test.go
** GitHub Actions / lint**
undeclared name: `MaxFieldPathIndex` (typecheck)
Check failure on line 760 in pkg/fieldpath/paved_test.go
** GitHub Actions / unit-tests**
undefined: MaxFieldPathIndex
value: "c", opts: []PavedOption{}, }, want: want{ object: map[string]any{ "data": func() []any { res := make([]any, MaxFieldPathIndex+2)
Check failure on line 767 in pkg/fieldpath/paved_test.go
** GitHub Actions / lint**
undeclared name: `MaxFieldPathIndex` (typecheck)
Check failure on line 767 in pkg/fieldpath/paved_test.go
** GitHub Actions / unit-tests**
undefined: MaxFieldPathIndex
res[0] = “a” res[MaxFieldPathIndex+1] = “c”
Check failure on line 769 in pkg/fieldpath/paved_test.go
** GitHub Actions / lint**
undeclared name: `MaxFieldPathIndex` (typecheck)
Check failure on line 769 in pkg/fieldpath/paved_test.go
** GitHub Actions / unit-tests**
undefined: MaxFieldPathIndex
return res }()}, }, }, "MapStringString": { reason: "A map of string to string should be converted to a map of string to any", data: []byte(`{"metadata":{}}`), @@ -817,7 +851,7 @@ func TestSetValue(t *testing.T) { t.Run(name, func(t *testing.T) { in := make(map[string]any) _ = json.Unmarshal(tc.data, &in) p := Pave(in) p := Pave(in, tc.args.opts…)
err := p.SetValue(tc.args.path, tc.args.value) if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != “” {
Related news
### Summary Fuzz testing on `crossplane/crossplane`, by Ada Logics and sponsored by the CNCF, identified input to a function in the `fieldpath` package that can cause an out of memory panic. Applications that use the `Paved` type's `SetValue` method with user provided input without proper validation might use excessive amounts of memory and cause an out of memory panic. ### Details In the `fieldpath` package, the `SetValue` method of the `Paved` type sets a value on the inner object according to the provided path, without validating it first. This allows setting values in slices at any specific index and the code will grow the target array up to the required size. The index is currently capped at max uint32 (4294967295) given how indexes are parsed, but that is still an unnecessarily large value. ### Workaround Users can parse and validate the path before passing it to the `SetValue` method of the `Paved` type, constraining the index size as deemed appropriate. ### Credits Disc...