Skip to content

Commit 597e7ba

Browse files
fippoWebRTC LUCI CQ
authored andcommitted
[M118] Obfuscate prflx raddr when using mdns
BUG=chromium:1478690 (cherry picked from commit a8e3111) 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-Original-Commit-Position: refs/heads/main@{#40724} Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/320580 Cr-Commit-Position: refs/branch-heads/5993@{#2} Cr-Branched-From: 5afcec0-refs/heads/main@{#40703}
1 parent 7349579 commit 597e7ba

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

p2p/base/port_allocator.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,12 @@ Candidate PortAllocator::SanitizeCandidate(const Candidate& c) const {
340340
// If the candidate filter doesn't allow reflexive addresses, empty TURN raddr
341341
// to avoid reflexive address leakage.
342342
bool filter_turn_related_address = !(candidate_filter_ & CF_REFLEXIVE);
343+
// Sanitize related_address when using MDNS.
344+
bool filter_prflx_related_address = MdnsObfuscationEnabled();
343345
bool filter_related_address =
344346
((c.type() == STUN_PORT_TYPE && filter_stun_related_address) ||
345-
(c.type() == RELAY_PORT_TYPE && filter_turn_related_address));
347+
(c.type() == RELAY_PORT_TYPE && filter_turn_related_address) ||
348+
(c.type() == PRFLX_PORT_TYPE && filter_prflx_related_address));
346349
return c.ToSanitizedCopy(use_hostname_address, filter_related_address);
347350
}
348351

p2p/base/port_allocator_unittest.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,21 @@ TEST_F(PortAllocatorTest, SanitizePrflxCandidateMdnsObfuscationEnabled) {
357357
EXPECT_EQ("", output.address().ipaddr().ToString());
358358
}
359359

360+
TEST_F(PortAllocatorTest,
361+
SanitizePrflxCandidateMdnsObfuscationEnabledRelatedAddress) {
362+
allocator_->SetMdnsObfuscationEnabledForTesting(true);
363+
// Create the candidate from an IP literal. This populates the hostname.
364+
cricket::Candidate input(1, "udp", rtc::SocketAddress(kIpv4Address, 443), 1,
365+
"username", "password", cricket::PRFLX_PORT_TYPE, 1,
366+
"foundation", 1, 1);
367+
368+
cricket::Candidate output = allocator_->SanitizeCandidate(input);
369+
EXPECT_NE(kIpv4AddressWithPort, output.address().ToString());
370+
EXPECT_EQ("", output.address().ipaddr().ToString());
371+
EXPECT_NE(kIpv4AddressWithPort, output.related_address().ToString());
372+
EXPECT_EQ("", output.related_address().ipaddr().ToString());
373+
}
374+
360375
TEST_F(PortAllocatorTest, SanitizeIpv4NonLiteralMdnsObfuscationEnabled) {
361376
// Create the candidate with an empty hostname.
362377
allocator_->SetMdnsObfuscationEnabledForTesting(true);

0 commit comments

Comments
 (0)