Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

The SecOps Group CAP Exam - Topic 12 Question 113 Discussion

Under the same-origin policy (also SOP), a web browser permits scripts contained in a web page to access data in another web page, but only if both web pages have the same origin. Which of the following pages are in the same origin as that of the below URL?http://www.example.com/dir/page2.htmlhttp://www.example.com/dir/other.htmlhttp://www.example.com:81/dir/other.htmlhttp://www.example.com/dir/other.htmlhttp://en.example.com/dir/other.html
A) 1 Only
B) 1 and 2
C) 1, 3 and 4
D) None of the above

The SecOps Group CAP Exam - Topic 12 Question 113 Discussion

Actual exam question for The SecOps Group's CAP exam
Question #: 113
Topic #: 12
[All CAP Questions]

Under the same-origin policy (also SOP), a web browser permits scripts contained in a web page to access data in another web page, but only if both web pages have the same origin. Which of the following pages are in the same origin as that of the below URL?

http://www.example.com/dir/page2.html

http://www.example.com/dir/other.html

http://www.example.com:81/dir/other.html

http://www.example.com/dir/other.html

http://en.example.com/dir/other.html

Show Suggested Answer Hide Answer
Suggested Answer: A

The Same-Origin Policy (SOP) is a fundamental security mechanism in web browsers that restricts how a document or script loaded from one origin can interact with resources from another origin. An origin is defined by the combination of protocol, host, and port. Two pages have the same origin if their protocol (e.g., http://), host (e.g., www.example.com), and port (default is 80 for HTTP) match exactly. The given URL is http://www.example.com/dir/page2.html, which uses HTTP, host www.example.com, and the default port 80.

Option 1 ('http://www.example.com/dir/other.html'): Matches the protocol (http), host (www.example.com), and port (default 80), so it is in the same origin.

Option 2 ('http://www.example.com:81/dir/other.html'): Differs in port (81 vs. default 80), so it is a different origin.

Option 3 ('http://www.example.com/dir/other.html'): Identical to Option 1, matching protocol, host, and port, so it is in the same origin. However, since it's a duplicate of Option 1 in the list, it doesn't add a new page.

Option 4 ('http://en.example.com/dir/other.html'): Differs in host (en.example.com vs. www.example.com), so it is a different origin.

Since the question asks which pages are in the same origin, and only Option 1 (and its duplicate Option 3) matches, the correct answer is A ('1 Only'), considering unique pages. The CAP syllabus covers SOP under 'Client-Side Security' and 'Cross-Origin Resource Sharing (CORS).'


Contribute your Thoughts:

0/2000 characters
Denise
4 days ago
I practiced a similar question where we had to identify same-origin URLs, and I think it was just the first two that matched here.
upvoted 0 times
...
Lili
9 days ago
I'm a bit unsure about option 3 since it has a different port. Does that mean it's not the same origin?
upvoted 0 times
...
Jeanice
14 days ago
I remember that the same-origin policy is all about matching the protocol, domain, and port. So, I think options 1 and 2 are definitely the same origin.
upvoted 0 times
...

Save Cancel