Skip to content

Commit

Permalink
Merge pull request #3207 from nspcc-dev/limit-rpc-signers
Browse files Browse the repository at this point in the history
rpcsrv/params: limit tx signers/witnesses
  • Loading branch information
roman-khimov committed Nov 20, 2023
2 parents 7fb077e + f6cb698 commit b5cf3f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/services/rpcsrv/params/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ func (p Param) GetSignersWithWitnesses() ([]transaction.Signer, []transaction.Wi
if err != nil {
return nil, nil, err
}
if len(hashes) > transaction.MaxAttributes {
return nil, nil, errors.New("too many signers")
}
signers := make([]transaction.Signer, len(hashes))
witnesses := make([]transaction.Witness, len(hashes))
// try to extract hashes first
Expand Down
9 changes: 9 additions & 0 deletions pkg/services/rpcsrv/params/param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,15 @@ func TestParamGetSigners(t *testing.T) {
require.True(t, u2.Equals(actual[1].Account))
})

t.Run("overflow", func(t *testing.T) {
var hashes = make([]util.Uint256, transaction.MaxAttributes+1)
msg, err := json.Marshal(hashes)
require.NoError(t, err)
p := Param{RawMessage: msg}
_, _, err = p.GetSignersWithWitnesses()
require.Error(t, err)
})

t.Run("bad format", func(t *testing.T) {
p := Param{RawMessage: []byte(`"not a signer"`)}
_, _, err := p.GetSignersWithWitnesses()
Expand Down

0 comments on commit b5cf3f5

Please sign in to comment.