-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=275224 rdar://125913679 Reviewed by Alex Christensen. This patch blocks connections to 0.0.0.0 and [::], as per RFC 6890 [0]. That spec says that these addresses may only be used as source addresses, not destinations. Requesting connections to either of these addresses is generally confusing, and likely not motivated by a good reason. Coincidentally, Blink seems to be making a similar change [1], and their use counters are showing below 0.001%. We can't exactly extrapolate from that, but it's a good indicator that this is safe. [0] https://www.rfc-editor.org/rfc/rfc6890#section-2.2.3 [1] https://groups.google.com/a/chromium.org/g/blink-dev/c/9uymCQNGVgw * LayoutTests/http/tests/media/video-error-all-zero-address-blocked-expected.txt: Added. * LayoutTests/http/tests/media/video-error-all-zero-address-blocked.html: Added. * LayoutTests/http/tests/security/block-iframe-to-all-zero-address-expected.txt: Added. * LayoutTests/http/tests/security/block-iframe-to-all-zero-address.html: Added. * LayoutTests/http/tests/security/block-popup-to-all-zero-address-expected.txt: Added. * LayoutTests/http/tests/security/block-popup-to-all-zero-address.html: Added. * LayoutTests/http/tests/security/redirect-BLOCKED-to-all-zero-address-expected.txt: Added. * LayoutTests/http/tests/security/redirect-BLOCKED-to-all-zero-address.html: Added. * LayoutTests/http/tests/websocket/connection-to-all-zero-address-blocked-expected.txt: Added. * LayoutTests/http/tests/websocket/connection-to-all-zero-address-blocked.html: Added. * LayoutTests/platform/wincairo/TestExpectations: * Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::iceServersFromConfiguration): * Source/WebCore/Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::connect): * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::isSafeToLoadURL const): * Source/WebCore/loader/DocumentLoader.cpp: (WebCore::DocumentLoader::willSendRequest): * Source/WebCore/loader/FrameLoader.cpp: (WebCore::FrameLoader::loadFrameRequest): (WebCore::FrameLoader::reportBlockedLoadFailed): * Source/WebCore/loader/ResourceLoader.cpp: (WebCore::ResourceLoader::init): * Source/WebCore/loader/SubframeLoader.cpp: (WebCore::FrameLoader::SubframeLoader::pluginIsLoadable): (WebCore::FrameLoader::SubframeLoader::loadSubframe): * Source/WebCore/loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * Source/WebCore/platform/network/DNS.cpp: (WebCore::isIPAddressDisallowed): * Source/WebCore/platform/network/DNS.h: * Source/WebCore/platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::ResourceHandle): * Source/WebKit/NetworkProcess/NetworkDataTask.cpp: (WebKit::NetworkDataTask::NetworkDataTask): Canonical link: https://commits.webkit.org/279835@main
- Loading branch information
Matthew Finkel
committed
Jun 7, 2024
1 parent
f6a08ca
commit e59cd4a
Showing
23 changed files
with
175 additions
and
11 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
LayoutTests/http/tests/media/video-error-all-zero-address-blocked-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONSOLE MESSAGE: Not allowed to use restricted network host "0.0.0.0": http://0.0.0.0:8000/media/resources/test.mp4 | ||
PASS Received error | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Test passes if loading video is not successful |
27 changes: 27 additions & 0 deletions
27
LayoutTests/http/tests/media/video-error-all-zero-address-blocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<p>Test passes if loading video is not successful</p> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpAsText(); | ||
} | ||
|
||
const video = document.createElement("video"); | ||
video.src = "http://0.0.0.0:8000/media/resources/test.mp4"; | ||
video.onerror = (e) => { | ||
testPassed("Received error"); | ||
testRunner.notifyDone(); | ||
} | ||
video.onopen = (e) => { | ||
testFailed("Received open"); | ||
testRunner.notifyDone(); | ||
} | ||
video.onmessage = (e) => { | ||
testFailed("Received message"); | ||
testRunner.notifyDone(); | ||
} | ||
</script> | ||
</body> |
3 changes: 3 additions & 0 deletions
3
LayoutTests/http/tests/security/block-iframe-to-all-zero-address-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONSOLE MESSAGE: Not allowed to use restricted network host "0.0.0.0": http://0.0.0.0:8000/security/resources/target.html | ||
|
||
This attempts to load an iframe from the all-zeroes address, which should be blocked. |
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/security/block-iframe-to-all-zero-address.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html> | ||
<body> | ||
<iframe src="http://0.0.0.0:8000/security/resources/target.html"></iframe></br> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
} | ||
</script> | ||
<p>This attempts to load an iframe from the all-zeroes address, which should be blocked.</p> | ||
</body> | ||
</html> |
2 changes: 2 additions & 0 deletions
2
LayoutTests/http/tests/security/block-popup-to-all-zero-address-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONSOLE MESSAGE: Not allowed to use restricted network host "0.0.0.0": http://0.0.0.0:8000/security/resources/target.html | ||
This attempts to load an iframe from the all-zeroes address, which should be blocked. |
12 changes: 12 additions & 0 deletions
12
LayoutTests/http/tests/security/block-popup-to-all-zero-address.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<html> | ||
<body> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
} | ||
window.open("http://0.0.0.0:8000/security/resources/target.html"); | ||
|
||
</script> | ||
<p>This attempts to load an iframe from the all-zeroes address, which should be blocked.</p> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
LayoutTests/http/tests/security/redirect-BLOCKED-to-all-zero-address-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONSOLE MESSAGE: Not allowed to use restricted network host "0.0.0.0": http://0.0.0.0:8000/security/resources/file-redirect-target.html | ||
|
||
This attempts to open a redirect link to the all-zeroes address, which should be blocked. |
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/security/redirect-BLOCKED-to-all-zero-address.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html> | ||
<body> | ||
<iframe src="http://127.0.0.1:8000/resources/redirect.py?url=http://0.0.0.0:8000/security/resources/file-redirect-target.html"></iframe></br> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
} | ||
</script> | ||
<p>This attempts to open a redirect link to the all-zeroes address, which should be blocked.</p> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
LayoutTests/http/tests/websocket/connection-to-all-zero-address-blocked-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONSOLE MESSAGE: WebSocket address 0.0.0.0 blocked | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
PASS Received error | ||
Test passes if websocket connection is not successful |
26 changes: 26 additions & 0 deletions
26
LayoutTests/http/tests/websocket/connection-to-all-zero-address-blocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<p>Test passes if websocket connection is not successful</p> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpAsText(); | ||
} | ||
|
||
const socket = new WebSocket("ws://0.0.0.0:8880"); | ||
socket.onerror = (e) => { | ||
testPassed("Received error"); | ||
testRunner.notifyDone(); | ||
} | ||
socket.onopen = (e) => { | ||
testFailed("Received open"); | ||
testRunner.notifyDone(); | ||
} | ||
socket.onmessage = (e) => { | ||
testFailed("Received message"); | ||
testRunner.notifyDone(); | ||
} | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters