Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1648)

Unified Diff: chrome/browser/ui/webui/extensions/extension_error_handler.cc

Issue 23875013: Handle invalid input for SourceHighlighter, Don't Allow Relative Paths in ErrorHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove comment + address security risk in ErrorHandler Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | extensions/browser/file_highlighter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/extensions/extension_error_handler.cc
diff --git a/chrome/browser/ui/webui/extensions/extension_error_handler.cc b/chrome/browser/ui/webui/extensions/extension_error_handler.cc
index 45bd71f99cbc1141ac5ede960ef9abddde2edea7..f89feb4bdcf84f3d004c0a3fa069b2a3e39fe0d7 100644
--- a/chrome/browser/ui/webui/extensions/extension_error_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_error_handler.cc
@@ -90,11 +90,11 @@ void ExtensionErrorHandler::HandleRequestFileSource(
// Three required arguments: extension_id, path_suffix, and error_message.
std::string extension_id;
- base::FilePath::StringType path_suffix;
+ base::FilePath::StringType path_suffix_string;
base::string16 error_message;
if (!args->GetDictionary(0, &dict) ||
- !dict->GetString(kPathSuffixKey, &path_suffix) ||
+ !dict->GetString(kPathSuffixKey, &path_suffix_string) ||
!dict->GetString(ExtensionError::kExtensionIdKey, &extension_id) ||
!dict->GetString(ExtensionError::kMessageKey, &error_message)) {
NOTREACHED();
@@ -105,6 +105,13 @@ void ExtensionErrorHandler::HandleRequestFileSource(
ExtensionSystem::Get(Profile::FromWebUI(web_ui()))->
extension_service()->GetExtensionById(extension_id,
true /* include disabled */ );
+
+ // Under no circumstances should we ever need to reference a file outside of
+ // the extension's directory. If it tries to, abort.
+ base::FilePath path_suffix(path_suffix_string);
+ if (path_suffix.ReferencesParent())
+ return;
+
base::FilePath path = extension->path().Append(path_suffix);
// Setting the title and the error message is the same for all file types.
@@ -118,7 +125,7 @@ void ExtensionErrorHandler::HandleRequestFileSource(
base::Closure closure;
std::string* contents = NULL;
- if (path_suffix == kManifestFilename) {
+ if (path_suffix_string == kManifestFilename) {
std::string manifest_key;
if (!dict->GetString(ManifestError::kManifestKeyKey, &manifest_key)) {
NOTREACHED();
« no previous file with comments | « no previous file | extensions/browser/file_highlighter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698