Changeset 201423 in webkit
- Timestamp:
- May 26, 2016, 11:19:30 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/security/insecure-geolocation-expected.txt (added)
-
LayoutTests/http/tests/security/insecure-geolocation.html (added)
-
LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt (added)
-
LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content.html (added)
-
LayoutTests/http/tests/security/mixedcontent-geolocation-expected.txt (added)
-
LayoutTests/http/tests/security/mixedcontent-geolocation.html (added)
-
LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html (modified) (1 diff)
-
LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/geolocation/Geolocation.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/geolocation/Geolocation.h (modified) (1 diff)
-
Source/WebCore/dom/SecurityContext.h (modified) (2 diffs)
-
Source/WebCore/loader/MixedContentChecker.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r201422 r201423 1 2016-05-26 Pranjal Jumde <pjumde@apple.com> 2 3 Sites served over insecure connections should not be allowed to use geolocation. 4 https://bugs.webkit.org/show_bug.cgi?id=157423 5 <rdar://problem/23751632> 6 7 Reviewed by Brent Fulgham. 8 9 * http/tests/security/geolocation-over-insecure-content.html: Added. 10 * http/tests/security/geolocation-over-mixed-content-block.html: Added. 11 * http/tests/security/geolocation-over-mixed-content.html: Added. 12 * http/tests/security/insecure-geolocation-expected.txt: Added. 13 * http/tests/security/insecure-geolocation.html: Added. 14 * http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt: Added. 15 * http/tests/security/mixedcontent-geolocation-block-insecure-content.html: Added. 16 * http/tests/security/mixedcontent-geolocation-expected.txt: Added. 17 * http/tests/security/mixedcontent-geolocation.html: Added. 18 * http/tests/security/sandboxed-iframe-geolocation-watchPosition.html: 19 iframe is loaded over secure connection to avoid geolocation failures 20 * http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html: 21 iframe is loaded over secure connection to avoid geolocation failures 22 1 23 2016-05-26 Brady Eidson <beidson@apple.com> 2 24 -
trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html
r195075 r201423 12 12 <body> 13 13 <p>Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a document in a sandboxed iframe.</p> 14 <iframe src=" resources/sandboxed-iframe-geolocation-getCurrentPosition.html" sandbox="allow-scripts" width="100%" height="300"></iframe>14 <iframe src="https://127.0.0.1:8443/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html" sandbox="allow-scripts" width="100%" height="300"></iframe> 15 15 </body> 16 16 </html> -
trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html
r195075 r201423 12 12 <body> 13 13 <p>Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a document in a sandboxed iframe.</p> 14 <iframe src=" resources/sandboxed-iframe-geolocation-watchPosition.html" sandbox="allow-scripts" width="100%" height="300"></iframe>14 <iframe src="https://127.0.0.1:8443/security/resources/sandboxed-iframe-geolocation-watchPosition.html" sandbox="allow-scripts" width="100%" height="300"></iframe> 15 15 </body> 16 16 </html> -
trunk/Source/WebCore/ChangeLog
r201422 r201423 1 2016-05-26 Pranjal Jumde <pjumde@apple.com> 2 3 Sites served over insecure connections should not be allowed to use geolocation. 4 https://bugs.webkit.org/show_bug.cgi?id=157423 5 <rdar://problem/23751632> 6 7 Reviewed by Brent Fulgham. 8 9 Tests: http/tests/security/insecure-geolocation.html 10 http/tests/security/mixedcontent-geolocation-block-insecure-content.html 11 http/tests/security/mixedcontent-geolocation.html 12 13 * Modules/geolocation/Geolocation.cpp: 14 (WebCore::logError): 15 Logs an error to the console if geolocation is blocked. 16 (WebCore::Geolocation::startRequest): 17 Access to Geolocation will be blocked if site is not secure. An error will be logged when access to Geolocation is blocked. 18 (WebCore::Geolocation::shouldBlockGeolocationRequests) 19 Returns true if the access to geolocation should be blocked. 20 * Modules/geolocation/Geolocation.h: 21 * dom/SecurityContext.h: 22 (WebCore::SecurityContext::foundMixedContent): 23 Returns true if insecure content was accessed over secure connection. 24 (WebCore::SecurityContext::setFoundMixedContent): 25 Sets m_foundMixedContent to true if insecure content is accessed over secure connection. 26 (WebCore::SecurityContext::geolocationAccessed): 27 Returns true if geolocation was accessed 28 (WebCore::SecurityContext::setGeolocationAccessed): 29 Sets m_geolocationAccessed to true if geolocation was accessed. 30 * loader/MixedContentChecker.cpp: 31 (WebCore::MixedContentChecker::canDisplayInsecureContent): 32 Insecure content will be blocked if geolocation was accessed by the page. Updates document to keep track of mixed content. 33 (WebCore::MixedContentChecker::canRunInsecureContent): 34 Insecure content will be blocked if geolocation was accessed by the page. Updates document to keep track of mixed content. 35 1 36 2016-05-26 Brady Eidson <beidson@apple.com> 2 37 -
trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp
r200895 r201423 44 44 #include <wtf/CurrentTime.h> 45 45 #include <wtf/Ref.h> 46 #include <wtf/text/StringBuilder.h> 46 47 47 48 namespace WebCore { … … 173 174 return true; 174 175 } 175 176 176 177 void Geolocation::suspend(ReasonForSuspension reason) 177 178 { … … 338 339 } 339 340 341 static void logError(const String& target, const bool isSecure, const bool isMixedContent, Document* document) 342 { 343 StringBuilder message; 344 message.append("[blocked] Access to geolocation was blocked over"); 345 346 if (!isSecure) 347 message.append(" insecure connection to "); 348 else if (isMixedContent) 349 message.append(" secure connection with mixed content to "); 350 else 351 return; 352 353 message.append(target); 354 message.append(".\n"); 355 document->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message.toString()); 356 } 357 358 bool Geolocation::shouldBlockGeolocationRequests() 359 { 360 bool isSecure = SecurityOrigin::isSecure(document()->url()); 361 bool hasMixedContent = document()->foundMixedContent(); 362 bool isLocalFile = document()->url().isLocalFile(); 363 if (securityOrigin()->canRequestGeolocation()) { 364 if (isLocalFile || (isSecure && !hasMixedContent)) 365 return false; 366 } 367 368 logError(securityOrigin()->toString(), isSecure, hasMixedContent, document()); 369 return true; 370 } 371 340 372 void Geolocation::startRequest(GeoNotifier* notifier) 341 373 { 342 if ( !securityOrigin()->canRequestGeolocation()) {374 if (shouldBlockGeolocationRequests()) { 343 375 notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, ASCIILiteral(originCannotRequestGeolocationErrorMessage))); 344 376 return; 345 377 } 378 document()->setGeolocationAccessed(); 346 379 347 380 // Check whether permissions have already been denied. Note that if this is the case, -
trunk/Source/WebCore/Modules/geolocation/Geolocation.h
r200691 r201423 73 73 void positionChanged(); 74 74 void setError(GeolocationError*); 75 bool shouldBlockGeolocationRequests(); 75 76 76 77 private: -
trunk/Source/WebCore/dom/SecurityContext.h
r200691 r201423 76 76 77 77 static SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensErrorMessage); 78 bool foundMixedContent() const { return m_foundMixedContent; } 79 void setFoundMixedContent() { m_foundMixedContent = true; } 80 bool geolocationAccessed() const { return m_geolocationAccessed; } 81 void setGeolocationAccessed() { m_geolocationAccessed = true; } 78 82 79 83 protected: … … 91 95 RefPtr<SecurityOriginPolicy> m_securityOriginPolicy; 92 96 std::unique_ptr<ContentSecurityPolicy> m_contentSecurityPolicy; 97 bool m_foundMixedContent { false }; 98 bool m_geolocationAccessed { false }; 93 99 }; 94 100 -
trunk/Source/WebCore/loader/MixedContentChecker.cpp
r200691 r201423 66 66 return true; 67 67 68 bool allowed = m_frame.settings().allowDisplayOfInsecureContent() || type == ContentType::ActiveCanWarn;68 bool allowed = (m_frame.settings().allowDisplayOfInsecureContent() || type == ContentType::ActiveCanWarn) && !m_frame.document()->geolocationAccessed(); 69 69 logWarning(allowed, "display", url); 70 70 71 if (allowed) 71 if (allowed) { 72 m_frame.document()->setFoundMixedContent(); 72 73 client().didDisplayInsecureContent(); 74 } 73 75 74 76 return allowed; … … 80 82 return true; 81 83 82 bool allowed = m_frame.settings().allowRunningOfInsecureContent() ;84 bool allowed = m_frame.settings().allowRunningOfInsecureContent() && !m_frame.document()->geolocationAccessed(); 83 85 logWarning(allowed, "run", url); 84 86 85 if (allowed) 87 if (allowed) { 88 m_frame.document()->setFoundMixedContent(); 86 89 client().didRunInsecureContent(securityOrigin, url); 90 } 87 91 88 92 return allowed;
Note:
See TracChangeset
for help on using the changeset viewer.