Explorar o código

More security for extension files: nosniff (#9593)

Global `X-Content-Type-Options: nosniff`
And follow-up of #7753
Alexandre Alapetite hai 18 horas
pai
achega
8ffddc11f8

+ 1 - 0
.lycheeignore

@@ -3,6 +3,7 @@
 ^https://[^/]+\.domain/
 ^http://wiremock:8080/
 ^http://freshrss/
+^https://example.net
 
 # URLs used in source code / tests
 ^http://www\.blogger\.com/feeds/1/posts

+ 1 - 0
app/Controllers/extensionController.php

@@ -360,6 +360,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
 		$content_type = self::MIME_TYPES[$mimeType];
 		header("Content-Type: {$content_type}");
 		header("Content-Disposition: inline; filename='{$filename}'");
+		header('X-Content-Type-Options: nosniff');
 		header('Referrer-Policy: same-origin');
 		if (file_exists(DATA_PATH . '/no-cache.txt') || !httpConditional($mtime, cacheSeconds: 604800, cachePrivacy: 0)) {
 			$contents = $extension->getFile($filename);

+ 0 - 2
app/FreshRSS.php

@@ -142,8 +142,6 @@ class FreshRSS extends Minz_FrontController {
 	}
 
 	public static function preLayout(): void {
-		header('X-Content-Type-Options: nosniff');
-
 		FreshRSS_Share::load(join_path(APP_PATH, 'shares.php'));
 		self::loadStylesAndScripts();
 	}

+ 4 - 0
lib/core-extensions/UserCSS/extension.php

@@ -21,6 +21,10 @@ final class UserCSSExtension extends Minz_Extension {
 
 		$this->registerTranslates();
 
+		if (FreshRSS_Auth::requestReauth()) {
+			return;
+		}
+
 		if (Minz_Request::isPost()) {
 			$css_rules = Minz_Request::paramString('css-rules', plaintext: true);
 			$this->saveFile(self::FILENAME, $css_rules);

+ 2 - 0
p/i/index.php

@@ -25,6 +25,8 @@ declare(strict_types=1);
 require dirname(__DIR__, 2) . '/constants.php';
 require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
+header('X-Content-Type-Options: nosniff');
+
 $migrations_path = APP_PATH . '/migrations';
 $applied_migrations_path = DATA_PATH . '/applied_migrations.txt';