Habr•August 12, 2026•🇷🇺Translated from Russian

Same-Origin Policy and CORS: How Browsers Enforce Web Security Boundaries

The fundamental question in web security is what stops a script on one website from reading sensitive information, such as a bank balance, from another site where the user is logged in. Technically nothing prevents the request itself from being sent, because the browser would attach the user’s cookies, making the request appear authenticated. However, the Same-Origin Policy built into every browser blocks the script from reading the response, thereby protecting user data across different sites.

An origin consists of exactly three components: protocol, domain, and port. Two URLs belong to the same origin only when all three match. For example, https://shop.ru/catalog and https://shop.ru/cart share the same origin, while http://shop.ru and https://shop.ru are treated as different origins. Even subdomains such as https://api.shop.ru constitute a separate origin from https://shop.ru, which frequently surprises developers building front-end applications that call their own APIs.

The policy states that code executing in one origin cannot read data from another origin. It does not prohibit loading foreign resources; it only prevents programmatic reading of their content. Images, fonts, analytics scripts, and embedded videos from other origins load and display normally. Attempting to draw such an image onto a <canvas> element and read its pixels is blocked. Similarly, an <iframe> can display a third-party page, yet JavaScript cannot inspect or extract data from that frame.

Foreign scripts loaded via <script> tags execute with the privileges of the including page because they become part of that origin’s code rather than remaining external data. This behavior enables libraries such as jQuery from CDNs but also introduces risk if the CDN is compromised. Developers therefore often host critical libraries themselves or apply subresource integrity hashes.

When an application must read data from another origin, for instance retrieving weather information from a public API, the Cross-Origin Resource Sharing (CORS) mechanism provides a controlled exception. The target server decides whether to allow the read by returning the header Access-Control-Allow-Origin. A value of * permits any origin, while a specific domain restricts access to that single origin. Without this header the browser discards the response before handing it to the calling script.

CORS operates exclusively inside the browser and does not protect servers against requests issued from tools such as curl or from other servers. Authentication and authorization checks on the server side remain the only effective controls for sensitive data. Even when a request is blocked by CORS, the request itself may still have reached the server and triggered side effects if it was a state-changing operation.

Browsers classify cross-origin requests as simple or non-simple. Simple requests (GET or POST with standard content types) are sent immediately. Non-simple requests trigger a preliminary OPTIONS preflight request so the server can declare which methods and headers it accepts before the actual request is issued.

Related articles

Habr•Other

Passkeys in Production: How One Developer Replaced Passwords with Face ID in Three Days Using FastAPI and Next.js

Yaroslav Morozov details a complete production implementation of Passkeys based on the WebAuthn standard and FIDO2 protocols. The article explains why Passkeys eliminate phishing and database breach risks compared to traditional passwords while providing biometric login via Face ID or Touch ID. It covers database schema design with PostgreSQL tables for credentials and challenges, SQLAlchemy models, and minimal dependencies including py-webauthn on the backend and SimpleWebAuthn on the frontend. Full working code for registration and authentication flows is provided, showing how Passkeys integrate with existing JWT token systems without major refactoring. The guide includes environment configuration, error handling, challenge management with five-minute TTL, and security considerations such as sign count verification to detect cloned keys.

Habr•Other

Yandex Disk Files Become Partially Inaccessible After Sasovo Data Center Incident

A detailed user report reveals that approximately one percent of files stored on Yandex Disk are currently unavailable for download following reported incidents at the Sasovo data center. The problems manifest in three distinct states: missing thumbnails with downloadable originals, visible thumbnails with inaccessible originals returning 504 Gateway Time-out errors, and cases where both thumbnails and originals fail to load. Technical analysis using curl requests traced the failures to specific storage nodes such as s418klg.storage.yandex.net, indicating that some data shards may reside in affected infrastructure while others remain operational. Yandex support requested original files for diagnosis but closed the ticket without providing an official explanation or confirming data integrity. The author emphasizes that the issue affects files across both the Photos and Files sections and recommends maintaining offline backups due to the lack of guaranteed availability during data center failures.

AntiMalware•Other

Keurig K-Supreme Smart Coffee Maker Generates Nearly 1 TB of Outbound Traffic in Ten Days

A Keurig K-Supreme Smart coffee maker unexpectedly produced around 1008 GB of outgoing traffic over ten days, overwhelming a home UniFi access point while generating only 9.94 GB of inbound data. The device had been placed on a separate network segment, yet the traffic remained largely internal to the home LAN rather than traversing the internet connection. The anomaly was discovered by user Nomad while assisting family members with network maintenance through the UniFi dashboard. After the coffee maker was powered off, the issue could not be reproduced in subsequent testing, and no packet captures were available to determine the content or root cause of the traffic. The model requires internet connectivity for remote control, scheduling, capsule recognition, and automatic reordering of coffee supplies. No similar incidents have been reported by other users, and the manufacturer has not issued any statement regarding the event.

Habr•Other

Hash Functions Part 1: Core Properties, Security Requirements and Practical Applications

The article provides a detailed introduction to hash functions, explaining how they map arbitrary-length input to fixed-length output while satisfying three fundamental security properties. It covers preimage resistance, second preimage resistance, and collision resistance, along with the avalanche effect that makes even minor input changes produce unrecognizable output. The text explains why a 256-bit digest is required to achieve 128-bit collision resistance, referencing the birthday paradox and its implications for MD5 and SHA-1. Practical guidance includes using OpenSSL for hashing, applying hashes in commitment schemes, enforcing subresource integrity on web pages, and securely storing passwords with Argon2 and bcrypt. The post emphasizes that hash functions alone do not guarantee integrity without proper transmission of the digest and announces a follow-up on SHA-2 and SHA-3 internals.