1. Home
  2. Explore
  3. Computer Science
  4. Web Security: CSRF

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Web Security: CSRF

  • 10Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Web Attack Types

What are the three major web attacks discussed, and which one is considered lesser-known?

10 questions

  1. 1

    What are the three major web attacks discussed, and which one is considered lesser-known?

    Model answer

    The three major web attacks are Cross-Site Scripting (XSS), SQL injection, and Cross-Site Request Forgery (CSRF). CSRF is highlighted as the lesser-known of the three.

    Explanation

    The text explicitly names Cross-Site Scripting (XSS), SQL injection, and Cross-Site Request Forgery (CSRF) as the 'three big web attacks'. It then states that CSRF 'is the lesser-known one', indicating its relative obscurity compared to the other two among many developers.

  2. 2

    How do web browsers typically handle code given to them, and what implication did this have in the early days of the web versus today?

    Model answer

    Web browsers are trusting and run any code given to them without judging its maliciousness. In the early web, this was less problematic as online banking was absent, but today it poses a significant risk due to sensitive online transactions.

    Explanation

    The text explains that web browsers 'don't cast a value judgment on it. They can't tell if it's malicious. They will just run it.' It notes that 'in the early days of the web, when there wasn't online banking,' this was 'kind of okay,' but 'nowadays, bit more complicated' due to the increased complexity and sensitive nature of online activities.

  3. 3

    Differentiate between GET and POST requests in terms of their typical use cases and how data is transmitted.

    Model answer

    GET requests are typically used for fetching data, with parameters visible in the URL bar (e.g., YouTube video IDs), making them suitable for sharing. POST requests are used for writing data or performing actions, with data bundled in the request body, not the URL, to prevent unintended repetition upon refresh or sharing.

    Explanation

    The text defines GET requests as being 'designed for fetching data' and having data 'in the address bar' (like YouTube URLs), which can be 'copy and paste[d]'. In contrast, POST requests are described as bundling data 'along with the request, but not in the address bar,' meant 'for writing things, things that happen once,' to avoid 'do[ing] the same thing twice' on refresh or making actions sharable.

  4. 4

    Why is it problematic for sensitive actions like transferring money to use a GET request instead of a POST request?

    Model answer

    Using a GET request for sensitive actions would expose critical data like account numbers and amounts directly in the URL. This would allow malicious actors to easily copy, share, and trick users into performing unauthorized transactions by simply clicking a manipulated link.

    Explanation

    The text explains that if sensitive data were in the URL, as with GET, 'you can't copy and paste that to a friend, and they all post the same comment' – or, in a banking context, transfer the same money. It implies that the visibility and shareability of GET request parameters make them unsuitable for actions that 'happen once' and involve sensitive user input.

  5. 5

    Describe the core mechanism of a Cross-Site Request Forgery (CSRF) attack using the example of a malicious online bank form.

    Model answer

    In a CSRF attack, a malicious website embeds a hidden form that mimics a legitimate, sensitive action (like a bank transfer) from another site. When a user, already logged into the legitimate site in another tab, visits the malicious page, the hidden form automatically submits a request to the legitimate site, performing the unauthorized action without the user's knowledge or consent.

    Explanation

    The text describes how a 'really bad online bank form' for sending money could be replicated on a 'fake webpage somewhere else.' This malicious form can 'hide some of those details' like account number and amount, pre-filling them. When a user, 'already been authorized' by logging into the bank in 'another tab,' visits the malicious site, the hidden form submits a POST request to the bank, which processes it because the user is authenticated, leading to unauthorized money transfer.

  6. 6

    How can modern web technologies, specifically background processes, exacerbate a CSRF attack?

    Model answer

    Modern web technologies allow requests to be sent silently in the background without requiring a user click or a full page reload. This means a malicious site can automatically submit a CSRF request as soon as the page loads, making the attack entirely invisible to the user.

    Explanation

    The text notes that 'when you type a comment on YouTube, you click "Post". It doesn't load the whole page back... Now, it does it all in the background, silently.' It then states that this 'would work with this too. You wouldn't even need to click the 'go' button. It could just be that when I load up my site... it just creates that form in the background and sends off that request.' This invisibility makes the attack harder to detect by the victim.

  7. 7

    What is the intended purpose of the HTTP Referer header in preventing CSRF, and what challenges does it face?

    Model answer

    The Referer header is designed to include the originating site's URL when a link is clicked or a form is submitted, allowing the target server to verify if the request came from an expected, legitimate source. However, its effectiveness is limited because privacy tools or ad blockers can frequently block or omit this header, leading to user complaints if sites strictly enforce its presence.

    Explanation

    The text explains the Referer header 'means, that when you click a link or submit a form, it includes the things it says Referer: this site. So you know if the form request is coming from the actual online bank... and not some malicious site elsewhere.' The challenge is 'if you start checking for that, a lot of users start complaining because that Referer header isn't always sent like it should' due to 'adverb blocker or some kind of privacy tool'.

  8. 8

    Explain how a 'one-time key' (nonce) effectively prevents CSRF attacks.

    Model answer

    A one-time key (nonce) works by generating a unique, random token for each form instance. This token is embedded in the hidden form and stored by the server. Upon submission, the server verifies if the received token matches the expected one for that user and form. A malicious site cannot guess or obtain this dynamic token, thus invalidating any forged requests.

    Explanation

    The text describes the nonce as 'generating a unique code... a random string of characters, each time you create the form. And then storing that [string of characters] and saying right, anything that comes back, anything that I see, needs to have this token with it.' This token is 'Completely hidden, invisible to the user.' A malicious blog 'can't possibly know what this token is, because it changes per user and it changes every time the form is requested,' so if 'you copy that form... I'll look at that token and I'll go: that's wrong. I'm not having that (?) and suddenly, Cross Site Request Forgery doesn't work anymore.'

  9. 9

    For what types of web forms or actions is using a one-time key (nonce) particularly crucial?

    Model answer

    Using a one-time key is crucial for any web forms that trigger permanent or sensitive actions, such as deleting an account, posting a comment, authorizing someone, or transferring money.

    Explanation

    The text explicitly states: 'So if you're designing web forms for anything which is permanent anything like deleting an account, posting a comment, authorizing someone, or even transferring money, if you're not using this, this is a pretty big security hole'.

  10. 10

    Why did CSRF 'go under the radar' for a long time compared to XSS and SQL injection?

    Model answer

    CSRF was less understood and recognized than XSS and SQL injection for a considerable period, resulting in many developers remaining unaware of this vulnerability despite its significant impact on web security.

    Explanation

    The text notes that XSS and SQL injection are widely known by web developers, but CSRF 'went under the radar for a long time, and there's still a lot of developers that don't know about it.' This indicates a past and continuing lack of awareness and understanding of this specific attack vector.

1 of 10
Question 1 of 10

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent