The Application Layer Flashcards

1
Q

What is the application layer?

A

the application layer is not theapplication itself, but rather a set of protocols which provide communication services to applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do application layer protocols focus on?

A

Application layer protocols rely on the protocols at the layers below them to ensure that a message gets to where it is supposed to, and focus instead on the structure of that message and the data that it should contain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the protocols used at the application layer?

A

There are a wide number of different application layer protocols for different use cases including HTTP, SMTP, FTP, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a URI?

A

Uniform Resource Identifier(URI), is a string of characters which identifies a particular resource.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is HTTP?

A

Hypertext Transfer Protocol(HTTP) is the set of rules which provide uniformity to the way resources on the web are transferred between applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What model of communication does HTTP use?

A

HTTP follows a simple model where a client makes arequestto a server and waits for aresponse. Hence, it’s referred to as arequest response protocol

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is DNS?

A

The Domain Name System provides a way to look up unknown server IP addresses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What steps does DNS use?

A
  1. Enter a URL likehttp://www.google.cominto your web browser’s address bar.
  2. The browser creates an HTTP request, which is packaged up and sent to your device’s network interface.
  3. If your device already has a record of the IP address for the domain name in its DNS cache, it will use this cached address. If the IP address isn’t cached, a DNS request will be made to the Domain Name System to obtain the IP address for the domain.
  4. The packaged-up HTTP request then goes over the Internet where it is directed to the server with the matching IP address.
  5. The remote server accepts the request and sends a response over the Internet back to your network interface which hands it to your browser.
  6. Finally, the browser displays the response in the form of a web page.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does it mean for a protocol to be stateless?

A

A protocol is said to bestatelesswhen it’s designed in such a way that each request/response pair is completely independent of the previous one. HTTP is a stateless protocol.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What affect is caused by HTTP being stateless?

A

Because of HTTPs statelessness, it is challenging to build stateful web applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a url?

A

Uniform Resource Locator orURL, is the most frequently used part of the general concept of a Uniform Resource Identifier orURI, which specifies how resources are located.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the components of the URL:
HTTP://www.example.com:88/home?item=book

A
  • http: Thescheme. It always comes before the colon and two forward slashes and tells the web client how to access the resource. In this case it tells the web client to use HTTP to make a request.
  • www.example.com: Thehost. It tells the client where the resource is hosted or located.
  • :88: Theportor port number. It is only required if you want to use a port other than the default.
  • /home: Thepath. It shows what local resource is being requested. This part of the URL is optional.
  • ?item=book: Thequery string, which is made up ofquery parameters. It is used to send data to the server. This part of the URL is also optional.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are query strings?

A

It is used to send data to the server as part of the URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is URL encoding?

A

URLs are designed to accept only certain characters in the standard 128-characterASCII character set. Reserved or unsafe ASCII characters have to be encoded.

URL encoding replaces these non-conforming characters with a%symbol followed by two hexadecimal digits that represent the equivalent UTF-8 character.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the limitations of query strings?

A
  • Query strings have a maximum length. Therefore, if you have a lot of data to pass on, you will not be able to do so with query strings.
  • The name/value pairs used in query strings are visible in the URL. For this reason, passing sensitive information like username or password to the server in this manner is not recommended.
  • Space and special characters like&cannot be used with query strings. They must be URL encoded, which we’ll talk about next.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When must characters be URL encoded?

A
  1. They have no corresponding character within the standard ASCII character set. Note that this means all extended ASCII characters as well as 2-, 3-, and 4-byte UTF-8 characters.
  2. The use of the character is unsafe since it may be misinterpreted or modified by some systems. For example,%is unsafe since it is used to encode other characters. Other unsafe characters include spaces, quotation marks, the#character,<and>,{and},[and], and~, among others.
  3. The character is reserved for special use within the URL scheme. Some characters are reserved for a special meaning; their presence in a URL serves a specific purpose. Characters such as/,?,:,@, and&are all reserved and must be encoded. For example&is reserved for use as a query string delimiter.:is also reserved to delimit host/port components and user/password.
17
Q

What are the 2 main HTTP request methods?

A

GET & POST

18
Q

What is a GET request used for?

A
  • GET requests are used to retrieve a resource, and most links are GETs.
  • The response from a GET request can be anything, but if it’s HTML and that HTML references other resources, your browser will automatically request those referenced resources. A pure HTTP tool will not.
19
Q

What is an HTTP POST request used for?

A

POSTis used when you want to initiate some action on the server, or send data to a server.

TheHTTPbody contains the data that is being transmitted in an HTTP message and is optional. You can think of the body as the letter enclosed in an envelope, to be posted.

20
Q

What are HTTP headers?

A

HTTP headers allow the client and the server to send additional information during the HTTP request/response cycle. Headers are colon-separated name-value pairs that are sent in plain text. For example, when you click a button to submit a form, Your browser issues an initialPOSTrequest, gets a response with aLocationheader, then issues another request without any action from you, then displays the response from that second request.

21
Q

What is a response status code?

A

Thestatus codeis a three-digit number that the server sends back after receiving a request signifying the status of the request.

22
Q

What is response code 302?

A

this happens when the resource has been moved

23
Q

What is response code 404

A

resource not found

24
Q

What is response code 500?

A

Internal server error

25
Q

What are response headers?

A

Response headers offer more information about the resource being sent back. Common headers include location, server, and content-encoding.

26
Q

What is a cookie?

A

CookiesorHTTP cookies, are small files stored in the browser and contain the session information. actual session data is stored on the server but the client side cookie is compared with the server-side session data on each request to identify the current session

27
Q

How are cookies established?

A

When you first access a website, the response will include a set cookie header, this will set the cookie which will be sent back with each subsequent get request.

28
Q

Where is session data stored?

A

session data is generated and stored on the server-side and the session id is sent to the client in the form of a cookie. That cookie is sent back and used as a “key” to the session data stored server side.

29
Q

What is AJAX? why is it useful?

A

Asynchronous JavaScript and XML. When AJAX is used, all requests sent from the client are performedasynchronously. Instead of the browser refreshing and processing the response, the response is processed by a callback function, which is usually some client-side JavaScript code.

30
Q

What is HTTPS?

A

HTTPS sends messages through a cryptographic protocol calledTLSfor encryption. These cryptographic protocols use certificates to communicate with remote servers and exchange security keys before data encryption happens.

31
Q

What is the Same-Origin Policy?

A

Same-origin policy permits unrestricted interaction between resources originating from the same origin, but restricts certain interactions between resources originating from different origins. Byorigin, we mean the combination of the scheme, host, and port.

Whatistypically restricted are cross-origin requests where resources are being accessed programmatically using APIs such asXMLHttpRequestorfetch.

This is an important defense against Session Hijacking

32
Q

What is Session Hijacking?

A

Session hijacking takes place when an attacker get ahold of a session ID, allowing them to access the web application.

33
Q

How can we defend against session hijacking?

A
  • resetting sessions. With authentication systems, this means a successful login must render an old session id invalid and create a new one. With this in place, on the next request, the victim will be required to authenticate. At this point, the altered session id will change, and the attacker will not be able to have access. Most websites implement this technique by making sure users authenticate when entering any potentially sensitive area, such as charging a credit card or deleting the account.
  • setting an expiration time on sessions. Expiring sessions after, say 30 minutes, gives the attacker a far narrower window to access the app.
  • using HTTPS across the entire app to minimize the chance that an attacker can get to the session id.
34
Q

What is Cross-Site Scripting?

A

XSS happens when you allow users to input HTML or JavaScript that ends up being displayed by the site directly. If not sanitized or escaped, user input will be injected into the page contents, andthe browser will interpret the HTML and JavaScript and execute it.

35
Q

How can we defend against cross site scripting?

A
  • sanitizing user input. This is done by eliminating problematic input, such as
     tags, or by disallowing HTML and JavaScript input altogether.
  • Escaping all user input data when displaying it. If you do need to allow users to input HTML and JavaScript, then when you print it out, make sure to escape it so that the browser does not interpret it as code.
36
Q

What is the difference between HTTP & TCP/IP

A

HTTP is actually relying on a TCP/IP connection. HTTP operates at the application layer and is concerned with structuring the messages that are exchanged between applications; it’s actually TCP/IP that’s doing all the heavy lifting and ensuring that the request/response cycle gets completed between your browser and the server.

37
Q

What are the 3 primary pieces of server side infrastructure?

A
  • web server: typically a server that responds to requests for static assets: files, images, css, javascript, etc. These requests don’t require any data processing, so can be handled by a simple web server.
  • application server: typically where application or business logic resides, and is where more complicated requests are handled. This is where your server-side code lives when deployed.
  • data store: like a relational database, to retrieve or create data. Data stores can also be simple files, key/value stores, document stores, etc. can be used topersistour data between stateless request/response cycles.