37
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

https://2685434919 と https://160.16.124.39 はSameOriginか

Last updated at Posted at 2026-01-20

これらのURLはSameOriginか?

(IPアドレスだと分かりづらいですが、僕個人サイトのIPアドレスですので、アクセスいただけます)

実際の動作

https://160.16.124.39/ のページ上で、fetchしてみる。特にSameOriginポリシーによりブロックされることはない。

image.png

仕様をみていく

Origin

Originの定義は whatwg/html に記載されている。

Originは下記のタプルから構成される。つまり、host の正体が大事。

  • A scheme (an ASCII string).
  • A host (a host).
  • A port (null or a 16-bit unsigned integer).

hostとは

続けて host の定義を見ていく。hostは Whatwg/url に記載されている。

A host is a domain, an IP address, an opaque host, or an empty host.
(ホストは、ドメイン、IPアドレス、 不透明ホスト、または空のホストのいずれかです。)

hostになりうるIP address自体の定義は、同ドキュメントで下記のように書かれている。。

An IP address is an IPv4 address or an IPv6 address.

An IPv4 address is a 32-bit unsigned integer that identifies a network address. [RFC791]

An IPv6 address is a 128-bit unsigned integer that identifies a network address.

つまり、OriginとしてIPアドレスを使う場合は、見た目は関係なく32bit整数値であることがわかります。(IPv6であれば省略記法などもあり、それらが同じ物と言われればそうですよね)

ということで IPv4アドレスに関しても URL の見た目にかかわらず同じものはSameOriginということになりそうです。

(あんまり自信はないので、認識違いがあればご指摘ください)

おまけ

現在 Chrome が開発中の isSameOrigin() で比較すると false になる。(まだ、、、開発中だしね?ということで様子見)

Chrome Canaryにて
image.png

37
10
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?