Cross-Origin Resource Sharing Flashcards

(20 cards)

1
Q

True or False

Many web apps don’t connect to each other and are independent from each other’s resources/services.

A

False

Many web apps connect to each other and rely on each other’s resources/services.

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

Restricts how a document/script from one origin can interact with a resource from another origin.

A

Same-Origin Policy

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

2 web pages have the same origin if they have the same:

A
  1. Protocol
  2. Host/Domain
  3. Port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A page attempting to interact with a resource from a different origin is making a ___________

A

Cross-Origin Request

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

Is this a Cross-Origin Request?

http://myapp.com -> https://myapp.com

A

Yes, because http is different from https.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • This restriction is done by the browser, not by the website itself.
  • Browsers restrict cross-origin HTTP requests initiated within scripts.
A

Same-Origin Policy

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

Exceptions

A
  • Embedded requests (<img src=”...” /><link href=”...” />)
  • Cross-Origin writes (submitting data to a different origin)

Example:
<img src="https://bit.ly/2EZkilW" />

<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com
/bootstrap/4.1.0/css/bootstrap.min.css"
>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why restrict cross-origin access?

A

Cross-origin requests are a vector for online attacks. They are a way to steal cookies, and can give an attacker access to a user’s sensitive information if they are not careful.
So they are blocked by default.

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

______________ is a system that allows resources to be accessed across different origins.

A

Cross-Origin Resource Sharing (CORS)

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

True or False

The Access-Control-* headers are used by clients and servers to determine if the client can access the server’s resources.

A

True

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

Access-Control-Allow-Origin

A

Specifies which origins are allowed access

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

Access-Control-Allow-Credentials

A

Indicates if sending credentials are allowed

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

Access-Control-Allow-Methods

A

Indicates which HTTP methods are allowed to be used for incoming requests

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

Access-Control-Allow-Headers

A

Indicates which headers are allowed to be used for incoming requests

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

Some cross-origin requests trigger a ______________

A

preflight request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  • ______________ are automatically issued by the browser before sending some kinds of cross-origin requests.
  • It is a ‘preflight’ check to see if the actual request will be accepted and processed.
A

Preflight requests

17
Q

All preflight requests are OPTIONS HTTP requests with 3 particular headers

A
  1. Access-Control-Request-Method
  2. Access-Control-Request-Headers
  3. Origin
18
Q

Before the browser sends the actual POST request, it sends an ________ request, to ask if the POST request will be allowed.

19
Q

True or False

In general, requests that will cause some sort of change in the server’s data trigger a tralalero tralala.

A

False

In general, requests that will cause some sort of change in the server’s data trigger a preflight request.

20
Q

True or False

“Simple” requests don’t trigger a preflight and only look for the Access-Control-Allow-Origin header in the response.