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

registerGroup function reverts when called with empty _name or _symbol #110

Open
hats-bug-reporter bot opened this issue Sep 16, 2024 · 1 comment
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@hats-bug-reporter
Copy link

Github username: --
Twitter username: --
Submission hash (on-chain): 0xf98ccef9fe87ce0039b45e0f99fc036ca44aec603eb8b9c098d35e788625192f
Severity: medium

Description:
Description
The registerGroup function reverts when called with empty _name or empty _symbol.

This is due to the below checks in the internal _registerGroup function:

if (!nameRegistry.isValidName(_name)) {
// Invalid group name.
// name must be ASCII alphanumeric and some special characters
revert CirclesInvalidString(_name, 0);
}
if (!nameRegistry.isValidSymbol(_symbol)) {
// Invalid group symbol.
// symbol must be ASCII alphanumeric and some special characters
revert CirclesInvalidString(_symbol, 1);
}

These functions return false due to nameBytes.length == 0

if (nameBytes.length > 32 || nameBytes.length == 0) return false; // Check length

Thus the internal _registerGroup function will revert with CirclesInvalidString error

This behaviour differs from the intended functionality of defaulting name to "Circles-<base58(short)Name> when _name is left empty.

// if name is left empty, it will default to default name "Circles-<base58(short)Name>"

This is a medium issue because it results in essential functionality of the contracts being temporarily unusable or inaccessible.

Recommendation
Replace the

 if (nameBytes.length > 32 || nameBytes.length == 0) return false; // Check length

condition in isValidName function with

 if (nameBytes.length > 32 return false; // Check length

There is no need to return false on nameBytes.length == 0

@hats-bug-reporter hats-bug-reporter bot added the bug Something isn't working label Sep 16, 2024
@benjaminbollen benjaminbollen added the invalid This doesn't seem right label Sep 16, 2024
@benjaminbollen
Copy link
Collaborator

Groups must have a valid custom name, organizations do not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant