Security: Zebra's address book can use all available memory #1873
Labels
A-rust
Area: Updates to Rust code
C-bug
Category: This is a bug
C-security
Category: Security issues
I-heavy
Problems with excessive memory, disk, or CPU usage
I-invalid-data
Zebra relies on invalid or untrusted data, or sends invalid data
I-slow
Problems with performance or responsiveness
I-unbounded-growth
Zebra keeps using resources, without any limit
Milestone
Motivation
Zebra does not limit the size of its address book. Since it accepts up to 1000 addresses from each peer address request, other nodes can fill up Zebra's memory with junk addresses.
Goals
Edge Cases
If we delete them immediately, we could get gossiped another copy of their address, and then retry them
We closed ticket Zebra should limit the number of addresses it uses from a single Addrs response, to avoid address book takeover #1869 because it wouldn't work with
zcashd
. Does deleting peers make address book takeover more likely? How can we prevent that?What happens if our local clock is a long way ahead, so all gossiped peers seem outdated to us?
Do we need to warn the user when all their peers get deleted? What if all their peers fail the
is_probably_reachable
check from Security: Avoid reconnecting to peers that are likely unreachable #3030?Suggestions
Choosing Peers
Zebra could retain peers in the following order, choosing the newest timestamps first within each category:
To implement this choice, Zebra could sort peers in recently live order, then reconnection (
Ord
trait) order, then delete the last peers in the list.AddressBook::update
is the only method that increases the address book size, so it is a good place to delete excess peers.Edge Cases
last_failed_time
, so that we don't risk losing all our peers after a network interruptionChoosing the Limit
Addrs
response (3000 peers * 1/3 peer response = 1000 limit)Alternatives
We could choose a random selection of
untrusted_last_seen
peers instead, but choosing the newest peers retains peers that are more likely to be available.Mitigations
This issue is mitigated by:
The text was updated successfully, but these errors were encountered: