diff options
author | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:50:24 +0100 |
---|---|---|
committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:50:24 +0100 |
commit | 2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e (patch) | |
tree | 86ab4534d10092b293d4b7ab169fe1a8a2421bfa /files/pt-pt/web/seguranca | |
parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
download | translated-content-2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e.tar.gz translated-content-2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e.tar.bz2 translated-content-2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e.zip |
unslug pt-pt: move
Diffstat (limited to 'files/pt-pt/web/seguranca')
-rw-r--r-- | files/pt-pt/web/seguranca/index.html | 16 | ||||
-rw-r--r-- | files/pt-pt/web/seguranca/palavras-passe_inseguras/index.html | 157 | ||||
-rw-r--r-- | files/pt-pt/web/seguranca/same-origin_policy/index.html | 263 |
3 files changed, 0 insertions, 436 deletions
diff --git a/files/pt-pt/web/seguranca/index.html b/files/pt-pt/web/seguranca/index.html deleted file mode 100644 index 4a555a18f6..0000000000 --- a/files/pt-pt/web/seguranca/index.html +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Segurança da Web -slug: Web/Seguranca -tags: - - Landing - - Segurança - - Web -translation_of: Web/Security ---- -<div class="summary"> -<p><span class="seoSummary">É crítico assegurar que o seu site da Web ou aplicação da Web aberta é segura. Até erros simples no seu código podem resultar na divulgação de informação privada, e as pessoas más estão por aí a tentar encontrar meios para roubar dados. Estes articgos proporcionam informação que poderá ajudá-lo a proteger o seu código code.</span></p> -</div> - -<p>{{LandingPageListSubpages}}</p> - -<p>{{QuickLinksWithSubpages}}</p> diff --git a/files/pt-pt/web/seguranca/palavras-passe_inseguras/index.html b/files/pt-pt/web/seguranca/palavras-passe_inseguras/index.html deleted file mode 100644 index 239618d225..0000000000 --- a/files/pt-pt/web/seguranca/palavras-passe_inseguras/index.html +++ /dev/null @@ -1,157 +0,0 @@ ---- -title: Palavras-passe inseguras -slug: Web/Seguranca/Palavras-passe_inseguras -tags: - - Insegura - - Intermediária - - Segurança - - Web - - palavra-passe - - palavras-passe -translation_of: Web/Security/Insecure_passwords ---- -<p class="summary">Apresentar formulários de sessão usando protocolo HTTP é especialmente perigoso por causa da grande variedade de ataques que podem ser utilizados contra os mesmos para extrair a palavra-passe de um utilizador. As escutas ocultas de rede podem roubar a palavra-passe de um utilizador ao "farejar" a rede ou modificar a página servida no tráfego. Esta página detalha os mecanismos de segurança que o Firefox criou para alertar os utilizadores e programadores dos riscos que envolvem as palavras-passe inseguras e o roubo da mesma<span class="seoSummary">.</span></p> - -<p>O protocolo <a href="https://en.wikipedia.org/wiki/HTTP_Secure" title="https://en.wikipedia.org/wiki/HTTP_Secure">HTTPS</a> foi desenhado para proteger os dados dos utilizadores de escutas (confidencialidade) e modificação (integridade) na rede. As páginas que lidam com dados de utilizador, deveriam idealmente usar HTTPS para proteger os utilizadores de ataques. Caso uma página use HTTP em vez de HTTPS, roubar informação acerca do utilizador (como os dados de autenticação) é um processo trivial. Esta técnica ficou famosamente demonstrada por <a href="https://codebutler.github.io/firesheep/" title="http://codebutler.com/firesheep/">Firesheep</a>.</p> - -<p>Para resolver este problema, é necessário instalar e configurar um certificado SSL/TLS no servidor onde está alojada a página. Existem vários emissores deste tipo de certificados sendo que uns são grátis e outros pagos. Se está a usar uma plataforma cloud, é possível que a mesma tenha as suas próprias maneiras de ativar o protocolo HTTPS.</p> - -<h2 id="Indicadores_de_segurança_de_palavra-passe_do_Firefox">Indicadores de segurança de palavra-passe do Firefox</h2> - -<p>Para o informar do perigo descrito acima, o Firefox implementa vários mecanismos de aviso:</p> - -<ol> - <li> - <p>Firefox 51+ mostrará o símbolo de um cadeado com um traço vermelho na barra de endereços sempre que uma página de autenticação não tenha uma ligação segura, como demonstrado abaixo.</p> - - <p style="text-align: center;"><img alt="Lock Icon" src="https://support.cdn.mozilla.net/media/uploads/gallery/images/2015-11-17-12-13-18-2faa61.png" style="height: 25px; width: 25px;"></p> - </li> - <li> - <p>Firefox 52+ mostrará um aviso claro na barra de endereço e mais abaixo, focará o campo de introdução da password em qualquer formulário inseguro:</p> - - <p style="text-align: center;"><img alt="Warning" src="https://support.cdn.mozilla.net/media/uploads/gallery/images/2017-04-21-23-52-53-ba340d.png" style="height: 133px; width: 328px;"></p> - </li> - <li> - <p>Firefox 52+ também desabilita o preenchimento automático em formulários inseguros. No entanto, a partir da caixa de seleção, os utilizadores continuam a poder utilizar o preenchimento automático caso tenham os seus dados de autenticação gravados.</p> - </li> - <li> - <p>Avisos acerca de formulários inseguros também podem ser encontrados no separador "Segurança" da consola de programador em todas as versões distribuídas de Firefox, como demonstrado na próxima secção.</p> - </li> -</ol> - -<h2 id="Mensagens_da_Consola_da_Web"><strong>Mensagens da Consola da Web</strong></h2> - -<p>Esta secção descreve as mensagens de segurança mostradas pela consola de programador das Firefox DevTools (ferramentas de desenvolvimento), acerca de passwords inseguras.</p> - -<h3 id="Apresentando_o_formulário_de_sessão_usando_protocolo_HTTP">Apresentando o formulário de sessão usando protocolo HTTP</h3> - -<p>Mesmo que a acção do formulário seja um endereço HTTPS, a informação introduzida no formulário pelo utilizador não está protegida porque um possível atacante pode modificar a própria página que o utilizador consulta (por exemplo, os atacantes podem mudar o destino do formulário de forma a que os dados sensíveis sejam enviados para um servidor por eles controlados, ou inserir um script de leitura de teclas que desenha a password enquanto o utilizador a escreve). O separador de segurança da consola de programador web avisará os programadores e utilizadores acerca desta preocupação de segurança:</p> - -<p style="text-align: center;"><img alt="Insecure login form shown with the Web Console and contextual warning on the password field." src="https://mdn.mozillademos.org/files/14783/Insecure_Password_Console_Contextual_sm.png" style="height: 566px; width: 790px;"></p> - -<div class="note"> -<p><strong>Nota</strong>: Também não é seguro incluir uma página de autenticação recorrendo a HTTPS numa página HTTP - um atacante pode alterar a frame e respetivo endereço para apontar para um outro endereço, possivelmente malicioso.</p> -</div> - -<h3 id="Utilizar_um_URL_HTTP_na_acção_do_formulário"><strong>Utilizar um URL HTTP na acção do formulário</strong></h3> - -<p>Neste caso, quaisquer dados que o utilizador introduza é enviado pela rede como sendo apenas texto básico. A password do utilizador é claramente visível para qualquer pessoa que "fareje" a rede desde o momento em que deixa o computador do utilizador até ao momento em que chega ao servidor onde se encontra alojado o website de destino.</p> - -<p style="text-align: center;"><img alt="Insecure login form action shown with the Web Console and contextual warning on the password field." src="https://mdn.mozillademos.org/files/14785/Insecure_Action_Password_Console_Contextual_sm.png" style="height: 566px; width: 790px;"></p> - -<h2 id="Nota_sobre_a_reutilização_de_palavra-passe">Nota sobre a reutilização de palavra-passe</h2> - -<p>Por vezes, as páginas requerem nomes de utilizador e palavras-passe, mas não guardam dados que sejam particularmente sensíveis. Por exemplo, uma página de notícias pode gravar quais os anúncios que um utilizador queira voltar a rever e ler, sem guardar quaisquer dados acerca deste utilizador. Os programadores web deste tipo de páginas poderão estar menos preocupados a promover a segurança desta página e dos dados dos seus utilizadores.</p> - -<p>Infelizmente, <a href="https://www.lightbluetouchpaper.org/2011/02/09/measuring-password-re-use-empirically/">a reutilização de palavras-passe é um grande problema</a>. Os utilizadores tendem a utilizar a mesma palavra-passe para aceder a múltiplas páginas (seja de notícias, redes sociais, serviços de email, bancos, etc.). Por essa razão, mesmo que o acesso ao utilizador e palavra-passe do seu site não lhe pareça um enorme risco, é um grande risco para utilizadores que usem esse mesmo nome de utilizador e palavra-passe para aceder, por exemplo, às suas contas bancárias. Os atacantes estão a tornar-se cada vez mais espertos; roubam pares de nomes de utilizador/palavra-passe de um site, e tentam reusá-los em sites mais lucrativos.</p> - -<h2 id="Consulte_também">Consulte também</h2> - -<ul> - <li class="entry-title"><a href="https://blog.mozilla.org/tanvi/2016/01/28/no-more-passwords-over-http-please/">Não Utilizar Mais Palavras-passe sobre HTTP, Por favor!</a> (inglês)— artigo de blogue detalhado com mais informação, e perguntas frequentes.</li> -</ul> - -<p class="entry-title">{{QuickLinksWithSubpages("/en-US/docs/Web/Security")}}</p> - -<div id="SL_balloon_obj" style="display: block;"> -<div class="SL_ImTranslatorLogo" id="SL_button" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%; display: none; opacity: 1; left: -8px; top: -25px;"> </div> - -<div id="SL_shadow_translation_result2" style="display: none;"> </div> - -<div id="SL_shadow_translator" style="display: none;"> -<div id="SL_planshet"> -<div id="SL_arrow_up" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div> - -<div id="SL_Bproviders"> -<div class="SL_BL_LABLE_ON" id="SL_P0" title="Google">G</div> - -<div class="SL_BL_LABLE_ON" id="SL_P1" title="Microsoft">M</div> - -<div class="SL_BL_LABLE_ON" id="SL_P2" title="Translator">T</div> -</div> - -<div id="SL_alert_bbl" style="display: none;"> -<div id="SLHKclose" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div> - -<div id="SL_alert_cont"> </div> -</div> - -<div id="SL_TB"> -<table id="SL_tables"> - <tbody> - <tr> - <td class="SL_td"><input></td> - <td class="SL_td"><select><option value="auto">Detectar idioma</option><option value="af">Africâner</option><option value="sq">Albanês</option><option value="de">Alemão</option><option value="ar">Arabe</option><option value="hy">Armênio</option><option value="az">Azerbaijano</option><option value="eu">Basco</option><option value="bn">Bengali</option><option value="be">Bielo-russo</option><option value="my">Birmanês</option><option value="bs">Bósnio</option><option value="bg">Búlgaro</option><option value="ca">Catalão</option><option value="kk">Cazaque</option><option value="ceb">Cebuano</option><option value="ny">Chichewa</option><option value="zh-CN">Chinês (Simp)</option><option value="zh-TW">Chinês (Trad)</option><option value="si">Cingalês</option><option value="ko">Coreano</option><option value="ht">Crioulo haitiano</option><option value="hr">Croata</option><option value="da">Dinamarquês</option><option value="sk">Eslovaco</option><option value="sl">Esloveno</option><option value="es">Espanhol</option><option value="eo">Esperanto</option><option value="et">Estoniano</option><option value="fi">Finlandês</option><option value="fr">Francês</option><option value="gl">Galego</option><option value="cy">Galês</option><option value="ka">Georgiano</option><option value="el">Grego</option><option value="gu">Gujarati</option><option value="ha">Hauça</option><option value="iw">Hebraico</option><option value="hi">Hindi</option><option value="hmn">Hmong</option><option value="nl">Holandês</option><option value="hu">Húngaro</option><option value="ig">Igbo</option><option value="id">Indonésio</option><option value="en">Inglês</option><option value="yo">Ioruba</option><option value="ga">Irlandês</option><option value="is">Islandês</option><option value="it">Italiano</option><option value="ja">Japonês</option><option value="jw">Javanês</option><option value="kn">Kannada</option><option value="km">Khmer</option><option value="lo">Laosiano</option><option value="la">Latim</option><option value="lv">Letão</option><option value="lt">Lituano</option><option value="mk">Macedônico</option><option value="ml">Malaiala</option><option value="ms">Malaio</option><option value="mg">Malgaxe</option><option value="mt">Maltês</option><option value="mi">Maori</option><option value="mr">Marathi</option><option value="mn">Mongol</option><option value="ne">Nepalês</option><option value="no">Norueguês</option><option value="fa">Persa</option><option value="pl">Polonês</option><option value="pt">Português</option><option value="pa">Punjabi</option><option value="ro">Romeno</option><option value="ru">Russo</option><option value="sr">Sérvio</option><option value="st">Sesotho</option><option value="so">Somália</option><option value="sw">Suaíli</option><option value="su">Sudanês</option><option value="sv">Sueco</option><option value="tg">Tadjique</option><option value="tl">Tagalo</option><option value="th">Tailandês</option><option value="ta">Tâmil</option><option value="cs">Tcheco</option><option value="te">Telugo</option><option value="tr">Turco</option><option value="uk">Ucraniano</option><option value="ur">Urdu</option><option value="uz">Uzbeque</option><option value="vi">Vietnamita</option><option value="yi">Yiddish</option><option value="zu">Zulu</option></select></td> - <td class="SL_td"> - <div id="SL_switch_b" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Alternar Idiomas"> </div> - </td> - <td class="SL_td"><select><option value="af">Africâner</option><option value="sq">Albanês</option><option value="de">Alemão</option><option value="ar">Arabe</option><option value="hy">Armênio</option><option value="az">Azerbaijano</option><option value="eu">Basco</option><option value="bn">Bengali</option><option value="be">Bielo-russo</option><option value="my">Birmanês</option><option value="bs">Bósnio</option><option value="bg">Búlgaro</option><option value="ca">Catalão</option><option value="kk">Cazaque</option><option value="ceb">Cebuano</option><option value="ny">Chichewa</option><option value="zh-CN">Chinês (Simp)</option><option value="zh-TW">Chinês (Trad)</option><option value="si">Cingalês</option><option value="ko">Coreano</option><option value="ht">Crioulo haitiano</option><option value="hr">Croata</option><option value="da">Dinamarquês</option><option value="sk">Eslovaco</option><option value="sl">Esloveno</option><option value="es">Espanhol</option><option value="eo">Esperanto</option><option value="et">Estoniano</option><option value="fi">Finlandês</option><option value="fr">Francês</option><option value="gl">Galego</option><option value="cy">Galês</option><option value="ka">Georgiano</option><option value="el">Grego</option><option value="gu">Gujarati</option><option value="ha">Hauça</option><option value="iw">Hebraico</option><option value="hi">Hindi</option><option value="hmn">Hmong</option><option value="nl">Holandês</option><option value="hu">Húngaro</option><option value="ig">Igbo</option><option value="id">Indonésio</option><option selected value="en">Inglês</option><option value="yo">Ioruba</option><option value="ga">Irlandês</option><option value="is">Islandês</option><option value="it">Italiano</option><option value="ja">Japonês</option><option value="jw">Javanês</option><option value="kn">Kannada</option><option value="km">Khmer</option><option value="lo">Laosiano</option><option value="la">Latim</option><option value="lv">Letão</option><option value="lt">Lituano</option><option value="mk">Macedônico</option><option value="ml">Malaiala</option><option value="ms">Malaio</option><option value="mg">Malgaxe</option><option value="mt">Maltês</option><option value="mi">Maori</option><option value="mr">Marathi</option><option value="mn">Mongol</option><option value="ne">Nepalês</option><option value="no">Norueguês</option><option value="fa">Persa</option><option value="pl">Polonês</option><option value="pt">Português</option><option value="pa">Punjabi</option><option value="ro">Romeno</option><option value="ru">Russo</option><option value="sr">Sérvio</option><option value="st">Sesotho</option><option value="so">Somália</option><option value="sw">Suaíli</option><option value="su">Sudanês</option><option value="sv">Sueco</option><option value="tg">Tadjique</option><option value="tl">Tagalo</option><option value="th">Tailandês</option><option value="ta">Tâmil</option><option value="cs">Tcheco</option><option value="te">Telugo</option><option value="tr">Turco</option><option value="uk">Ucraniano</option><option value="ur">Urdu</option><option value="uz">Uzbeque</option><option value="vi">Vietnamita</option><option value="yi">Yiddish</option><option value="zu">Zulu</option></select></td> - <td class="SL_td"> - <div id="SL_TTS_voice" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Ouça"> </div> - </td> - <td class="SL_td"> - <div class="SL_copy" id="SL_copy" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Copiar"> </div> - </td> - <td class="SL_td"> - <div id="SL_bbl_font_patch"> </div> - - <div class="SL_bbl_font" id="SL_bbl_font" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Tamanho da fonte"> </div> - </td> - <td class="SL_td"> - <div id="SL_bbl_help" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Ajuda"> </div> - </td> - <td class="SL_td"> - <div class="SL_pin_off" id="SL_pin" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Fixar a janela de pop-up"> </div> - </td> - </tr> - </tbody> -</table> -</div> -</div> - -<div id="SL_shadow_translation_result" style=""> </div> - -<div class="SL_loading" id="SL_loading" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div> - -<div id="SL_player2"> </div> - -<div id="SL_alert100">A função de fala é limitada a 200 caracteres</div> - -<div id="SL_Balloon_options" style="background: rgb(255, 255, 255) repeat scroll 0% 0%;"> -<div id="SL_arrow_down" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div> - -<table id="SL_tbl_opt" style="width: 100%;"> - <tbody> - <tr> - <td><input></td> - <td> - <div id="SL_BBL_IMG" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="Mostrar o botão do ImTranslator 3 segundos"> </div> - </td> - <td><a class="SL_options" title="Mostrar opções">Opções</a> : <a class="SL_options" title="Histórico de tradução">Histórico</a> : <a class="SL_options" title="Comentários">Comentários</a> : <a class="SL_options" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GD9D8CPW8HFA2" title="Faça sua contribuição">Donate</a></td> - <td><span id="SL_Balloon_Close" title="Encerrar">Encerrar</span></td> - </tr> - </tbody> -</table> -</div> -</div> -</div> diff --git a/files/pt-pt/web/seguranca/same-origin_policy/index.html b/files/pt-pt/web/seguranca/same-origin_policy/index.html deleted file mode 100644 index a6ebc31ad6..0000000000 --- a/files/pt-pt/web/seguranca/same-origin_policy/index.html +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: Same-origin policy -slug: Web/Seguranca/Same-origin_policy -translation_of: Web/Security/Same-origin_policy ---- -<div>{{QuickLinksWithSubpages("/en-US/docs/Web/Security")}}</div> - -<p><span class="seoSummary">The <strong>same-origin policy</strong> is a critical security mechanism that restricts how a document or script loaded from one {{Glossary("origin")}} can interact with a resource from another origin.</span> It helps isolate potentially malicious documents, reducing possible attack vectors.</p> - -<p>Definição de uma Origem</p> - -<p>Duas URL tem a mesma origem se o {{Glossary("protocol")}}, {{Glossary("port")}} (if specified), and {{Glossary("host")}} are the same for both. You may see this referenced as the "scheme/host/port tuple", or just "tuple". (A "tuple" is a set of items that together comprise a whole — a generic form for double/triple/quadruple/quintuple/etc.)</p> - -<p>The following table gives examples of origin comparisons with the URL <code>http://store.company.com/dir/page.html</code>:</p> - -<table class="standard-table"> - <tbody> - <tr> - <th>URL</th> - <th>Outcome</th> - <th>Reason</th> - </tr> - <tr> - <td><code>http://store.company.com/dir2/other.html</code></td> - <td>Same origin</td> - <td>Only the path differs</td> - </tr> - <tr> - <td><code>http://store.company.com/dir/inner/another.html</code></td> - <td>Same origin</td> - <td>Only the path differs</td> - </tr> - <tr> - <td><code>https://store.company.com/page.html</code></td> - <td>Failure</td> - <td>Different protocol</td> - </tr> - <tr> - <td><code>http://store.company.com:81/dir/page.html</code></td> - <td>Failure</td> - <td>Different port (<code>http://</code> is port 80 by default)</td> - </tr> - <tr> - <td><code>http://news.company.com/dir/page.html</code></td> - <td>Failure</td> - <td>Different host</td> - </tr> - </tbody> -</table> - -<h3 id="Inherited_origins">Inherited origins</h3> - -<p>Scripts executed from pages with an <code>about:blank</code> or <code>javascript:</code> URL inherit the origin of the document containing that URL, since these types of URLs do not contain information about an origin server.</p> - -<div class="note"> -<p>For example, <code>about:blank</code> is often used as a URL of new, empty popup windows into which the parent script writes content (e.g. via the {{domxref("Window.open()")}} mechanism). If this popup also contains JavaScript, that script would inherit the same origin as the script that created it.</p> -</div> - -<div class="warning"> -<p><code>data:</code> URLs get a new, empty, security context.</p> -</div> - -<h3 id="Exceptions_in_Internet_Explorer">Exceptions in Internet Explorer</h3> - -<p>Internet Explorer has two major exceptions to the same-origin policy:</p> - -<dl> - <dt>Trust Zones</dt> - <dd>If both domains are in the <em>highly trusted zone</em> (e.g. corporate intranet domains), then the same-origin limitations are not applied.</dd> - <dt>Port</dt> - <dd>IE doesn't include port into same-origin checks. Therefore, <code>https://company.com:81/index.html</code> and <code>https://company.com/index.html</code> are considered the same origin and no restrictions are applied.</dd> -</dl> - -<p>These exceptions are nonstandard and unsupported in any other browser.</p> - -<h2 id="Changing_origin">Changing origin</h2> - -<p>A page may change its own origin, with some limitations. A script can set the value of {{domxref("document.domain")}} to its current domain or a superdomain of its current domain. If set to a superdomain of the current domain, the shorter superdomain is used for same-origin checks.</p> - -<p>For example, assume a script from the document at <code>http://store.company.com/dir/other.html</code> executes the following:</p> - -<pre class="brush: js notranslate">document.domain = "company.com"; -</pre> - -<p>Afterward, the page can pass the same-origin check with <code>http://company.com/dir/page.html</code> (assuming <code>http://company.com/dir/page.html</code> sets its <code>document.domain</code> to "<code>company.com</code>" to indicate that it wishes to allow that - see {{domxref("document.domain")}} for more). However, <code>company.com</code> could <strong>not</strong> set <code>document.domain</code> to <code>othercompany.com</code>, since that is not a superdomain of <code>company.com</code>.</p> - -<p>The port number is checked separately by the browser. Any call to <code>document.domain</code>, including <code>document.domain = document.domain</code>, causes the port number to be overwritten with <code>null</code>. Therefore, one <strong>cannot</strong> make <code>company.com:8080</code> talk to <code>company.com</code> by only setting <code>document.domain = "company.com"</code> in the first. It has to be set in both so their port numbers are both <code>null</code>.</p> - -<div class="note"> -<p><strong>Note:</strong> When using <code>document.domain</code> to allow a subdomain to access its parent securely, you need to set <code>document.domain</code> to the <em>same value</em> in both the parent domain and the subdomain. This is necessary even if doing so is simply setting the parent domain back to its original value. Failure to do this may result in permission errors.</p> -</div> - -<h2 id="Cross-origin_network_access">Cross-origin network access</h2> - -<p>The same-origin policy controls interactions between two different origins, such as when you use {{domxref("XMLHttpRequest")}} or an {{htmlelement("img")}} element. These interactions are typically placed into three categories:</p> - -<ul> - <li>Cross-origin <em>writes</em> are typically allowed. Examples are links, redirects, and form submissions. Some HTTP requests require <a href="/en-US/docs/Web/HTTP/CORS#Preflighted_requests">preflight</a>.</li> - <li>Cross-origin <em>embedding</em> is typically allowed. (Examples are listed below.)</li> - <li>Cross-origin <em>reads</em> are typically disallowed, but read access is often leaked by embedding. For example, you can read the dimensions of an embedded image, the actions of an embedded script, or the <a class="external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629094">availability of an embedded resource</a>.</li> -</ul> - -<p>Here are some examples of resources which may be embedded cross-origin:</p> - -<ul> - <li>JavaScript with <code><script src="…"></script></code>. Error details for syntax errors are only available for same-origin scripts.</li> - <li>CSS applied with <code><link rel="stylesheet" href="…"></code>. Due to the <a class="external" href="https://scarybeastsecurity.blogspot.com/2009/12/generic-cross-browser-cross-domain.html">relaxed syntax rules</a> of CSS, cross-origin CSS requires a correct <code>Content-Type</code> header. Restrictions vary by browser: <a class="external" href="https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/compatibility/gg622939(v=vs.85)?redirectedfrom=MSDN">Internet Explorer</a>, <a class="external" href="https://www.mozilla.org/en-US/security/advisories/mfsa2010-46/">Firefox</a>, <a class="external" href="https://bugs.chromium.org/p/chromium/issues/detail?id=9877">Chrome</a> , <a class="external" href="https://support.apple.com/kb/HT4070">Safari</a> (scroll down to CVE-2010-0051) and <a class="external" href="https://security.opera.com/cross-domain-data-theft-with-css-load-opera-security-advisories/">Opera</a>.</li> - <li>Images displayed by {{htmlelement("img")}}.</li> - <li>Media played by {{htmlelement("video")}} and {{htmlelement("audio")}}.</li> - <li>External resources embedded with {{htmlelement("object")}} and {{htmlelement("embed")}}.</li> - <li>Fonts applied with {{cssxref("@font-face")}}. Some browsers allow cross-origin fonts, others require same-origin.</li> - <li>Anything embedded by {{htmlelement("iframe")}}. Sites can use the {{HTTPHeader("X-Frame-Options")}} header to prevent cross-origin framing.</li> -</ul> - -<h3 id="How_to_allow_cross-origin_access">How to allow cross-origin access</h3> - -<p>Use <a href="/en-US/docs/Web/HTTP/CORS">CORS</a> to allow cross-origin access. CORS is a part of {{Glossary("HTTP")}} that lets servers specify what hosts are permitted to load content from that server.</p> - -<h3 id="How_to_block_cross-origin_access">How to block cross-origin access</h3> - -<ul> - <li>To prevent cross-origin writes, check an unguessable token in the request — known as a <a class="external" href="https://owasp.org/www-community/attacks/csrf">Cross-Site Request Forgery (CSRF)</a> token. You must prevent cross-origin reads of pages that require this token.</li> - <li>To prevent cross-origin reads of a resource, ensure that it is not embeddable. It is often necessary to prevent embedding because embedding a resource always leaks some information about it.</li> - <li>To prevent cross-origin embeds, ensure that your resource cannot be interpreted as one of the embeddable formats listed above. Browsers may not respect the <code>Content-Type</code> header. For example, if you point a <code><script></code> tag at an HTML document, the browser will try to parse the HTML as JavaScript. When your resource is not an entry point to your site, you can also use a CSRF token to prevent embedding.</li> -</ul> - -<h2 id="Cross-origin_script_API_access">Cross-origin script API access</h2> - -<p>JavaScript APIs like {{domxref("HTMLIFrameElement.contentWindow", "iframe.contentWindow")}}, {{domxref("window.parent")}}, {{domxref("window.open")}}, and {{domxref("window.opener")}} allow documents to directly reference each other. When two documents do not have the same origin, these references provide very limited access to {{domxref("Window")}} and {{domxref("Location")}} objects, as described in the next two sections.</p> - -<p>To communicate between documents from different origins, use {{domxref("window.postMessage")}}.</p> - -<p>Specification: <a class="external" href="https://html.spec.whatwg.org/multipage/browsers.html#cross-origin-objects">HTML Living Standard § Cross-origin objects</a>.</p> - -<h3 id="Window">Window</h3> - -<p>The following cross-origin access to these <code>Window</code> properties is allowed:</p> - -<table class="fullwidth-table standard-table"> - <thead> - <tr> - <th scope="col">Methods</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{domxref("window.blur")}}</td> - </tr> - <tr> - <td>{{domxref("window.close")}}</td> - </tr> - <tr> - <td>{{domxref("window.focus")}}</td> - </tr> - <tr> - <td>{{domxref("window.postMessage")}}</td> - </tr> - </tbody> -</table> - -<table class="fullwidth-table standard-table"> - <thead> - <tr> - <th scope="col">Attributes</th> - <th scope="col"></th> - </tr> - </thead> - <tbody> - <tr> - <td>{{domxref("window.closed")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.frames")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.length")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.location")}}</td> - <td>Read/Write.</td> - </tr> - <tr> - <td>{{domxref("window.opener")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.parent")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.self")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.top")}}</td> - <td>Read only.</td> - </tr> - <tr> - <td>{{domxref("window.window")}}</td> - <td>Read only.</td> - </tr> - </tbody> -</table> - -<p>Some browsers allow access to more properties than the above.</p> - -<h3 id="Location">Location</h3> - -<p>The following cross-origin access to <code>Location</code> properties is allowed:</p> - -<table class="fullwidth-table standard-table"> - <thead> - <tr> - <th scope="col">Methods</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{domxref("location.replace")}}</td> - </tr> - </tbody> -</table> - -<table class="fullwidth-table standard-table"> - <thead> - <tr> - <th scope="col">Attributes</th> - <th scope="col"></th> - </tr> - </thead> - <tbody> - <tr> - <td>{{domxref("URLUtils.href")}}</td> - <td>Write-only.</td> - </tr> - </tbody> -</table> - -<p>Some browsers allow access to more properties than the above.</p> - -<h2 id="Cross-origin_data_storage_access">Cross-origin data storage access</h2> - -<p>Access to data stored in the browser such as <a href="/en-US/docs/Web/API/Web_Storage_API">Web Storage</a> and <a href="/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> are separated by origin. Each origin gets its own separate storage, and JavaScript in one origin cannot read from or write to the storage belonging to another origin.</p> - -<p>{{glossary("Cookie", "Cookies")}} use a separate definition of origins. A page can set a cookie for its own domain or any parent domain, as long as the parent domain is not a public suffix. Firefox and Chrome use the <a class="external" href="https://publicsuffix.org/">Public Suffix List</a> to determine if a domain is a public suffix. Internet Explorer uses its own internal method to determine if a domain is a public suffix. The browser will make a cookie available to the given domain including any sub-domains, no matter which protocol (HTTP/HTTPS) or port is used. When you set a cookie, you can limit its availability using the <code>Domain</code>, <code>Path</code>, <code>Secure</code>, and <code>HttpOnly</code> flags. When you read a cookie, you cannot see from where it was set. Even if you use only secure https connections, any cookie you see may have been set using an insecure connection.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="https://www.w3.org/Security/wiki/Same_Origin_Policy">Same Origin Policy at W3C</a></li> - <li><a href="https://web.dev/secure/same-origin-policy">Same-origin policy at web.dev</a></li> -</ul> - -<div class="originaldocinfo"> -<h2 id="Original_Document_Information" name="Original_Document_Information">Original Document Information</h2> - -<ul> - <li>Author(s): Jesse Ruderman</li> -</ul> -</div> |