Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. CSRF question

CSRF question

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-nethelp
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephen Holdorf
    wrote on last edited by
    #1

    I am investigating a CSRF finding in asp.net c# code behind as shown in the following code:

    LinkButton LinkButtonControl = new LinkButton();
    LinkButtonControl.ID = Name;

    Now, I feel that the following code using ViewStateUserKey is the right approach:

    protected override OnInit(EventArgs e) {
    base.OnInit(e);
    if (User.Identity.IsAuthenticated)
    ViewStateUserKey = Session.SessionID; }

    However; another person I work with thinks that the Httputility.htmlencode method is the best way to correct the problem. First I don't know if the Httputility.htmlencode method is the best way and if so I would I use it?

    A Richard DeemingR 2 Replies Last reply
    0
    • S Stephen Holdorf

      I am investigating a CSRF finding in asp.net c# code behind as shown in the following code:

      LinkButton LinkButtonControl = new LinkButton();
      LinkButtonControl.ID = Name;

      Now, I feel that the following code using ViewStateUserKey is the right approach:

      protected override OnInit(EventArgs e) {
      base.OnInit(e);
      if (User.Identity.IsAuthenticated)
      ViewStateUserKey = Session.SessionID; }

      However; another person I work with thinks that the Httputility.htmlencode method is the best way to correct the problem. First I don't know if the Httputility.htmlencode method is the best way and if so I would I use it?

      A Offline
      A Offline
      Anil Vaghasiya
      wrote on last edited by
      #2

      Hello, Very nice question i'm also interested in Website Security Please follow the Below link that might be helpful. Hack Proof Your ASP.NET Application Part 3 (Cross Site Request Forgery)[^] http://www.asp.net/mvc/overview/security/xsrfcsrf-prevention-in-aspnet-mvc-and-web-pages[^] http://www.asp.net/web-api/overview/security/preventing-cross-site-request-forgery-%28csrf%29-attacks[^]

      1 Reply Last reply
      0
      • S Stephen Holdorf

        I am investigating a CSRF finding in asp.net c# code behind as shown in the following code:

        LinkButton LinkButtonControl = new LinkButton();
        LinkButtonControl.ID = Name;

        Now, I feel that the following code using ViewStateUserKey is the right approach:

        protected override OnInit(EventArgs e) {
        base.OnInit(e);
        if (User.Identity.IsAuthenticated)
        ViewStateUserKey = Session.SessionID; }

        However; another person I work with thinks that the Httputility.htmlencode method is the best way to correct the problem. First I don't know if the Httputility.htmlencode method is the best way and if so I would I use it?

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        The HtmlEncode method is one of a group of methods used to prevent XSS (Cross-Site Scripting)[^] - that's where you take input from the user and write it to the output without properly encoding it. The method provides zero protection from a CSRF vulnerability. CSRF (aka XSRF) is a Cross-Site Request Forgery[^] vulnerability. That's where a script on another site can force the user's browser to make an authenticated request to your site without the user's knowledge. It looks like Anil has already given you some good links for dealing with this class of vulnerability.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups