Merge pull request #3207 from nspcc-dev/limit-rpc-signers

rpcsrv/params: limit tx signers/witnesses
This commit is contained in:
Roman Khimov 2023-11-20 16:29:42 +03:00 committed by GitHub
commit b5cf3f592f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -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

View file

@ -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()