Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: security report fix #206

Merged
merged 2 commits into from
May 22, 2023
Merged

fix: security report fix #206

merged 2 commits into from
May 22, 2023

Conversation

randyahx
Copy link
Contributor

Description

implemented changes according to the feedback in the security report

Rationale

issues such as overflow errors were raised

Example

none

Changes

please refer to the security report and the changed files

@@ -94,6 +94,9 @@ func EncodePackageHeader(header PackageHeader) []byte {
copy(packageHeader[PackageTypeLength:PackageTypeLength+TimestampLength], timestampBytes)

relayerFeeLength := len(header.RelayerFee.Bytes())
if relayerFeeLength > 32 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this.

It is ok if PackageHeader is wrong, as the protocol will handle this.

@@ -61,12 +61,13 @@ func ParseGrantKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress, msgType
// key is of format:
// <granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes>
kv.AssertKeyAtLeastLength(key, 2)
granterAddrLen := key[0]
// prevent granterAddrLen overflow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont change this, as we did not use this, let us keep consistent with cosmos-sdk.

@@ -82,6 +82,9 @@ func stripRowID(indexKey []byte, secondaryIndexKey interface{}) (RowID, error) {
switch v := secondaryIndexKey.(type) {
case []byte:
searchableKeyLen := indexKey[0]
if 1+int(searchableKeyLen) > len(indexKey) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont change this as we dont use it.

@@ -219,12 +219,22 @@ func ParseValidatorQueueKey(bz []byte) (time.Time, int64, error) {
return time.Time{}, 0, fmt.Errorf("invalid prefix; expected: %X, got: %X", ValidatorQueueKey, prefix)
}

if prefixL+8 > len(bz) {
return time.Time{}, 0, fmt.Errorf("timeBzl is out of bounds")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont use this, so no need to change it.

@@ -221,11 +221,18 @@ func ParseValidatorQueueKey(bz []byte) (time.Time, int64, error) {
}

timeBzL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8])
if prefixL+8+int(timeBzL) > len(bz) {
return time.Time{}, 0, fmt.Errorf("ts is out of bounds")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is here.

@randyahx randyahx requested a review from unclezoro May 22, 2023 06:18
@unclezoro unclezoro merged commit 9526d41 into develop May 22, 2023
unclezoro pushed a commit that referenced this pull request May 23, 2023
@unclezoro unclezoro deleted the randy/security-fix branch August 16, 2023 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants