{"id":9790,"date":"2024-12-17T08:55:42","date_gmt":"2024-12-17T08:55:42","guid":{"rendered":"https:\/\/cloudkul.com\/blog\/?p=9790"},"modified":"2024-12-17T08:55:44","modified_gmt":"2024-12-17T08:55:44","slug":"what-is-the-same-origin-policy","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/","title":{"rendered":"What is the Same Origin Policy?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Today, New browsers provide many built-in security mechanisms to <a href=\"https:\/\/cloudkul.com\/blog\/phishing-cyber-attack\/\">protect against cyberattacks<\/a>. The <a href=\"https:\/\/cloudkul.com\/blog\/content-security-policy-protect-your-web-applications\/\">Content-Security-Policy<\/a>, Cookies Policy, and Same Origin Policy are a few of them.<\/p>\n\n\n\n<p>These built-in mechanisms can not protect us fully, but they provide an extra layer of security that can make hackers work hard.<\/p>\n\n\n\n<p>Here we are going to discuss a browser feature <strong>SOP (Same-origin policy).<\/strong> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Same Origin Policy<\/h2>\n\n\n\n<p>Before SOP, we need to understand &#8220;What is origin&#8221;. In this context, origin denotes the exact location of a specific resource such as script, documents, etc.<\/p>\n\n\n\n<p>Mainly origin consists of three elements, The hostname (test.com), the protocol (HTTP or HTTPS), and the ports (80, 443, 8080).<\/p>\n\n\n\n<p>At the time of SOP checks, the browser compares the origin location with the requested resource location.<\/p>\n\n\n\n<p><strong>EXAMPLE: <\/strong> Let&#8217;s compare the origin location of this <strong>http:\/\/old.test.com\/dir\/<\/strong> with tables.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>URL<\/strong><\/td><td><strong>Result<\/strong><\/td><td><strong>Reason<\/strong><\/td><\/tr><tr><td><strong>http:\/\/old.test.com\/<\/strong>dir2\/index.html<\/td><td>Same-origin<\/td><td>Same host, protocol, port (only the path differs)<\/td><\/tr><tr><td><strong>https:\/\/old.test.com\/<\/strong>dir2\/<\/td><td>Failure<\/td><td>Different protocol<\/td><\/tr><tr><td><strong>http:\/\/old.test.com<\/strong>\/dir\/other.html<\/td><td>Same-origin<\/td><td>only the path differs<\/td><\/tr><tr><td><strong>http:\/\/old.test.com:81\/<\/strong>dir\/page.html<\/td><td>Failure<\/td><td>Different Port no.<\/td><\/tr><tr><td><strong>http:\/\/new.test.com\/<\/strong>dir\/page.html<\/td><td>Failure<\/td><td>Different Hostname<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The same-origin policy is an important security feature of any browser.<\/p>\n\n\n\n<p>Its main purpose is to restrict <a href=\"https:\/\/cloudkul.com\/blog\/magento-2-cors-secure-your-magento2-store-from-cors-attack\/\">cross-origin resource sharing <\/a>like documents, scripts, or media files from one origin to a different origin. <\/p>\n\n\n\n<p>SOP is applicable for a script, and documents, It means resources like CSS, Images, etc. can be accessed across origins via the corresponding HTML tags.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>A browser can load and display resources from multiple sites and can embed multiple iframes from different sites. <\/p>\n\n\n\n<p>If there is no restriction on the browser, a script can be compromised by a hacker, and the script could expose everything in a user&#8217;s browser. <\/p>\n\n\n\n<p>Here, SOP acts as a gatekeeper and restricts read access to a resource loaded from a different origin.<\/p>\n\n\n\n<p>Secure your E-commerce store with&nbsp;<a href=\"https:\/\/webkul.com\/\">Webkul<\/a> through its&nbsp;<a href=\"https:\/\/store.webkul.com\/Ecommerce-Security-Audit-Basic-Plan.html\">basic security module<\/a>.<\/p>\n\n\n\n<p><strong>In case of any help or query, please&nbsp;<a href=\"https:\/\/cloudkul.com\/contact\/\">contact<\/a>&nbsp;us or raise a&nbsp;<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\">ticket<\/a>.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Today, New browsers provide many built-in security mechanisms to protect against cyberattacks. The Content-Security-Policy, <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[87,340,1],"tags":[306,231,587,89],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is the Same Origin Policy? - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is the Same Origin Policy? - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"Introduction Today, New browsers provide many built-in security mechanisms to protect against cyberattacks. The Content-Security-Policy, [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-17T08:55:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-17T08:55:44+00:00\" \/>\n<meta name=\"author\" content=\"Ekansh Saini\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/\",\"name\":\"What is the Same Origin Policy? - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2024-12-17T08:55:42+00:00\",\"dateModified\":\"2024-12-17T08:55:44+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/ba7305367206650102581ddeea6e2263\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is the Same Origin Policy?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/ba7305367206650102581ddeea6e2263\",\"name\":\"Ekansh Saini\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/15503d9e186f868b9a1d0ed1b458f512?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/15503d9e186f868b9a1d0ed1b458f512?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Ekansh Saini\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/ekansh-saini306\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is the Same Origin Policy? - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/","og_locale":"en_US","og_type":"article","og_title":"What is the Same Origin Policy? - Cloudkul","og_description":"Introduction Today, New browsers provide many built-in security mechanisms to protect against cyberattacks. The Content-Security-Policy, [...]","og_url":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/","og_site_name":"Cloudkul","article_published_time":"2024-12-17T08:55:42+00:00","article_modified_time":"2024-12-17T08:55:44+00:00","author":"Ekansh Saini","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/","url":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/","name":"What is the Same Origin Policy? - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2024-12-17T08:55:42+00:00","dateModified":"2024-12-17T08:55:44+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/ba7305367206650102581ddeea6e2263"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/what-is-the-same-origin-policy\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What is the Same Origin Policy?"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/ba7305367206650102581ddeea6e2263","name":"Ekansh Saini","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/15503d9e186f868b9a1d0ed1b458f512?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/15503d9e186f868b9a1d0ed1b458f512?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Ekansh Saini"},"url":"https:\/\/cloudkul.com\/blog\/author\/ekansh-saini306\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/9790"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=9790"}],"version-history":[{"count":14,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/9790\/revisions"}],"predecessor-version":[{"id":19049,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/9790\/revisions\/19049"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=9790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=9790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=9790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}