Cybersecurity 11 Feb (part 1)
Cybersecurity 11 Feb (part 1)
Security
Dr. Uddipana
Dowerah
Web Application Security
Web Site Vulnerabilities
• XSS – Cross-site scripting
• Bad web site sends innocent victim a script that steals information from
an honest web site
• SQL Injection
• Browser sends malicious input to server
• Bad input checking leads to malicious SQL query
• Buffer Overflow
• A buffer overflow occurs when a program writing data to a buffer
overloads that buffer's capacity
Cross-Site Scripting (XSS)
• Attacker attaches code onto a legitimate website that will execute when the
victim loads the website.
• How to insert code - either added to the end of a URL or posted directly
onto a page that displays user-generated content.
• Client-side code injection attack (JavaScript code that runs on a user’s machine)
• This code can then be used to access a user's private information, such as
cookies, session tokens, and other sensitive data.
Cross-Site Scripting (XSS)
How Does XSS Work?
• By exploiting a vulnerability in a website, which results in it returning
malicious JavaScript code when users visit it.
• The execution of malicious code occurs inside the user’s browser, enabling
the attacker to compromise the victim’s interaction with the site.
• The victim loads a webpage and the malicious code copies the user’s
cookies
• The code then sends an HTTP request to an attacker’s webserver with the
stolen cookies in the body of the request.
• The attacker can then use those cookies to impersonate the user on that
website
• for the purpose of a social engineering attack
• to access bank account numbers or other sensitive data.
Why would XSS occur?
• Happens when a web application takes user input and includes it in the
webpage without properly validating or encoding it.
• If the website does not properly filter out <script> tags, an attacker could
submit <script>alert('You have been hacked!');</script>
• When another user views the page, the script runs in their browser.
• Sanitize Inputs: Remove harmful <script> tags and other risky elements.
• Escape Output: Convert special characters (<, > etc.) into HTML entities.
• The <script> tag is escaped as <script>
• this would appear as <script>, instead of being executed as
JavaScript.
Since '1'='1' is always true, the attacker can log in without knowing the real
password.
How SQL Injection Works
• Login forms: A user enters this malicious input instead of a normal
username
• Example:
– User logs in to bank.com. Forgets to sign off.
– Session cookie remains in browser state
– The attacker sends the user an email or posts a link on a website, like
<form name=F action=http://bank.com/BillPay.php>
<input name=recipient value=badguy> …
<script> document.F.submit(); </script>
– The user, who is still logged into bank.com, clicks the link
– browser sends the user authentication cookie along with the request
• Transaction will be successful
• Problem:
– The browser is a confused deputy; it is serving both the websites and the
user and gets confused who initiated a request
CSRF Prevention Techniques
Overflow Occurs:
• If a user inputs more data than expected, it overwrites adjacent memory
locations.