Changeset 210531 in webkit
- Timestamp:
- Jan 9, 2017, 4:32:24 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/SecurityOrigin.cpp (modified) (4 diffs)
-
Source/WebCore/page/SecurityOrigin.h (modified) (2 diffs)
-
Source/WebCore/platform/FileSystem.cpp (modified) (2 diffs)
-
Source/WebCore/platform/FileSystem.h (modified) (3 diffs)
-
Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm (modified) (3 diffs)
-
Source/WebCore/platform/posix/FileSystemPOSIX.cpp (modified) (2 diffs)
-
Source/WebCore/platform/win/FileSystemWin.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (6 diffs)
-
Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html (added)
-
Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r210524 r210531 1 2017-01-09 Brent Fulgham <bfulgham@apple.com> 2 3 File scheme should not allow access of a resource on a different volume. 4 https://bugs.webkit.org/show_bug.cgi?id=158552 5 <rdar://problem/15307582> 6 7 Reviewed by Alex Christensen. 8 9 Revise SecurityOrigin to prevent files from one storage device (volume) from accessing content 10 on a different storage device (volume) unless universal access is enabled. 11 12 Pass the current file device as part of the NSURLRequest so that CFNetwork can reject loads 13 where the device changes in the midst of a load. 14 15 Also properly reflect that SecurityOrigin is never null by passing as a reference, 16 rather than as a pointer. 17 18 Tests: Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm 19 20 * page/SecurityOrigin.cpp: 21 (WebCore::SecurityOrigin::canAccess): Pass argument as reference. 22 (WebCore::SecurityOrigin::passesFileCheck): Add check that file URLs refer to files in 23 the same storage volume. 24 (WebCore::SecurityOrigin::canDisplay): Add check that files share the same volume. 25 (WebCore::SecurityOrigin::isSameSchemeHostPort): Pass argument as reference. 26 * page/SecurityOrigin.h: 27 * platform/FileSystem.cpp: 28 (WebCore::filesHaveSameVolume): Added. 29 * platform/FileSystem.h: 30 * platform/network/cocoa/ResourceRequestCocoa.mm: 31 (WebCore::ResourceRequest::doUpdatePlatformRequest): If loading a file URL, tell CFNetwork 32 the storage device at the time of the start of the load so we can trigger a failure if this 33 changes during the load operation. 34 * platform/posix/FileSystemPOSIX.cpp: 35 (WebCore::getFileDeviceId): Added. 36 * platform/win/FileSystemWin.cpp: 37 (WebCore::getFileDeviceId): Added. 38 1 39 2017-01-09 Tim Horton <timothy_horton@apple.com> 2 40 -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r210218 r210531 1 1 /* 2 * Copyright (C) 2007-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 230 230 231 231 if (canAccess && isLocal()) 232 canAccess = passesFileCheck(other);232 canAccess = passesFileCheck(*other); 233 233 234 234 return canAccess; 235 235 } 236 236 237 bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const 238 { 239 ASSERT(isLocal() && other->isLocal()); 240 241 if (!m_enforceFilePathSeparation && !other->m_enforceFilePathSeparation) 242 return true; 243 244 return (m_filePath == other->m_filePath); 237 bool SecurityOrigin::passesFileCheck(const SecurityOrigin& other) const 238 { 239 ASSERT(isLocal() && other.isLocal()); 240 241 if (!filesHaveSameVolume(m_filePath, other.m_filePath)) 242 return false; 243 244 if (!m_enforceFilePathSeparation && !other.m_enforceFilePathSeparation) 245 return true; 246 247 return (m_filePath == other.m_filePath); 245 248 } 246 249 … … 305 308 return true; 306 309 310 if (isLocal() && url.isLocalFile()) { 311 if (!filesHaveSameVolume(m_filePath, url.path())) 312 return false; 313 } 314 307 315 if (isFeedWithNestedProtocolInHTTPFamily(url)) 308 316 return true; … … 524 532 return false; 525 533 526 if (isLocal() && !passesFileCheck( other))534 if (isLocal() && !passesFileCheck(*other)) 527 535 return false; 528 536 -
trunk/Source/WebCore/page/SecurityOrigin.h
r210218 r210531 1 1 /* 2 * Copyright (C) 2007 , 2008Apple Inc. All rights reserved.2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 209 209 210 210 // FIXME: Rename this function to something more semantic. 211 bool passesFileCheck(const SecurityOrigin *) const;211 bool passesFileCheck(const SecurityOrigin&) const; 212 212 213 213 // This method checks that the scheme for this origin is an HTTP-family -
trunk/Source/WebCore/platform/FileSystem.cpp
r209399 r210531 1 1 /* 2 * Copyright (C) 2007 , 2011Apple Inc. All rights reserved.2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2015 Canon Inc. All rights reserved. 4 4 * … … 234 234 } 235 235 236 237 bool filesHaveSameVolume(const String& fileA, const String& fileB) 238 { 239 auto fsRepFileA = fileSystemRepresentation(fileA); 240 auto fsRepFileB = fileSystemRepresentation(fileB); 241 242 if (fsRepFileA.isNull() || fsRepFileB.isNull()) 243 return false; 244 245 auto handleA = openFile(fsRepFileA.data(), OpenForRead); 246 if (!isHandleValid(handleA)) 247 return false; 248 249 auto handleB = openFile(fsRepFileB.data(), OpenForRead); 250 if (!isHandleValid(handleB)) { 251 closeFile(handleA); 252 return false; 253 } 254 255 bool result = false; 256 257 auto fileADev = getFileDeviceId(handleA); 258 auto fileBDev = getFileDeviceId(handleB); 259 260 if (fileADev && fileBDev) 261 result = (fileADev == fileBDev); 262 263 closeFile(handleA); 264 closeFile(handleB); 265 266 return result; 267 } 268 236 269 #if !PLATFORM(MAC) 237 270 -
trunk/Source/WebCore/platform/FileSystem.h
r208278 r210531 1 1 /* 2 * Copyright (C) 2007 , 2008, 2011Apple Inc. All rights reserved.2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. 4 4 * Copyright (C) 2015 Canon Inc. All rights reserved. … … 147 147 WEBCORE_EXPORT String directoryName(const String&); 148 148 WEBCORE_EXPORT bool getVolumeFreeSpace(const String&, uint64_t&); 149 WEBCORE_EXPORT std::optional<int32_t> getFileDeviceId(PlatformFileHandle); 149 150 150 151 WEBCORE_EXPORT void setMetadataURL(String& URLString, const String& referrer, const String& path); … … 194 195 String decodeFromFilename(const String&); 195 196 197 bool filesHaveSameVolume(const String&, const String&); 198 196 199 #if USE(CF) 197 200 RetainPtr<CFURLRef> pathAsURL(const String&); -
trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm
r207585 r210531 1 1 /* 2 * Copyright (C) 2014 Apple, Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if PLATFORM(COCOA) 30 30 31 #import "FileSystem.h" 31 32 #import "FormDataStreamMac.h" 32 33 #import "HTTPHeaderNames.h" … … 204 205 #endif 205 206 207 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 208 if (m_url.isLocalFile()) { 209 auto fsRepFile = fileSystemRepresentation(m_url.fileSystemPath()); 210 if (!fsRepFile.isNull()) { 211 auto handle = openFile(fsRepFile.data(), OpenForRead); 212 if (isHandleValid(handle)) { 213 auto fileDevice = getFileDeviceId(handle); 214 if (fileDevice && fileDevice.value()) 215 [nsRequest _setProperty:[NSNumber numberWithInteger:fileDevice.value()] forKey:@"NSURLRequestFileProtocolExpectedDevice"]; 216 } 217 } 218 } 219 #endif 220 206 221 m_nsRequest = adoptNS(nsRequest); 207 222 } -
trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp
r200163 r210531 1 1 /* 2 * Copyright (C) 2007 , 2008Apple Inc. All rights reserved.2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 384 384 } 385 385 386 std::optional<int32_t> getFileDeviceId(PlatformFileHandle handle) 387 { 388 struct stat fileStat; 389 if (fstat(handle, &fileStat)) 390 return std::nullopt; 391 392 return fileStat.st_dev; 393 } 394 386 395 } // namespace WebCore -
trunk/Source/WebCore/platform/win/FileSystemWin.cpp
r206196 r210531 1 1 /* 2 * Copyright (C) 2007 , 2008Apple Inc. All rights reserved.2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. 4 4 * … … 34 34 #include "NotImplemented.h" 35 35 #include "PathWalker.h" 36 #include <io.h> 37 #include <shlobj.h> 38 #include <shlwapi.h> 39 #include <sys/stat.h> 40 #include <windows.h> 36 41 #include <wtf/CryptographicallyRandomNumber.h> 37 42 #include <wtf/HashMap.h> 38 43 #include <wtf/text/CString.h> 39 44 40 #include <windows.h>41 #include <shlobj.h>42 #include <shlwapi.h>43 45 44 46 namespace WebCore { … … 453 455 } 454 456 457 std::optional<int32_t> getFileDeviceId(PlatformFileHandle handle) 458 { 459 BY_HANDLE_FILE_INFORMATION fileInformation = { }; 460 if (!::GetFileInformationByHandle(handle, &fileInformation)) 461 return std::nullopt; 462 463 return fileInformation.dwVolumeSerialNumber; 464 } 465 455 466 } // namespace WebCore -
trunk/Tools/ChangeLog
r210523 r210531 1 2017-01-09 Brent Fulgham <bfulgham@apple.com> 2 3 File scheme should not allow access of a resource on a different volume. 4 https://bugs.webkit.org/show_bug.cgi?id=158552 5 <rdar://problem/15307582> 6 7 Reviewed by Alex Christensen. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add new files. 10 * TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html: Added. 11 * TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm: Added. 12 1 13 2017-01-09 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 14 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r210320 r210531 198 198 7AD3FE8E1D76131200B169A4 /* TransformationMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */; }; 199 199 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; }; 200 7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */; }; 201 7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */; }; 200 202 7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* Color.cpp */; }; 201 203 7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */; }; … … 602 604 dstSubfolderSpec = 7; 603 605 files = ( 606 7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */, 604 607 CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */, 605 608 9BD4239C1E04C01C00200395 /* chinese-character-with-image.html in Copy Resources */, … … 1041 1044 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformationMatrix.cpp; sourceTree = "<group>"; }; 1042 1045 7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = "<group>"; }; 1046 7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CrossPartitionFileSchemeAccess.mm; sourceTree = "<group>"; }; 1047 7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = CrossPartitionFileSchemeAccess.html; path = Tests/mac/CrossPartitionFileSchemeAccess.html; sourceTree = SOURCE_ROOT; }; 1043 1048 7C3965051CDD74F90094DBB8 /* Color.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; }; 1044 1049 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommandBackForward.mm; sourceTree = "<group>"; }; … … 2030 2035 isa = PBXGroup; 2031 2036 children = ( 2037 7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */, 2032 2038 5C0BF88F1DD5999B00B00328 /* WebViewCanPasteZeroPng.mm */, 2033 2039 5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */, … … 2094 2100 isa = PBXGroup; 2095 2101 children = ( 2102 7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */, 2096 2103 F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */, 2097 2104 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */, … … 2498 2505 2D1646E21D1862CD00015A1A /* DeferredViewInWindowStateChange.mm in Sources */, 2499 2506 7CCE7EB91A411A7E00447C4C /* DeviceScaleFactorInDashboardRegions.mm in Sources */, 2507 7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */, 2500 2508 7CCE7EBA1A411A7E00447C4C /* DeviceScaleFactorOnBack.mm in Sources */, 2501 2509 7C83E04D1D0A641800FEBCF3 /* DFACombiner.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.