i'm solving issue of webform application security issue.
security team is said default path="/" is vulnerable
i'm solving issue of webform application security issue.
security team is said default path="/" is vulnerable
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Mar 8, 2023, 7:09 AM EST
suppose you have a.aspx, b.aspx and c.aspx pages. In which only a.aspx requires cookies. b and c pages have nothing to do with the cookie. so, if a user make a request to b or c then the cookie should not go to the server from the user's browser.
For default path , it doesn't matter in which page the user is currently, the browser will send the cookie to server with each request.
Are you getting the point?
The browser just mathes the domain and the url to send a request, for example, suppose you are logged in to c# corner and on another tab there is a website opened name it webA, on webA there is button win 10000$, suppose the button is inside any form like
win 10000$now when you will click on win 1000$, as you are logged in to c# corner and you are in answer section page ,from another tab, then the cookie of c# corner (from answer page (if cookie path is default)) will also be sent to the server and the c#corner would think the request is from c#corner website and not from another website.
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 8, 2023, 4:35 AM EST
Hello Tahir,
In ASP.NET, when you set the cookie path to "/", it means that the cookie will be accessible from all pages on the website, including pages in subdirectories. This can be a security issue because it makes it easier for an attacker to steal the cookie and use it to impersonate the user.
To mitigate this vulnerability, you can set the cookie path to a more specific path that corresponds to the portion of the website that requires the cookie. For example, if the
HttpCookie myCookie = new HttpCookie("myCookie"); myCookie.Path = "/"; Response.Cookies.Add(myCookie);Refere below link:
https://stackoverflow.com/questions/576535/cookie-path-and-its-accessibility-to-subfolder-pages
Thanks
Naimish Makwana
Vishal JoshiRank #377 · 6.7K reputationPosted Mar 8, 2023, 5:56 AM EST
Hello
We can use some Web.config settings to restrict the domain of our cookies.
We can restrict the path, we’ll need to add some server-side code. How we handle this is dependent mainly on the structure of our application, but the example function below allows us to specify the path from a value in our Web.config when we set a cookie.
private void SetCookie(string Key, string Value) { Response.Cookies[Key].Value = Value; Response.Cookies[Key].Path = _ ConfigurationManager.AppSettings["UserDefinedCookiePathFilter"]; }Thanks