CVE-2020-36568 (published 2022-12-27T22:15Z)

Unsanitized input in the query parser in github.com/revel/revel before v1.0.0 allows remote attackers to cause resource exhaustion via memory allocation.

CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)

Weakness information:
cwe_id: CWE-770
cwe_name: Allocation of Resources Without Limits or Throttling
description: The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
extended_description: Code frequently has to work with limited resources, so programmers must be careful to ensure that resources are not consumed too quickly, or too easily.  Without use of quotas, resource limits, or other protection mechanisms, it can be easy for an attacker to consume many resources by rapidly making many requests, or causing larger resources to be used than is needed. When too many resources are allocated, or if a single resource is too large, then it can prevent the code from working correctly, possibly leading to a denial of service.
         

Fix information:
repo_url: https://github.com/revel/revel
commit_details: repo_url: https://github.com/revel/revel
author: SYM01
author_date: 2019-03-09 11:21:44+08:00
msg: fix issue #1424
repository: repo_url: https://github.com/revel/revel
repo_name: revel/revel
description: A high productivity, full-stack web framework for the Go language.
repo_language: Go
owner: revel
file_changes: filename: binder.go
change_type: ModificationType.MODIFY
diff: @@ -213,6 +213,8 @@ func bindSlice(params *Params, name string, typ reflect.Type) reflect.Value {
 	numNoIndex := 0
 	sliceValues := []sliceValue{}
 
+	maxIndexBound := Config.IntDefault("params.max_index", 4096)
+
 	// Factor out the common slice logic (between form values and files).
 	processElement := func(key string, vals []string, files []*multipart.FileHeader) {
 		if !strings.HasPrefix(key, name+"[") {
@@ -229,6 +231,11 @@ func bindSlice(params *Params, name string, typ reflect.Type) reflect.Value {
 
 		// Handle the indexed case.
 		if index > -1 {
+			// Just ignore illegal index, fix issue #1424
+			if index > maxIndexBound {
+				binderLog.Error("Ignoring parameter for security reason", "index", index, "key", key)
+				return
+			}
 			if index > maxIndex {
 				maxIndex = index
 			}

programming_language: Go
filename: binder_test.go
change_type: ModificationType.MODIFY
diff: @@ -7,6 +7,7 @@ package revel
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/revel/config"
 	"io"
 	"io/ioutil"
 	"os"
@@ -98,6 +99,8 @@ var (
 		"invalidArr":                     {"xyz"},
 		"int8-overflow":                  {"1024"},
 		"uint8-overflow":                 {"1024"},
+		"arrDoS[2]":                      {"2"},
+		"arrDoS[65535]":                  {"65535"},
 	}
 
 	testDate     = time.Date(1982, time.July, 9, 0, 0, 0, 0, time.UTC)
@@ -168,6 +171,7 @@ var binderTestCases = map[string]interface{}{
 	"priv":           A{},
 	"int8-overflow":  int8(0),
 	"uint8-overflow": uint8(0),
+	"arrDoS":         []int{0, 0, 2},
 }
 
 // Types that files may be bound to, and a func that can read the content from
@@ -213,6 +217,12 @@ func TestBinder(t *testing.T) {
 	// Reuse the mvc_test.go multipart request to test the binder.
 	params := &Params{}
 	c := NewTestController(nil, getMultipartRequest())
+	if Config == nil {
+		Config = config.NewContext()
+		defer func() {
+			Config = nil
+		}()
+	}
 	ParseParams(params, NewRequest(c.Request.In))
 	params.Values = ParamTestValues
 

programming_language: Go