Changeset 19952 in webkit
- Timestamp:
- Mar 2, 2007, 6:18:43 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 20 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r19951 r19952 1 2007-03-02 Kevin McCullough <kmccullough@apple.com> 2 3 Reviewed by Geoff. 4 5 - rdar://problem/4922454 6 - This fixes a security issue by making remote referrers not able to access local 7 resources, unless they register their schemes to be treated as local. The result is 8 that those schemes can access local resources and cannot be accessed by remote 9 referrers. 10 Because this behavior is new a link-on-or-after check is made to determine if the 11 app should use the older, less safe, behavior. 12 13 * fast/loader/local-CSS-from-local-expected.txt: Added. 14 * fast/loader/local-CSS-from-local.html: Added. 15 * fast/loader/local-JavaScript-from-local-expected.txt: Added. 16 * fast/loader/local-JavaScript-from-local.html: Added. 17 * fast/loader/local-iFrame-source-from-local-expected.txt: Added. 18 * fast/loader/local-iFrame-source-from-local.html: Added. 19 * fast/loader/local-image-from-local-expected.txt: Added. 20 * fast/loader/local-image-from-local.html: Added. 21 * http/tests/security/local-CSS-from-remote-expected.txt: Added. 22 * http/tests/security/local-CSS-from-remote.html: Added. 23 * http/tests/security/local-JavaScript-from-remote-expected.txt: Added. 24 * http/tests/security/local-JavaScript-from-remote.html: Added. 25 * http/tests/security/local-iFrame-from-remote-expected.txt: Added. 26 * http/tests/security/local-iFrame-from-remote.html: Added. 27 * http/tests/security/local-image-from-remote-expected.txt: Added. 28 * http/tests/security/local-image-from-remote.html: Added. 29 * http/tests/security/resources/compass.jpg: Added. 30 * http/tests/security/resources/cssStyle.css: Added. 31 * http/tests/security/resources/localPage.html: Added. 32 * http/tests/security/resources/localScript.js: Added. 33 1 34 2007-03-02 Justin Garcia <justin.garcia@apple.com> 2 35 -
trunk/WebCore/ChangeLog
r19951 r19952 1 2007-03-02 Kevin McCullough <kmccullough@apple.com> 2 3 Reviewed by Geoff. 4 5 - rdar://problem/4922454 6 - This fixes a security issue by making remote referrers not able to access local 7 resources, unless they register their schemes to be treated as local. The result is 8 that those schemes can access local resources and cannot be accessed by remote 9 referrers. 10 Because this behavior is new a link-on-or-after check is made to determine if the 11 app should use the older, less safe, behavior. 12 13 * WebCore.exp: added exported functions 14 * bindings/objc/DOM.mm: consolodated function to base class 15 (-[DOMElement image]): 16 (-[DOMElement _imageTIFFRepresentation]): 17 * dom/Document.cpp: Cache the document's ability to load local resources. 18 (WebCore::Document::Document): 19 (WebCore::Document::setURL): 20 (WebCore::Document::shouldBeAllowedToLoadLocalResources): 21 (WebCore::Document::stylesheetLoaded): 22 * dom/Document.h: Cache the docuent's ability to load local resources. 23 (WebCore::Document::getPendingSheet): 24 (WebCore::Document::isAllowedToLoadLocalResources): 25 * html/HTMLImageLoader.cpp: Moved functionality into base class. 26 (WebCore::HTMLImageLoader::updateFromElement): 27 (WebCore::HTMLImageLoader::dispatchLoadEvent): 28 * html/HTMLLinkElement.cpp: Handles null returns correctly now. 29 * html/HTMLTokenizer.cpp: Moved functionality into base class. 30 (WebCore::HTMLTokenizer::notifyFinished): 31 * ksvg2/misc/SVGImageLoader.cpp: Moved functionality into base class. 32 (WebCore::SVGImageLoader::dispatchLoadEvent): 33 * loader/Cache.cpp: Checks if the cached resource can be loaded. 34 (WebCore::Cache::requestResource): 35 * loader/CachedCSSStyleSheet.cpp: Moved functionality into base class. 36 (WebCore::CachedCSSStyleSheet::ref): 37 (WebCore::CachedCSSStyleSheet::error): 38 * loader/CachedImage.cpp: Moved functionality into base class. 39 (WebCore::CachedImage::CachedImage): 40 * loader/CachedImage.h: Moved functionality into base class. 41 (WebCore::CachedImage::canRender): 42 * loader/CachedResource.cpp: Cache if the CachedResource should be treated as local 43 (WebCore::CachedResource::CachedResource): 44 * loader/CachedResource.h: Moved functionality into base class. 45 (WebCore::CachedResource::errorOccurred): 46 (WebCore::CachedResource::shouldTreatAsLocal): 47 * loader/CachedScript.cpp: Moved functionality into base class. 48 (WebCore::CachedScript::CachedScript): 49 * loader/CachedScript.h: Moved functionality into base class. 50 (WebCore::CachedScript::schedule): 51 * loader/CachedXBLDocument.cpp: Moved functionality into base class. 52 (WebCore::CachedXBLDocument::error): 53 * loader/CachedXSLStyleSheet.cpp: Moved functionality into base class. 54 (WebCore::CachedXSLStyleSheet::error): 55 * loader/FrameLoader.cpp: See comments for each function below. 56 (WebCore::FrameLoader::loadSubframe): Use new canLoad. 57 (WebCore::FrameLoader::restrictAccessToLocal): return value of linked-on-or-after check. 58 (WebCore::FrameLoader::setRestrictAccessToLocal): set value for linked-on-or-after check. 59 (WebCore::localSchemes): Return set of schemes that are to be treated as local. 60 (WebCore::FrameLoader::loadPlugin): Use new canLoad. 61 (WebCore::FrameLoader::canLoad): Now multiple functions that each do the same work but some can take advantage of the cached values, if they were computed previously. 62 (WebCore::FrameLoader::shouldHideReferrer): Extracted out the logic to determine if the referrer should be hidden so it is only calculated when needed. 63 (WebCore::FrameLoader::loadResourceSynchronously): No longer calls canLoad to get hideReferrer info. 64 (WebCore::FrameLoader::registerSchemeAsLocal): Functionality to register a scheme to be treated as local. 65 (WebCore::FrameLoader::treatURLAsLocal): Given a URL this function determines if it should be treated as local. 66 * loader/FrameLoader.h: Declared functions for this security fix. See above. 67 * loader/MainResourceLoader.cpp: Optized order of bools to regain performance. 68 (WebCore::MainResourceLoader::continueAfterContentPolicy): 69 * loader/SubresourceLoader.cpp: Now restricts remote from loading local resources. 70 (WebCore::SubresourceLoader::create): 71 * page/EventHandler.cpp: Moved functionality into base class. 72 (WebCore::selectCursor): 73 * platform/KURL.cpp: KURLs need to check all the registered schemes now. 74 (WebCore::KURL::isLocalFile): 75 * rendering/HitTestResult.cpp: Moved functionality into base class. 76 (WebCore::HitTestResult::image): 77 * rendering/RenderImage.cpp: Moved functionality into base class. 78 (WebCore::RenderImage::setCachedImage): 79 (WebCore::RenderImage::imageChanged): 80 (WebCore::RenderImage::paint): 81 (WebCore::RenderImage::layout): 82 (WebCore::RenderImage::calcAspectRatioWidth): 83 (WebCore::RenderImage::calcAspectRatioHeight): 84 * rendering/RenderImage.h: Moved functionality into base class. 85 (WebCore::RenderImage::errorOccurred): 86 * rendering/RenderListItem.cpp: Moved functionality into base class. 87 (WebCore::RenderListItem::setStyle): 88 * rendering/RenderListMarker.cpp: Moved functionality into base class. 89 (WebCore::RenderListMarker::isImage): 90 * xml/xmlhttprequest.cpp: Check doc's cached value instead of determining independently. 91 (WebCore::XMLHttpRequest::urlMatchesDocumentDomain): 92 1 93 2007-03-02 Justin Garcia <justin.garcia@apple.com> 2 94 -
trunk/WebCore/WebCore.exp
r19921 r19952 146 146 __ZN7WebCore11FrameLoader16detachFromParentEv 147 147 __ZN7WebCore11FrameLoader18currentHistoryItemEv 148 __ZN7WebCore11FrameLoader18shouldHideReferrerERKNS_4KURLERKNS_6StringE 148 149 __ZN7WebCore11FrameLoader20continueLoadWithDataEPNS_12SharedBufferERKNS_6StringES5_RKNS_4KURLE 149 150 __ZN7WebCore11FrameLoader21addPlugInStreamLoaderEPNS_14ResourceLoaderE 151 __ZN7WebCore11FrameLoader21registerSchemeAsLocalERKNS_6StringE 150 152 __ZN7WebCore11FrameLoader21setCurrentHistoryItemEN3WTF10PassRefPtrINS_11HistoryItemEEE 151 153 __ZN7WebCore11FrameLoader22setPreviousHistoryItemEN3WTF10PassRefPtrINS_11HistoryItemEEE … … 153 155 __ZN7WebCore11FrameLoader23timeOfLastCompletedLoadEv 154 156 __ZN7WebCore11FrameLoader24removePlugInStreamLoaderEPNS_14ResourceLoaderE 157 __ZN7WebCore11FrameLoader24setRestrictAccessToLocalEb 155 158 __ZN7WebCore11FrameLoader25provisionalDocumentLoaderEv 156 159 __ZN7WebCore11FrameLoader25setProvisionalHistoryItemEN3WTF10PassRefPtrINS_11HistoryItemEEE … … 167 170 __ZN7WebCore11FrameLoader5clearEb 168 171 __ZN7WebCore11FrameLoader6reloadEv 169 __ZN7WebCore11FrameLoader7canLoadERKNS_4KURLE RKNS_6StringERb172 __ZN7WebCore11FrameLoader7canLoadERKNS_4KURLEPKNS_8DocumentE 170 173 __ZN7WebCore11HistoryItem12addChildItemEN3WTF10PassRefPtrIS0_EE 171 174 __ZN7WebCore11HistoryItem12setURLStringERKNS_6StringE -
trunk/WebCore/bindings/objc/DOM.mm
r19855 r19952 492 492 if (renderer && renderer->isImage()) { 493 493 WebCore::RenderImage* img = static_cast<WebCore::RenderImage*>(renderer); 494 if (img->cachedImage() && !img->cachedImage()-> isErrorImage())494 if (img->cachedImage() && !img->cachedImage()->errorOccurred()) 495 495 return img->cachedImage()->image()->getNSImage(); 496 496 } … … 517 517 if (renderer && renderer->isImage()) { 518 518 WebCore::RenderImage* img = static_cast<WebCore::RenderImage*>(renderer); 519 if (img->cachedImage() && !img->cachedImage()-> isErrorImage())519 if (img->cachedImage() && !img->cachedImage()->errorOccurred()) 520 520 return (NSData*)(img->cachedImage()->image()->getTIFFRepresentation()); 521 521 } -
trunk/WebCore/dom/Document.cpp
r19934 r19952 300 300 , m_createRenderers(true) 301 301 , m_inPageCache(false) 302 , m_isAllowedToLoadLocalResources(false) 302 303 { 303 304 m_document.resetSkippingRef(this); … … 1252 1253 setBaseURL(parent->baseURL()); 1253 1254 } 1254 else1255 setURL(m_url);1256 1255 1257 1256 if ((frame() && frame()->loader()->isLoadingMainResource()) || (tokenizer() && tokenizer()->executingScript())) … … 1513 1512 void Document::setURL(const DeprecatedString& url) 1514 1513 { 1514 if (url == m_url) 1515 return; 1516 1515 1517 m_url = url; 1516 1518 if (m_styleSelector) 1517 1519 m_styleSelector->setEncodedURL(m_url); 1520 1521 m_isAllowedToLoadLocalResources = shouldBeAllowedToLoadLocalResources(); 1522 } 1523 1524 bool Document::shouldBeAllowedToLoadLocalResources() const 1525 { 1526 if (FrameLoader::shouldTreatURLAsLocal(m_url)) 1527 return true; 1528 1529 Frame* frame = this->frame(); 1530 if (!frame) 1531 return false; 1532 1533 DocumentLoader* documentLoader = frame->loader()->documentLoader(); 1534 if (!documentLoader) 1535 return false; 1536 1537 return documentLoader->substituteData().isValid(); 1518 1538 } 1519 1539 … … 1881 1901 #endif 1882 1902 1883 updateStyleSelector(); 1903 updateStyleSelector(); 1884 1904 } 1885 1905 -
trunk/WebCore/dom/Document.h
r19855 r19952 619 619 String iconURL(); 620 620 void setIconURL(const String& iconURL, const String& type); 621 622 bool isAllowedToLoadLocalResources() const { return m_isAllowedToLoadLocalResources; } 623 621 624 protected: 622 625 CSSStyleSelector* m_styleSelector; … … 629 632 DeprecatedString m_baseURL; 630 633 String m_baseTarget; 631 634 632 635 RefPtr<DocumentType> m_docType; 633 636 RefPtr<DOMImplementation> m_implementation; … … 784 787 785 788 private: 789 bool shouldBeAllowedToLoadLocalResources() const; 790 786 791 void updateTitle(); 787 792 void removeAllDisconnectedNodeEventListeners(); … … 831 836 bool m_inPageCache; 832 837 String m_iconURL; 838 839 bool m_isAllowedToLoadLocalResources; 833 840 }; 834 841 -
trunk/WebCore/html/HTMLImageLoader.cpp
r19590 r19952 124 124 if (!haveFiredLoadEvent() && image()) { 125 125 setHaveFiredLoadEvent(true); 126 element()->dispatchHTMLEvent(image()-> isErrorImage() ? errorEvent : loadEvent, false, false);126 element()->dispatchHTMLEvent(image()->errorOccurred() ? errorEvent : loadEvent, false, false); 127 127 } 128 128 } -
trunk/WebCore/html/HTMLLinkElement.cpp
r18233 r19952 180 180 if (!isAlternate()) 181 181 document()->addPendingSheet(); 182 182 183 183 String chset = getAttribute(charsetAttr); 184 184 if (chset.isEmpty() && document()->frame()) … … 195 195 if (m_cachedSheet) 196 196 m_cachedSheet->ref(this); 197 else if (!isAlternate()) { // request may have been denied if stylesheet is local and document is remote. 198 m_loading = false; 199 document()->stylesheetLoaded(); 200 } 197 201 } 198 202 } else if (m_sheet) { -
trunk/WebCore/ksvg2/misc/SVGImageLoader.cpp
r19855 r19952 71 71 if (!haveFiredLoadEvent() && image()) { 72 72 setHaveFiredLoadEvent(true); 73 if (image()-> isErrorImage()) {73 if (image()->errorOccurred()) { 74 74 // FIXME: We're supposed to put the document in an "error state" per the spec. 75 75 } else -
trunk/WebCore/loader/Cache.cpp
r19855 r19952 35 35 #include "DocLoader.h" 36 36 #include "Document.h" 37 #include "FrameLoader.h" 37 38 #include "Image.h" 38 39 #include "ResourceHandle.h" … … 88 89 CachedResource* resource = m_resources.get(url.url()); 89 90 90 if (!resource) { 91 if (resource) { 92 if (FrameLoader::restrictAccessToLocal() 93 && !FrameLoader::canLoad(*resource, docLoader->doc())) 94 return 0; 95 } else { 96 if (FrameLoader::restrictAccessToLocal() 97 && !FrameLoader::canLoad(url, docLoader->doc())) 98 return 0; 99 91 100 // The resource does not exist. Create it. 92 101 resource = createResource(type, docLoader, url, expireDate, charset); -
trunk/WebCore/loader/CachedCSSStyleSheet.cpp
r18969 r19952 60 60 61 61 if (!m_loading) 62 c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), m_sheet);62 c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), errorOccurred() ? "" : m_sheet); 63 63 } 64 64 … … 93 93 { 94 94 m_loading = false; 95 m_errorOccurred = true; 95 96 checkNotify(); 96 97 } -
trunk/WebCore/loader/CachedImage.cpp
r19855 r19952 57 57 { 58 58 m_image = 0; 59 m_errorOccurred = false;60 59 m_status = Unknown; 61 60 if (!docLoader || docLoader->autoLoadImages()) { … … 71 70 { 72 71 m_image = image; 73 m_errorOccurred = false;74 72 m_status = Cached; 75 73 m_loading = false; -
trunk/WebCore/loader/CachedImage.h
r19590 r19952 48 48 Image* image() const; 49 49 50 bool canRender() const { return ! isErrorImage() && imageSize().width() > 0 && imageSize().height() > 0; }50 bool canRender() const { return !errorOccurred() && imageSize().width() > 0 && imageSize().height() > 0; } 51 51 52 52 IntSize imageSize() const; // returns the size of the complete image … … 58 58 virtual void data(Vector<char>&, bool allDataReceived); 59 59 virtual void error(); 60 61 bool isErrorImage() const { return m_errorOccurred; }62 60 63 61 virtual bool schedule() const { return true; } … … 81 79 Image* m_image; 82 80 int m_dataSize; 83 84 bool m_errorOccurred : 1;85 81 86 82 friend class Cache; -
trunk/WebCore/loader/CachedResource.cpp
r19218 r19952 31 31 32 32 #include "Cache.h" 33 #include "FrameLoader.h" 33 34 #include "Request.h" 34 35 #include <KURL.h> … … 55 56 m_lruIndex = 0; 56 57 #endif 58 m_errorOccurred = false; 59 m_shouldTreatAsLocal = FrameLoader::shouldTreatURLAsLocal(m_url); 57 60 } 58 61 -
trunk/WebCore/loader/CachedResource.h
r19855 r19952 128 128 void setAccept(const String& accept) { m_accept = accept; } 129 129 130 bool errorOccurred() const { return m_errorOccurred; } 131 bool treatAsLocal() const { return m_shouldTreatAsLocal; } 132 130 133 protected: 131 134 void setSize(unsigned size); … … 142 145 Type m_type; 143 146 Status m_status; 147 148 bool m_errorOccurred; 144 149 145 150 private: … … 161 166 CachedResource* m_prevInLRUList; 162 167 friend class Cache; 168 169 bool m_shouldTreatAsLocal; 163 170 }; 164 171 -
trunk/WebCore/loader/CachedScript.cpp
r17133 r19952 46 46 // and refuse to serve them if we only accept application/x-javascript. 47 47 setAccept("*/*"); 48 m_errorOccurred = false;49 48 // load the file 50 49 cache()->loader()->load(dl, this, false); -
trunk/WebCore/loader/CachedScript.h
r19590 r19952 50 50 51 51 virtual bool schedule() const { return false; } 52 53 bool errorOccurred() const { return m_errorOccurred; }54 52 55 53 void checkNotify(); … … 58 56 String m_script; 59 57 TextEncoding m_encoding; 60 bool m_errorOccurred;61 58 }; 62 59 } -
trunk/WebCore/loader/CachedXBLDocument.cpp
r19855 r19952 104 104 { 105 105 m_loading = false; 106 m_errorOccurred = true; 106 107 checkNotify(); 107 108 } -
trunk/WebCore/loader/CachedXSLStyleSheet.cpp
r19855 r19952 93 93 { 94 94 m_loading = false; 95 m_errorOccurred = true; 95 96 checkNotify(); 96 97 } -
trunk/WebCore/loader/FrameLoader.cpp
r19940 r19952 83 83 #include <kjs/object.h> 84 84 85 using namespace KJS; 85 using KJS::UString; 86 using KJS::JSLock; 87 using KJS::JSValue; 86 88 87 89 namespace WebCore { … … 156 158 157 159 static double storedTimeOfLastCompletedLoad; 160 static bool m_restrictAccessToLocal = false; 158 161 159 162 static bool getString(JSValue* result, String& string) … … 953 956 } 954 957 958 bool FrameLoader::restrictAccessToLocal() 959 { 960 return m_restrictAccessToLocal; 961 } 962 963 void FrameLoader::setRestrictAccessToLocal(bool access) 964 { 965 m_restrictAccessToLocal = access; 966 } 967 968 static HashSet<String, CaseInsensitiveHash<String> >& localSchemes() 969 { 970 static HashSet<String, CaseInsensitiveHash<String> > localSchemes; 971 972 if (localSchemes.isEmpty()) { 973 localSchemes.add("file"); 974 localSchemes.add("applewebdata"); 975 } 976 977 return localSchemes; 978 } 979 955 980 void FrameLoader::commitIconURLToIconDatabase(const KURL& icon) 956 981 { … … 1348 1373 pluginElement = static_cast<Element*>(renderer->node()); 1349 1374 1350 bool hideReferrer; 1351 if (!canLoad(url, outgoingReferrer(), hideReferrer)) 1375 if (!canLoad(url, frame()->document())) 1352 1376 return false; 1353 1377 … … 1864 1888 bool FrameLoader::canLoad(const KURL& url, const String& referrer, bool& hideReferrer) 1865 1889 { 1866 bool referrerIsWebURL = referrer.startsWith("http:", false) || referrer.startsWith("https:", false); 1867 bool referrerIsLocalURL = referrer.startsWith("file:", false) || referrer.startsWith("applewebdata:"); 1868 bool URLIsFileURL = url.protocol().startsWith("file", false); 1890 hideReferrer = shouldHideReferrer(url, referrer); 1891 1892 if (!shouldTreatURLAsLocal(url.url())) 1893 return true; 1894 1895 return shouldTreatURLAsLocal(referrer); 1896 } 1897 1898 bool FrameLoader::canLoad(const KURL& url, const Document* doc) 1899 { 1900 if (!shouldTreatURLAsLocal(url.url())) 1901 return true; 1902 1903 return doc && doc->isAllowedToLoadLocalResources(); 1904 } 1905 1906 bool FrameLoader::canLoad(const CachedResource& resource, const Document* doc) 1907 { 1908 if (!resource.treatAsLocal()) 1909 return true; 1910 1911 return doc && doc->isAllowedToLoadLocalResources(); 1912 } 1913 1914 bool FrameLoader::shouldHideReferrer(const KURL& url, const String& referrer) 1915 { 1869 1916 bool referrerIsSecureURL = referrer.startsWith("https:", false); 1870 bool URLIsSecureURL = url.protocol().startsWith("https", false); 1871 1872 hideReferrer = !referrerIsWebURL || (referrerIsSecureURL && !URLIsSecureURL); 1873 return !URLIsFileURL || referrerIsLocalURL; 1917 bool referrerIsWebURL = referrerIsSecureURL || referrer.startsWith("http:", false); 1918 1919 if (!referrerIsWebURL) 1920 return true; 1921 1922 if (!referrerIsSecureURL) 1923 return false; 1924 1925 bool URLIsSecureURL = url.url().startsWith("https:", false); 1926 1927 return !URLIsSecureURL; 1874 1928 } 1875 1929 … … 2926 2980 // But we still want to know whether we should hide the referrer or not, so we call the canLoad method. 2927 2981 String referrer = m_outgoingReferrer; 2928 bool hideReferrer; 2929 canLoad(request.url(), referrer, hideReferrer); 2930 if (hideReferrer) 2982 if (shouldHideReferrer(request.url(), referrer)) 2931 2983 referrer = String(); 2932 2984 … … 4247 4299 } 4248 4300 4301 void FrameLoader::registerSchemeAsLocal(const String& scheme) 4302 { 4303 localSchemes().add(scheme); 4304 } 4305 4306 bool FrameLoader::shouldTreatURLAsLocal(const String& url) 4307 { 4308 // This avoids an allocation of another String and the HashSet containts() 4309 // call for the file: and http: schemes. 4310 if (url.length() >= 5) { 4311 const UChar* s = url.characters(); 4312 if (s[0] == 'h' && s[1] == 't' && s[2] == 't' && s[3] == 'p' && s[4] == ':') 4313 return false; 4314 if (s[0] == 'f' && s[1] == 'i' && s[2] == 'l' && s[3] == 'e' && s[4] == ':') 4315 return true; 4316 } 4317 4318 int loc = url.find(':'); 4319 if (loc == -1) 4320 return false; 4321 4322 String scheme = url.left(loc); 4323 return localSchemes().contains(scheme); 4324 } 4325 4249 4326 } // namespace WebCore -
trunk/WebCore/loader/FrameLoader.h
r19940 r19952 30 30 #define FrameLoader_h 31 31 32 #include "CachedResource.h" 32 33 #include "CachePolicy.h" 33 34 #include "FormState.h" … … 51 52 52 53 class AuthenticationChallenge; 54 class Document; 53 55 class DocumentLoader; 54 56 class Element; … … 149 151 void load(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); 150 152 151 bool canLoad(const KURL&, const String& referrer, bool& hideReferrer); 153 static bool canLoad(const KURL&, const String& referrer, bool& hideReferrer); 154 static bool canLoad(const KURL&, const Document*); 155 static bool canLoad(const CachedResource&, const Document*); 156 157 static bool shouldHideReferrer(const KURL& url, const String& referrer); 152 158 153 159 Frame* createWindow(const FrameLoadRequest&, const WindowFeatures&); … … 391 397 bool shouldGoToHistoryItem(HistoryItem*) const; 392 398 bool shouldTreatURLAsSameAsCurrent(const KURL&) const; 393 399 394 400 void commitProvisionalLoad(PassRefPtr<PageCache>); 395 401 … … 406 412 void setPreviousHistoryItem(PassRefPtr<HistoryItem>); 407 413 void setProvisionalHistoryItem(PassRefPtr<HistoryItem>); 408 414 409 415 void continueLoadWithData(SharedBuffer*, const String& mimeType, const String& textEncoding, const KURL&); 416 417 static void registerSchemeAsLocal(const String& scheme); 418 static bool restrictAccessToLocal(); 419 static void setRestrictAccessToLocal(bool); 420 static bool shouldTreatURLAsLocal(const String& url); 421 410 422 private: 411 423 PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal); -
trunk/WebCore/loader/MainResourceLoader.cpp
r19902 r19952 182 182 case PolicyUse: { 183 183 // Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255). 184 bool isRemote = !url.isLocalFile(); 185 isRemote = isRemote && !m_substituteData.isValid(); 186 bool isRemoteWebArchive = isRemote && equalIgnoringCase("application/x-webarchive", mimeType); 184 bool isRemoteWebArchive = equalIgnoringCase("application/x-webarchive", mimeType) && !m_substituteData.isValid() && !url.isLocalFile(); 187 185 if (!frameLoader()->canShowMIMEType(mimeType) || isRemoteWebArchive) { 188 186 frameLoader()->cannotShowMIMEType(r); -
trunk/WebCore/loader/SubresourceLoader.cpp
r19553 r19952 92 92 93 93 ResourceRequest newRequest = request; 94 95 // Since this is a subresource, we can load any URL (we ignore the return value).96 // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.97 // FIXME: is that really the rule we want for subresources?98 bool hideReferrer;99 fl->canLoad(request.url(), fl->outgoingReferrer(), hideReferrer);100 if ( hideReferrer)94 95 // If linked-on-or-after check canLoad 96 if (FrameLoader::restrictAccessToLocal() 97 && !FrameLoader::canLoad(request.url(), frame->document())) 98 return 0; 99 100 if (FrameLoader::shouldHideReferrer(request.url(), fl->outgoingReferrer())) 101 101 newRequest.clearHTTPReferrer(); 102 102 else if (!request.httpReferrer()) -
trunk/WebCore/page/DragController.cpp
r19808 r19952 478 478 479 479 RenderImage* image = static_cast<RenderImage*>(renderer); 480 if (image->cachedImage() && !image->cachedImage()-> isErrorImage())480 if (image->cachedImage() && !image->cachedImage()->errorOccurred()) 481 481 return image->cachedImage()->image(); 482 482 return 0; -
trunk/WebCore/page/EventHandler.cpp
r19940 r19952 646 646 if (cimage->image()->isNull()) 647 647 break; 648 if (!cimage-> isErrorImage()) {648 if (!cimage->errorOccurred()) 649 649 return Cursor(cimage->image(), hotSpot); 650 }651 650 } 652 651 } -
trunk/WebCore/platform/KURL.cpp
r19159 r19952 793 793 bool KURL::isLocalFile() const 794 794 { 795 // FIXME - include feed: here too? 795 // Including feed here might be a bad idea since drag and drop uses this check 796 // and including feed would allow feeds to potentially let someone's blog 797 // read the contents of the clipboard on a drag, even without a drop. 798 // Likewise with using the FrameLoader::shouldTreatURLAsLocal() function. 796 799 return protocol() == "file"; 797 800 } -
trunk/WebCore/rendering/HitTestResult.cpp
r19855 r19952 198 198 if (renderer && renderer->isImage()) { 199 199 RenderImage* image = static_cast<WebCore::RenderImage*>(renderer); 200 if (image->cachedImage() && !image->cachedImage()-> isErrorImage())200 if (image->cachedImage() && !image->cachedImage()->errorOccurred()) 201 201 return image->cachedImage()->image(); 202 202 } -
trunk/WebCore/rendering/RenderImage.cpp
r19696 r19952 71 71 if (m_cachedImage) { 72 72 m_cachedImage->ref(this); 73 if (m_cachedImage-> isErrorImage())73 if (m_cachedImage->errorOccurred()) 74 74 imageChanged(m_cachedImage); 75 75 } … … 137 137 138 138 // Set image dimensions, taking into account the size of the alt text. 139 if (newImage-> isErrorImage())139 if (newImage->errorOccurred()) 140 140 imageSizeChanged = setImageSizeForAltText(newImage); 141 141 … … 144 144 // Image dimensions have been changed, see what needs to be done 145 145 if (newImage->imageSize().width() != intrinsicWidth() || newImage->imageSize().height() != intrinsicHeight() || imageSizeChanged) { 146 if (!newImage-> isErrorImage()) {146 if (!newImage->errorOccurred()) { 147 147 setIntrinsicWidth(newImage->imageSize().width()); 148 148 setIntrinsicHeight(newImage->imageSize().height()); … … 227 227 return; 228 228 229 if (!m_cachedImage || image()->isNull() || isErrorImage()) {229 if (!m_cachedImage || image()->isNull() || errorOccurred()) { 230 230 if (paintInfo.phase == PaintPhaseSelection) 231 231 return; 232 232 233 233 if (cWidth > 2 && cHeight > 2) { 234 if (! isErrorImage()) {234 if (!errorOccurred()) { 235 235 context->setStrokeStyle(SolidStroke); 236 236 context->setStrokeColor(Color::lightGray); … … 245 245 int usableHeight = cHeight; 246 246 247 if ( isErrorImage() && !image()->isNull() && (usableWidth >= image()->width()) && (usableHeight >= image()->height())) {247 if (errorOccurred() && !image()->isNull() && (usableWidth >= image()->width()) && (usableHeight >= image()->height())) { 248 248 // Center the error image, accounting for border and padding. 249 249 int centerX = (usableWidth - image()->width()) / 2; … … 311 311 312 312 // minimum height 313 m_height = m_cachedImage && m_cachedImage-> isErrorImage() ? intrinsicHeight() : 0;313 m_height = m_cachedImage && m_cachedImage->errorOccurred() ? intrinsicHeight() : 0; 314 314 315 315 calcWidth(); … … 416 416 if (!intrinsicHeight()) 417 417 return 0; 418 if (!m_cachedImage || m_cachedImage-> isErrorImage())418 if (!m_cachedImage || m_cachedImage->errorOccurred()) 419 419 return intrinsicWidth(); // Don't bother scaling. 420 420 return RenderReplaced::calcReplacedHeight() * intrinsicWidth() / intrinsicHeight(); … … 425 425 if (!intrinsicWidth()) 426 426 return 0; 427 if (!m_cachedImage || m_cachedImage-> isErrorImage())427 if (!m_cachedImage || m_cachedImage->errorOccurred()) 428 428 return intrinsicHeight(); // Don't bother scaling. 429 429 return RenderReplaced::calcReplacedWidth() * intrinsicHeight() / intrinsicWidth(); -
trunk/WebCore/rendering/RenderImage.h
r19590 r19952 79 79 bool isHeightSpecified() const; 80 80 81 bool isErrorImage() const { return m_cachedImage && m_cachedImage->isErrorImage(); }81 bool errorOccurred() const { return m_cachedImage && m_cachedImage->errorOccurred(); } 82 82 83 83 // The image we are rendering. -
trunk/WebCore/rendering/RenderListItem.cpp
r19899 r19952 53 53 54 54 if (style()->listStyleType() != LNONE || 55 (style()->listStyleImage() && !style()->listStyleImage()-> isErrorImage())) {55 (style()->listStyleImage() && !style()->listStyleImage()->errorOccurred())) { 56 56 RenderStyle* newStyle = new (renderArena()) RenderStyle; 57 57 newStyle->ref(); -
trunk/WebCore/rendering/RenderListMarker.cpp
r19875 r19952 507 507 bool RenderListMarker::isImage() const 508 508 { 509 return m_image && !m_image-> isErrorImage();509 return m_image && !m_image->errorOccurred(); 510 510 } 511 511 -
trunk/WebCore/xml/xmlhttprequest.cpp
r18863 r19952 326 326 bool XMLHttpRequest::urlMatchesDocumentDomain(const KURL& url) const 327 327 { 328 KURL documentURL(m_doc->URL());329 330 328 // a local file can load anything 331 if ( documentURL.protocol().lower() == "file" || documentURL.protocol().lower() == "applewebdata")329 if (m_doc->isAllowedToLoadLocalResources()) 332 330 return true; 333 331 334 332 // but a remote document can only load from the same port on the server 333 KURL documentURL = m_doc->URL(); 335 334 if (documentURL.protocol().lower() == url.protocol().lower() 336 335 && documentURL.host().lower() == url.host().lower() -
trunk/WebKit/ChangeLog
r19929 r19952 1 2007-03-02 Kevin McCullough <kmccullough@apple.com> 2 3 Reviewed by Geoff. 4 5 - rdar://problem/4922454 6 - This fixes a security issue by making remote referrers not able to access local 7 resources, unless they register their schemes to be treated as local. The result is 8 that those schemes can access local resources and cannot be accessed by remote 9 referrers. 10 Because this behavior is new a link-on-or-after check is made to determine if the 11 app should use the older, less safe, behavior. 12 13 * Misc/WebKitVersionChecks.h: added linked-on-or-after check 14 * Misc/WebNSAttributedStringExtras.mm: Moved functionalit into the base class. 15 (fileWrapperForElement): 16 * Plugins/WebNetscapePluginStream.mm: uses new canLoad functions 17 * Plugins/WebPluginContainerCheck.mm: uses new canLoad functions 18 (-[WebPluginContainerCheck _isForbiddenFileLoad]): 19 * WebView/WebView.mm: make linked-on-or-after check and cache value, exposes SPI 20 for registering a scheme as local. 21 (-[WebView _commonInitializationWithFrameName:groupName:]): 22 (+[WebView registerSchemeAsLocal:]): 23 * WebView/WebViewPrivate.h: exposes SPI for registering a scheme as local. 24 1 25 2007-03-01 Justin Garcia <justin.garcia@apple.com> 2 26 -
trunk/WebKit/Misc/WebKitVersionChecks.h
r19704 r19952 36 36 #define WEBKIT_FIRST_VERSION_WITH_3_0_CONTEXT_MENU_TAGS 0x00020000 37 37 #define WEBKIT_FIRST_VERSION_WITHOUT_ACROBAT_QUIRK 0x00020000 38 #define WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION 0x00020000 38 39 #define WEBKIT_FIRST_VERSION_WITHOUT_APERTURE_QUIRK 0x00020000 39 40 -
trunk/WebKit/Misc/WebNSAttributedStringExtras.mm
r19702 r19952 99 99 if (!wrapper) { 100 100 RenderImage* renderer = static_cast<RenderImage*>(e->renderer()); 101 if (renderer->cachedImage() && !renderer->cachedImage()-> isErrorImage()) {101 if (renderer->cachedImage() && !renderer->cachedImage()->errorOccurred()) { 102 102 wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)(renderer->cachedImage()->image()->getTIFFRepresentation())]; 103 103 [wrapper setPreferredFilename:@"image.tiff"]; -
trunk/WebKit/Plugins/WebNetscapePluginStream.mm
r19747 r19952 64 64 WebBaseNetscapePluginView *view = (WebBaseNetscapePluginView *)thePlugin->ndata; 65 65 66 bool hideReferrer; 67 if (!core([view webFrame])->loader()->canLoad([theRequest URL], core([view webFrame])->loader()->outgoingReferrer(), hideReferrer)) 66 if (!core([view webFrame])->loader()->canLoad([theRequest URL], core([view webFrame])->document())) 68 67 return nil; 69 68 … … 79 78 80 79 request = [theRequest mutableCopy]; 81 if ( hideReferrer)80 if (core([view webFrame])->loader()->shouldHideReferrer([theRequest URL], core([view webFrame])->loader()->outgoingReferrer())) 82 81 [(NSMutableURLRequest *)request _web_setHTTPReferrer:nil]; 83 82 -
trunk/WebKit/Plugins/WebPluginContainerCheck.mm
r19702 r19952 96 96 - (BOOL)_isForbiddenFileLoad 97 97 { 98 bool ignore;99 98 WebFrameBridge *bridge = [_controller bridge]; 100 99 ASSERT(bridge); 101 if (![bridge _frame]->loader()->canLoad([_request URL], [ _controller URLPolicyCheckReferrer], ignore)) {100 if (![bridge _frame]->loader()->canLoad([_request URL], [bridge _frame]->document())) { 102 101 [self _continueWithPolicy:PolicyIgnore]; 103 102 return YES; -
trunk/WebKit/WebView/WebView.mm
r19752 r19952 1651 1651 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) 1652 1652 name:WebPreferencesChangedNotification object:[self preferences]]; 1653 1654 if (WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) 1655 FrameLoader::setRestrictAccessToLocal(true); 1653 1656 } 1654 1657 … … 2817 2820 } 2818 2821 2822 + (void)registerSchemeAsLocal:(NSString *)protocol 2823 { 2824 FrameLoader::registerSchemeAsLocal(protocol); 2825 } 2826 2819 2827 @end 2820 2828 -
trunk/WebKit/WebView/WebViewPrivate.h
r19292 r19952 172 172 - (void)setAllowsUndo:(BOOL)flag; 173 173 174 + (void)registerSchemeAsLocal:(NSString *)protocol; 175 174 176 @end 175 177
Note:
See TracChangeset
for help on using the changeset viewer.