【问题标题】:php.ini content type not specified未指定 php.ini 内容类型
【发布时间】:2015-12-30 01:39:35
【问题描述】:

我使用 Acunetix Web Vulnerability Scanner 扫描了我的 Web 应用程序,它说未指定 php.ini 内容类型。

漏洞描述

此页面未设置 Content-Type 标头值。该值告知 浏览器期望什么样的数据。如果缺少此标头, 浏览器可能会错误地处理数据。这可能导致 安全问题。

它在“如何修复此漏洞”上给出的建议是“为此页面设置 Content-Type 标头值。 "

这就是我的 php.ini

中的内容
magic_quotes_gpc = Off;
register_globals = Off;
default_charset = "UTF-8";
memory_limit = 64M;
max_execution_time = 3600;
upload_max_filesize = 10M;
sql.safe_mode = Off;
mysql.connect_timeout = 20;
allow_url_fopen = Off;
;session.auto_start = Off;
;session.use_only_cookies = On;
;session.use_cookies = On;
;session.use_trans_sid = Off;
;session.cookie_httponly = On;
;session.gc_maxlifetime = 3600;
;session.cookie_secure =On;
;session.entropy_file = "/dev/urandom";
;display_errors = 1;
;error_reporting = E_ALL;

问题。如何在 php.ini 文件中设置 content-type 标头值?

【问题讨论】:

  • 为什么您的 php.ini 会公开暴露在网络上?...您不需要在 php.ini 上设置内容类型。我不明白这是一个漏洞。
  • 也许您想说您从网络浏览器提供的文件没有设置内容类型?你是 Apache 还是...?
  • @Clayton,伙计,我搞砸了。需要更新我的 php.ini 文件而不是将其转储到应用程序文件夹中。谢谢提醒。

标签: php content-type ini


【解决方案1】:

检查文件权限。

来自PHP manual

默认情况下,PHP 会使用 Content-Type 输出一个媒体类型 标题。要禁用此功能,只需将其设置为空即可。

PHP 的内置默认媒体类型设置为 text/html。

但是您的 php.ini 文件不是作为 PHP 页面提供的。你不应该让你的 php.ini 文件暴露在网络上。有关 PHP 安全性的更多信息here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 1970-01-01
    • 2019-02-19
    • 2014-07-01
    • 1970-01-01
    • 2021-04-25
    • 2015-02-14
    相关资源
    最近更新 更多