Diff
Modified: trunk/Source/WTF/ChangeLog (256015 => 256016)
--- trunk/Source/WTF/ChangeLog 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WTF/ChangeLog 2020-02-07 10:42:37 UTC (rev 256016)
@@ -1,3 +1,17 @@
+2020-02-07 youenn fablet <[email protected]>
+
+ Mandate UUID version 4 for mDNS ICE candidates
+ https://bugs.webkit.org/show_bug.cgi?id=207329
+
+ Reviewed by Alex Christensen.
+
+ Add a routine to validate version 4 UUID.
+
+ * wtf/UUID.cpp:
+ (WTF::isHexadecimalCharacter):
+ (WTF::isVersion4UUID):
+ * wtf/UUID.h:
+
2020-02-07 Yusuke Suzuki <[email protected]>
Unreviewed, revert 75% load-factor because of JetStream2/string-unpack-code-SP regression
Modified: trunk/Source/WTF/wtf/UUID.cpp (256015 => 256016)
--- trunk/Source/WTF/wtf/UUID.cpp 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WTF/wtf/UUID.cpp 2020-02-07 10:42:37 UTC (rev 256016)
@@ -81,4 +81,40 @@
#endif
}
+static inline bool isHexadecimalCharacter(UChar character)
+{
+ return (character >= '0' && character <= '9')
+ || (character >= 'a' && character <= 'f')
+ || (character >= 'A' && character <= 'F');
+}
+
+bool isVersion4UUID(StringView value)
+{
+ // Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx with hexadecimal digits for x and one of 8, 9, A, or B for y.
+ if (value.length() != 36)
+ return false;
+
+ for (auto cptr = 0; cptr < 36; ++cptr) {
+ if (cptr == 8 || cptr == 13 || cptr == 18 || cptr == 23) {
+ if (value[cptr] != '-')
+ return false;
+ continue;
+ }
+ if (cptr == 14) {
+ if (value[cptr] != '4')
+ return false;
+ continue;
+ }
+ if (cptr == 19) {
+ auto y = value[cptr];
+ if (y != '8' && y != '9' && y != 'a' && y != 'A' && y != 'b' && y != 'B')
+ return false;
+ continue;
+ }
+ if (!isHexadecimalCharacter(value[cptr]))
+ return false;
+ }
+ return true;
+}
+
} // namespace WTF
Modified: trunk/Source/WTF/wtf/UUID.h (256015 => 256016)
--- trunk/Source/WTF/wtf/UUID.h 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WTF/wtf/UUID.h 2020-02-07 10:42:37 UTC (rev 256016)
@@ -34,6 +34,8 @@
namespace WTF {
+class StringView;
+
// Creates a UUID that consists of 32 hexadecimal digits and returns its canonical form.
// The canonical form is displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
// The hexadecimal values "a" through "f" are output as lower case characters.
@@ -46,6 +48,7 @@
WTF_EXPORT_PRIVATE String createCanonicalUUIDString();
WTF_EXPORT_PRIVATE String bootSessionUUIDString();
+WTF_EXPORT_PRIVATE bool isVersion4UUID(StringView);
}
Modified: trunk/Source/WebCore/ChangeLog (256015 => 256016)
--- trunk/Source/WebCore/ChangeLog 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WebCore/ChangeLog 2020-02-07 10:42:37 UTC (rev 256016)
@@ -1,3 +1,17 @@
+2020-02-07 youenn fablet <[email protected]>
+
+ Mandate UUID version 4 for mDNS ICE candidates
+ https://bugs.webkit.org/show_bug.cgi?id=207329
+
+ Reviewed by Alex Christensen.
+
+ Ignore ICE candidates if they are mDNS but not UUID version 4.
+ Covered by existing tests relying on mDNS to do the connection.
+
+ * Modules/mediastream/PeerConnectionBackend.cpp:
+ (WebCore::shouldIgnoreCandidate):
+ (WebCore::PeerConnectionBackend::addIceCandidate):
+
2020-02-07 Tomoki Imai <[email protected]>
[OpenSSL] Implement WebCrypto APIs for AES-CBC, AES-CFB and AES-GCM
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (256015 => 256016)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2020-02-07 10:42:37 UTC (rev 256016)
@@ -46,6 +46,7 @@
#include "RTCRtpCapabilities.h"
#include "RTCTrackEvent.h"
#include "RuntimeEnabledFeatures.h"
+#include <wtf/UUID.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenateNumbers.h>
@@ -302,9 +303,8 @@
m_pendingTrackEvents.append(WTFMove(event));
}
-static String extractIPAddres(const String& sdp)
+static String extractIPAddress(const String& sdp)
{
- ASSERT(sdp.contains(" host "));
unsigned counter = 0;
for (auto item : StringView { sdp }.split(' ')) {
if (++counter == 5)
@@ -313,6 +313,19 @@
return { };
}
+static inline bool shouldIgnoreIceCandidate(const RTCIceCandidate& iceCandidate)
+{
+ auto address = extractIPAddress(iceCandidate.candidate());
+ if (!address.endsWithIgnoringASCIICase(".local"_s))
+ return false;
+
+ if (!WTF::isVersion4UUID(StringView { address }.substring(0, address.length() - 6))) {
+ RELEASE_LOG_ERROR(WebRTC, "mDNS candidate is not a Version 4 UUID");
+ return true;
+ }
+ return false;
+}
+
void PeerConnectionBackend::addIceCandidate(RTCIceCandidate* iceCandidate, DOMPromiseDeferred<void>&& promise)
{
ASSERT(!m_peerConnection.isClosed());
@@ -327,6 +340,12 @@
promise.reject(Exception { TypeError, "Trying to add a candidate that is missing both sdpMid and sdpMLineIndex"_s });
return;
}
+
+ if (shouldIgnoreIceCandidate(*iceCandidate)) {
+ promise.resolve();
+ return;
+ }
+
m_addIceCandidatePromise = WTF::makeUnique<DOMPromiseDeferred<void>>(WTFMove(promise));
doAddIceCandidate(*iceCandidate);
}
@@ -450,7 +469,7 @@
// FIXME: We might need to clear all pending candidates when setting again local description.
m_pendingICECandidates.append(PendingICECandidate { String { sdp }, WTFMove(mid), sdpMLineIndex, WTFMove(serverURL) });
if (RuntimeEnabledFeatures::sharedFeatures().webRTCMDNSICECandidatesEnabled()) {
- auto ipAddress = extractIPAddres(sdp);
+ auto ipAddress = extractIPAddress(sdp);
// We restrict to IPv4 candidates for now.
if (ipAddress.contains('.'))
registerMDNSName(ipAddress);
Modified: trunk/Source/WebKit/ChangeLog (256015 => 256016)
--- trunk/Source/WebKit/ChangeLog 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WebKit/ChangeLog 2020-02-07 10:42:37 UTC (rev 256016)
@@ -1,3 +1,14 @@
+2020-02-07 youenn fablet <[email protected]>
+
+ Mandate UUID version 4 for mDNS ICE candidates
+ https://bugs.webkit.org/show_bug.cgi?id=207329
+
+ Reviewed by Alex Christensen.
+
+ * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
+ (WebKit::NetworkMDNSRegister::registerMDNSName):
+ Remove the count at the end of the mDNS name to make it a fully version 4 UUID.
+
2020-02-07 Patrick Griffis <[email protected]>
[GTK][WPE] Add same-site cookie support
Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp (256015 => 256016)
--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp 2020-02-07 10:06:18 UTC (rev 256015)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp 2020-02-07 10:42:37 UTC (rev 256016)
@@ -126,7 +126,7 @@
} else
service = iterator->value;
- String name = makeString(createCanonicalUUIDString(), pendingRegistrationRequestCount, ".local");
+ String name = makeString(createCanonicalUUIDString(), ".local");
auto ip = inet_addr(ipAddress.utf8().data());