Skip to content

Commit

Permalink
Obfuscate prflx raddr when using mdns
Browse files Browse the repository at this point in the history
BUG=chromium:1478690

Change-Id: I7a1caad7bbd2fc82507b61b59be71546494a304c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/319580
Reviewed-by: Harald Alvestrand <[email protected]>
Reviewed-by: Henrik Boström <[email protected]>
Commit-Queue: Philipp Hancke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#40724}
  • Loading branch information
fippo authored and WebRTC LUCI CQ committed Sep 8, 2023
1 parent 2d162c4 commit a8e3111
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion p2p/base/port_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,12 @@ Candidate PortAllocator::SanitizeCandidate(const Candidate& c) const {
// If the candidate filter doesn't allow reflexive addresses, empty TURN raddr
// to avoid reflexive address leakage.
bool filter_turn_related_address = !(candidate_filter_ & CF_REFLEXIVE);
// Sanitize related_address when using MDNS.
bool filter_prflx_related_address = MdnsObfuscationEnabled();
bool filter_related_address =
((c.type() == STUN_PORT_TYPE && filter_stun_related_address) ||
(c.type() == RELAY_PORT_TYPE && filter_turn_related_address));
(c.type() == RELAY_PORT_TYPE && filter_turn_related_address) ||
(c.type() == PRFLX_PORT_TYPE && filter_prflx_related_address));
return c.ToSanitizedCopy(use_hostname_address, filter_related_address);
}

Expand Down
15 changes: 15 additions & 0 deletions p2p/base/port_allocator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,21 @@ TEST_F(PortAllocatorTest, SanitizePrflxCandidateMdnsObfuscationEnabled) {
EXPECT_EQ("", output.address().ipaddr().ToString());
}

TEST_F(PortAllocatorTest,
SanitizePrflxCandidateMdnsObfuscationEnabledRelatedAddress) {
allocator_->SetMdnsObfuscationEnabledForTesting(true);
// Create the candidate from an IP literal. This populates the hostname.
cricket::Candidate input(1, "udp", rtc::SocketAddress(kIpv4Address, 443), 1,
"username", "password", cricket::PRFLX_PORT_TYPE, 1,
"foundation", 1, 1);

cricket::Candidate output = allocator_->SanitizeCandidate(input);
EXPECT_NE(kIpv4AddressWithPort, output.address().ToString());
EXPECT_EQ("", output.address().ipaddr().ToString());
EXPECT_NE(kIpv4AddressWithPort, output.related_address().ToString());
EXPECT_EQ("", output.related_address().ipaddr().ToString());
}

TEST_F(PortAllocatorTest, SanitizeIpv4NonLiteralMdnsObfuscationEnabled) {
// Create the candidate with an empty hostname.
allocator_->SetMdnsObfuscationEnabledForTesting(true);
Expand Down

0 comments on commit a8e3111

Please sign in to comment.