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

evoting: hashMap creates wrong hash #2508

Open
ineiti opened this issue Jun 27, 2023 · 0 comments
Open

evoting: hashMap creates wrong hash #2508

ineiti opened this issue Jun 27, 2023 · 0 comments
Assignees
Labels

Comments

@ineiti
Copy link
Member

ineiti commented Jun 27, 2023

This is another potential security error: the hashMap method here:

h.Write([]byte(m[k]))

creates a hash of a map, which is difficult in go, as the map doesn't have an explicit order in go. So it takes all keys, sorts them alphabetically, and then hashes the values.

But: it doesn't add the key to the values.

So the following two maps will have the same hash:

map1 := map[string]string{
    "first": 1,
    "second": 2,
}

map2 := map[string]string{
    "a": 1,
    "b": 2,
}

Fix: also add the key to the hash.

@ineiti ineiti self-assigned this Jun 27, 2023
@ineiti ineiti added the bug label Jun 27, 2023
ineiti added a commit that referenced this issue Jun 28, 2023
Added some security bugs found while adding the new functionalities.
They are here: #2507 #2508 #2509 #2510

Also added some comments and fixed some typos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant