Skip to content

Commit

Permalink
vm: reduce maximum stckitem size
Browse files Browse the repository at this point in the history
To prevent possible DoS. Port the neo-project/neo-vm#514,
close #3170.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
  • Loading branch information
AnnaShaleva committed Nov 2, 2023
1 parent 8ed6d97 commit b8a72c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/vm/stackitem/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
// MaxBigIntegerSizeBits is the maximum size of a BigInt item in bits.
MaxBigIntegerSizeBits = 32 * 8
// MaxSize is the maximum item size allowed in the VM.
MaxSize = 1024 * 1024
MaxSize = math.MaxUint16 * 2
// MaxComparableNumOfItems is the maximum number of items that can be compared for structs.
MaxComparableNumOfItems = MaxDeserialized
// MaxClonableNumOfItems is the maximum number of items that can be cloned in structs.
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/stackitem/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func TestToJSONWithTypesBadCases(t *testing.T) {
// until the necessary branch is covered #ididthemath.
arr := NewArray([]Item{
NewByteArray(bigBuf[:MaxSize/4*3-70]),
NewBigInteger(big.NewInt(1234)),
NewBigInteger(big.NewInt(123456)),
})
_, err := ToJSONWithTypes(arr)
require.ErrorIs(t, err, errTooBigSize)
Expand Down

0 comments on commit b8a72c8

Please sign in to comment.