Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: Cookie Security #50

Open
ejohn20 opened this issue Jun 25, 2018 · 1 comment
Open

New Rule: Cookie Security #50

ejohn20 opened this issue Jun 25, 2018 · 1 comment
Assignees

Comments

@ejohn20
Copy link
Member

ejohn20 commented Jun 25, 2018

Puma Scan didn’t detect missing HttpOnly and Secure flags here.

Secure settings are Secure = true, HttpOnly = true, and Expires can only be set to a past date.

HttpCookie CreateCookie(string value)
{
      var ck = new HttpCookie(COOKIE_NAME, value);
      if (string.IsNullOrWhiteSpace(value)) ck.Expires = DateTime.Now.AddYears(-1);
      return ck;
}

or

```cs
Response.SetCookie(new HttpCookie("sid", sid) { Expires = DateTime.Now.AddDays(1) });
@ejohn20 ejohn20 transferred this issue from another repository Dec 11, 2018
@ejohn20
Copy link
Member Author

ejohn20 commented Dec 11, 2018

Here's another sink in .NET Core

CookieOptions options = new CookieOptions() {
   HttpOnly = true,
   Secure = true,
   SameSite = SameSiteMode.Strict,
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants