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

Posted by Johnna on Aug 18, 2026 at 06:14 PM

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

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).'


Get Premium CAP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
12 comments · newest first
CH
Chandra 3 days ago
But what about C) 1, 3 and 4? The port is different in 3.
AI
Aimee 8 days ago
Agreed! Same protocol and domain.
TE
Tequila 13 days ago
I think it's B) 1 and 2. They match the origin.
AN
Annabelle 18 days ago
No way, I thought all those were fine!
ME
Meaghan 23 days ago
I thought subdomains counted as different origins?
ME
Mendy 29 days ago
Wait, is 3 really not the same? The port is different!
NO
Novella 1 month ago
Definitely B) 1 and 2!
EL
Elenora 1 month ago
Same origin means same protocol, host, and port!
FL
Fletcher 1 month ago
I feel like option 4 is also the same origin since the path is the same, but I'm not completely confident about the subdomain in option 5.
DE
Denise 2 months 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.
LI
Lili 2 months ago
I'm a bit unsure about option 3 since it has a different port. Does that mean it's not the same origin?
JE
Jeanice 2 months 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.
0/2000 characters

Save Cancel