Quotes Icon

Andrew M.

Andrew M.

オペレーション担当副社長

"私たちは小規模な非営利団体のためにTeamPasswordを使用していますが、私たちのニーズにうまく対応しています。"

今すぐ始める

Table Of Contents

    Hardening web applications

    Cybersecurity Series: What is cross-site request forgery (CSRF) and how to defend against it

    August 31, 20224 min read

    Cybersecurity

    In our second article of this cybersecurity series, we will be taking a look to Cross-site request forgery (CSRF). As a password manager, TeamPassword takes pride in maintaining your password data secured from attackers, but passwords managers alone cannot keep you safe. It is necessary to be aware of the main attack vectors that hackers may use to exploit cybersecurity vulnerabilities and be mindful of them while browsing the Internet.

    What is cross-site request forgery and how can you defend against it?

    Table of Contents

      How does CRSF work? 

      Cross-site request forgery, abbreviated as XSRF or CSRF, is an attack that attempts to have users unknowingly execute actions on a web application for which they are currently authenticated. This attack is similar to the Cross-site scripting attacks (XSS), but it exploits a different type of trust: the trust that a web application has in an authenticated user.

      Using this type of attack, the hacker could, for example, change the user's email address or password in the vulnerable web application, transfer funds from the user's bank account, or gain control over the user's account.

      For the CRSF to work, four conditions need to happen:

      1. Cookie-based session handling.

      By definition, a cookie is a piece of data from a website that is stored within a web browser that the website can retrieve at a later time. Every time we log into a web application, a cookie is sent automatically to our browser so that the web application can verify our login. This way, we will be authenticated by this web application and we can take any actions we want within it. 

      2. No unpredictable request parameters.

      The action request (for example, changing the user's email address) does not contain any parameters whose values will be unknown to the attacker. 

      3. The user clicks the malicious URL.

      This is usually done by social engineering to trick the victim into clicking the URL that the attacker carefully crafted. Once clicked, the action request will be triggered without the user knowing it.

      4. The user must be logged in to the vulnerable web application.

      If the user is logged in to a vulnerable web application, the attacker can use the CRSF attack to exploit it, so it is always safer to log out before browsing the Internet.

      An Example of a CSRF Attack

      For example, let's say the user has logged in to an online banking web application. The user's browser will now have a session cookie that authenticates it in that web application.

      The user decides to browse their favorite forum while being logged into that web application. There, they stumble upon an interesting post with a link, and they click it. The link looked like this, but he didn't notice it at the time:

      <a href="http://vulnerable-bank.com/transfer_funds?acct=JOSE&amount=3000">Check it out!</a>

      Without them knowing, clicking the link has triggered a request action that sends the user's funds to the attacker's bank account.

      The request might look like this:

      POST /transfer_funds HTTP/1.1
      Host: vulnerable-bank.com
      Content-Type: application/x-www-form-urlencoded
      Cookie: SessionID=d3yght4s6
      
      acct=JOSE
      amount=3000

      How to prevent CSRF attacks?

      Prevention by End Users

      Although CSRF is fundamentally a problem with the web application, there are two main actions that end users can take to protect themselves:

      1. Before clicking on a link, always double-check that it leads you to a trustworthy website and that is not triggering any action you might not want to take.

      2. Remember to log off the website before visiting another, or clear the browser's cookies at the end of each session.

      Prevention by Web Developers

      For the software application itself, there are several ways to harden it to prevent this type of attack:

      1. Use secure tokens that the attacker would not know to embed in the link. The best way to achieve this is through a CSRF token. A CSRF token is a secure random token that is used to prevent CSRF attacks. An approach that is normally effective is to transmit the token to the client within a hidden field of an HTML form that is submitted using the POST method. The token will then be included as a request parameter when the form is submitted:

      <input type="hidden" name="csrf-token" value="{{ csrf_token }}" />
      

      2. Check the referring URL in requests received from end users and only accept requests originating from their own site.

      Conclusion

      Web applications are complex ecosystems, which makes it important for cybersecurity professionals to harden them against any type of attack. As an end user, it is always good to use reliable applications with certified security, especially if the application handles valuable data for you or your organization. At TeamPassword, we take security seriously, as we are the custodians of important password data. Join the hundreds of companies that trust us, and rest easy knowing that your data is in the right place.

      パスワードの安全性を高める

      パスワードを生成し、正しく管理させるための最適なソフトウェア

      TeamPassword Screenshot
      facebook social icon
      twitter social icon
      linkedin social icon
      関連記事
      hand holding phone with QR code and floating symbols

      Cybersecurity

      January 14, 20256 min read

      WiFi Password Generator

      Secure your WiFi network with our comprehensive guide on generating strong passwords, using QR codes for sharing, and ...

      Google Chrome logo with a cancel symbol on top

      Cybersecurity

      January 6, 20255 min read

      How to Disable Google Chrome's Password Manager in 3 Steps

      Keeping track of passwords has gotten out of hand. Chrome offers a built-in solution, Google Password Manager, which ...

      Pile of antique keys and a lock

      Cybersecurity

      January 4, 202511 min read

      Passkey vs. Password: Which Is Right for You?

      What's the difference between a passkey vs. password? In this guide, we answer this question and more so ...

      最新情報をお見逃しなく!

      このような投稿をもっと読みたい方は、ブログを購読してください。

      Promotional image