Skip to content

Protected orders are vulnerable to timing attacks #2119

@aftermath2

Description

@aftermath2

Describe the bug

Protected orders are vulnerable to timing attacks on their passwords because string comparisons in Python are done character by character and have a short circuiting behaviour.

if order.password is not None and order.password != password:

Making it easier to brute force the password since an attacker could analyze the time taken on different values and figure out the secret character by character. This is specially concerning if the password is short.

Even though guessing the password won't give the attacker access to the order or funds, it could allow him to impersonate the maker or simply displace him.

To prevent this, we should use hmac.compare_digest from the standard library, which always takes the same time to compare two strings, no matter their length.

See https://en.wikipedia.org/wiki/Timing_attack for further information on this kind of attack.

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't workingpythonPull requests that update Python code

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions