重命名 ASP.NET 会话 Cookie 名称的原因?

发布于 2024-08-02 02:52:05 字数 85 浏览 3 评论 0原文

是否有任何原因(安全?)为什么有人应该重命名 ASP.NET 会话 Cookie 名称,或者这只是 ASP.NET 的一个毫无意义的选项?

is there any reason (safety?) why someone should rename the ASP.NET Session Cookie Name or is it just a senseless option of ASP.NET?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

许你一世情深 2024-08-09 02:52:05

如果您有多个应用程序在同一台服务器上的同一域下运行,您可能希望每个应用程序都有单独的会话 cookie 名称,这样它们就不会共享相同的会话状态,或者更糟的是仍然会相互覆盖。

另请参阅 Forms Auth cookie 名称:

指定用于身份验证的 HTTP cookie。 如果单个服务器上运行多个应用程序,并且每个应用程序都需要唯一的 cookie,则必须在每个应用程序的每个 Web.config 文件中配置 cookie 名称。

If you have several applications running under the same domain on the same server, you may well want to have seperate session cookie names for each one, so that they aren't sharing the same session state or worse still overwriting each other.

See also the notes for the Forms Auth cookie name:

Specifies the HTTP cookie to use for authentication. If multiple applications are running on a single server and each application requires a unique cookie, you must configure the cookie name in each Web.config file for each application.

奈何桥上唱咆哮 2024-08-09 02:52:05

1)它可能(稍微)减慢正在(随意)寻找它的人的速度。

2) 您可能想隐藏您正在运行 ASP.NET 的事实

1) It might (slightly) slow someone down who is (casually) looking for it.

2) You might want to hide the fact that you are running ASP.NET

九歌凝 2024-08-09 02:52:05

以下链接提供了有关为何应重命名会话 cookie 的更多信息。

https://www.owasp.org/index.php/Session_Management_Cheat_Sheet

"使用的名称会话 ID 不应具有过多的描述性,也不应提供有关 ID 的用途和含义的不必要的详细信息

最常见的 Web 应用程序开发框架使用的会话 ID 名称可以轻松识别 [0],例如 PHPSESSID (PHP), JSESSIONID (J2EE)、CFID & CFTOKEN (ColdFusion)、ASP.NET_SessionId (ASP .NET) 等。因此,会话 ID 名称可能会泄露 Web 应用程序使用的技术和编程语言,

建议更改默认值 。 Web 开发框架的会话 ID 名称改为通用名称,例如“id”。”

Below link provides more information about why session cookies should be renamed.

https://www.owasp.org/index.php/Session_Management_Cheat_Sheet

"The name used by the session ID should not be extremely descriptive nor offer unnecessary details about the purpose and meaning of the ID.

The session ID names used by the most common web application development frameworks can be easily fingerprinted [0], such as PHPSESSID (PHP), JSESSIONID (J2EE), CFID & CFTOKEN (ColdFusion), ASP.NET_SessionId (ASP .NET), etc. Therefore, the session ID name can disclose the technologies and programming languages used by the web application.

It is recommended to change the default session ID name of the web development framework to a generic name, such as “id”."

凯凯我们等你回来 2024-08-09 02:52:05

使用 Cookie 前缀,您可以向 Cookie 添加安全属性通过特殊的方式命名。 因此,在这种情况下,重命名 ASP.NET 会话 cookie 确实会对安全性产生影响:

  • __Secure-... cookie 只能从安全 (HTTPS) 站点写入。
  • __Host-... cookie 只能从同一安全域写入。 因此不是来自子域或不安全 (HTTP) 站点。

With cookie prefixes, you can add a security attribute to your cookie by naming it a special way. So in that case renaming your ASP.NET session cookie does have an impact on security:

  • __Secure-… cookies can only be written from secure (HTTPS) sites.
  • __Host-… cookies can only be written from the same, secure domain. So not from subdomains or insecure (HTTP) sites.
云胡 2024-08-09 02:52:05

根据以下规范,https://datatracker. ietf.org/doc/html/draft-ietf-httpbis-cookie-prefixes-00,现代浏览器实现的,前缀用于使事情更安全。

3.1。 “__Secure-”前缀

如果 cookie 的名称以“__Secure-”开头,则 cookie 必须是:

  1. 设置“安全”属性
  2. 从“方案”被用户认为“安全”的 URI 设置
    代理。

以下 cookie 在从任何来源设置时都会被拒绝,如下所示
未设置“安全”标志

设置 Cookie:__Secure-SID=12345; 域名=example.com

如果从安全来源设置,则以下内容将被接受
(例如“https://example.com/”),否则拒绝:

设置 Cookie:__Secure-SID=12345; 安全的; 域名=example.com

3.2。 “__Host-”前缀

如果 cookie 的名称以“__Host-”开头,则 cookie 必须是:

  1. 设置“安全”属性
  2. 从“方案”被用户认为“安全”的 URI 设置
    代理。
  3. 仅发送至设置 cookie 的主机。 也就是说,一个cookie
    来自“https://example.com”的名为“__Host-cookie1”的设置不得
    包含“Domain”属性(因此只会发送到
    “example.com”,而不是“subdomain.example.com”)。
  4. 发送给主机的每个请求。 也就是说,一个名为
    “__Host-cookie1”必须包含一个值为“Path”的属性
    “/”。

以下 cookie 将始终被拒绝:

设置 Cookie:__Host-SID=12345 设置 Cookie:__Host-SID=12345;
安全设置-Cookie:__Host-SID=12345; 域名=example.com
设置 Cookie:__Host-SID=12345; 域名=example.com; 路径=/
设置 Cookie:__Host-SID=12345; 安全的; 域名=example.com; 路径=/

According to the following specification, https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-prefixes-00, that modern browsers implement, the prefixes are used to make things more secure.

3.1. The "__Secure-" prefix

If a cookie's name begins with "__Secure-", the cookie MUST be:

  1. Set with a "Secure" attribute
  2. Set from a URI whose "scheme" is considered "secure" by the user
    agent.

The following cookie would be rejected when set from any origin, as
the "Secure" flag is not set

Set-Cookie: __Secure-SID=12345; Domain=example.com

While the following would be accepted if set from a secure origin
(e.g. "https://example.com/"), and rejected otherwise:

Set-Cookie: __Secure-SID=12345; Secure; Domain=example.com

3.2. The "__Host-" prefix

If a cookie's name begins with "__Host-", the cookie MUST be:

  1. Set with a "Secure" attribute
  2. Set from a URI whose "scheme" is considered "secure" by the user
    agent.
  3. Sent only to the host which set the cookie. That is, a cookie
    named "__Host-cookie1" set from "https://example.com" MUST NOT
    contain a "Domain" attribute (and will therefore be sent only to
    "example.com", and not to "subdomain.example.com").
  4. Sent to every request for a host. That is, a cookie named
    "__Host-cookie1" MUST contain a "Path" attribute with a value of
    "/".

The following cookies would always be rejected:

Set-Cookie: __Host-SID=12345 Set-Cookie: __Host-SID=12345;
Secure Set-Cookie: __Host-SID=12345; Domain=example.com
Set-Cookie: __Host-SID=12345; Domain=example.com; Path=/
Set-Cookie: __Host-SID=12345; Secure; Domain=example.com; Path=/

青芜 2024-08-09 02:52:05

我认为这主要是品味问题。 有些人/公司希望控制其网络应用程序的各个方面,并且可能只是使用另一个名称来与其他 cookie 名称保持一致。 例如,如果您在整个应用程序中使用非常短的单字符参数名称,您可能不喜欢像 ASPSESSID 这样的会话 cookie 名称。

安全原因可能适用,但在我看来,通过模糊实现安全性相当薄弱。

I think its mainly a matter of taste. Some people/companies want control every aspect of their web apps and might just use another name for consistency with other cookie names. For example, if you use very short one-character parameter names throughout your app you might not like session cookie names like ASPSESSID.

Security reasons might apply but security through obscurity is rather weak in my opinion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文