HabrAugust 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

HabrOther

Implementing 2FA Kubernetes Access via Gateway API, Dex and MULTIDIRECTORY

A Russian cybersecurity company replaced static kubeconfig files with corporate accounts and mandatory 2FA for its Talos Linux Kubernetes clusters. The solution routes all authentication through a single FQDN using NGINX Gateway Fabric, Dex as an OIDC provider connected to MULTIDIRECTORY via LDAP, and kube-oidc-proxy for token validation and impersonation. Groups stored in the directory are passed directly into RBAC bindings, eliminating manual certificate management. A lightweight Python service dynamically generates kubeconfig files that contain no secrets. The team documented several Gateway API migration pitfalls including namespace route restrictions and BackendTLSPolicy hostname validation. The approach keeps the entire configuration in Git and avoids modifying kube-apiserver flags.

AntiMalwareOther

Windows File System Tunneling Preserves Old File Metadata for Legacy Compatibility

Microsoft has clarified that Windows sometimes assigns creation dates from deleted files to new ones due to a long-standing mechanism called File System Tunneling. The feature keeps metadata in a short-term cache for about 15 seconds after a file is deleted or renamed. If a new file with the same name is created quickly in the same folder, it inherits the previous file's timestamps and short-to-long name mappings. This behavior exists to support safe saving patterns used by many applications and to maintain compatibility with old DOS-era 8.3 filename formats. The actual file content is never restored, only the metadata. The cache is temporary and clears over time, so the effect does not occur with files deleted long ago. The explanation came after users noticed unexpected dates in Windows Explorer and questioned whether it was a bug.

HabrOther

Amazon Confirms Irrecoverable Data Loss in UAE and Bahrain Data Centers After Drone Attacks

Amazon Web Services has officially confirmed that data stored in specific availability zones within its Middle East regions was permanently destroyed following physical attacks on data centers in the UAE and Bahrain. The incidents began on March 1 and continued through April and July, damaging infrastructure tied to AI development projects. In the UAE region mec1, only zone mec1-az2 was completely destroyed with no external backups, while mec1-az3 suffered severe damage and mec1-az1 remained operational but overloaded. All three zones in the Bahrain region me-south-1 were rendered inoperable. AWS had spent six months attempting recovery before issuing the final statement on September 15, 2026, and has advised customers to migrate workloads to unaffected regions. The event highlights growing risks to data from physical-world attacks beyond traditional network threats.

HabrOther

Bots Overload OT Commerce Store on OT Box, Spike Paid OTAPI Calls Mistaken for DDoS Attack

An online store running OT Commerce experienced CPU loads reaching 98-100% and a 6-7x increase in paid OTAPI calls over three days due to automated bot traffic rather than a traditional DDoS. The site owner had already deployed a paid anti-bot module on the VPS, yet behavioral bots continued to bypass protections and force expensive calls to the external OTAPI platform for product data from Taobao, Tmall, 1688 and other marketplaces. Traffic analysis after switching to the CRONARMOR WAF revealed that 41.9% of page requests were automated, with 99.3% of early-stage automation blocked before reaching the origin server. Only 0.5% were behavioral bots visible in analytics, while legitimate search crawlers accounted for 27,190 requests that were explicitly allowed. The WAF approach stopped requests at the reverse proxy layer, preventing PHP execution, database queries and OTAPI billing events on the origin. Post-deployment CPU dropped to single digits for most of the day, eliminating both performance issues and the anomalous rise in paid API usage.