๊ฐœ๋ฐœ ์ง€์‹/WEB ์ง€์‹

๐ŸŒ ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ € PNA ๊ถŒํ•œ๊ณผ CORS ํ•ด๊ฒฐํ•˜๊ธฐ

์ธํŒŒ_ 2023. 3. 23. 07:29

chrome-pna

Chrome PNA (Private Network Access)

์‚ฌ์„ค๋ง ์ ‘๊ทผ(private network access) ์ด๋ž€, ๋น„์ธ์ฆ๋œ ๊ณต์ธ(public) ์›น์‚ฌ์ดํŠธ์—์„œ, ์‚ฌ์ดํŠธ๋ฅผ ๋ฐฉ๋ฌธํ•œ ์‚ฌ์šฉ์ž์˜ ์™€ ๊ฐ™์€ ์‚ฌ์„ค ๋„คํŠธ์›Œํฌ๋ง(localhost(127.0.0.1) or 192.168.0.* ์•„์ดํ”ผ) ์—”๋“œํฌ์ธํŠธ์— ์—‘์„ธ์Šคํ•˜๋ ค ํ• ๋•Œ, ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์š”์ฒญ์„ ์ œํ•œํ•˜๋Š” ์ƒˆ๋กœ์šด ๋ณด์•ˆ ํ–ฅ์ƒ WSC ์‚ฌ์–‘์„ ๋งํ•œ๋‹ค.

PNA ๋™์ž‘ ๋ฉ”์ปค๋‹ˆ์ฆ˜์€ CORS(Cross-Origin Resource Sharing) ์ •์ฑ…์„ ํ™•์žฅํ•œ ๊ฐœ๋…์œผ๋กœ ์ ์šฉ๋œ๋‹ค. ๊ทธ๋ž˜์„œ ์‚ฌ์ดํŠธ์—์„œ ์‚ฌ์„ค ๋„คํŠธ์›Œํฌ ์„œ๋ฒ„์˜ ํ—ˆ๊ฐ€๋ฅผ ์šฐ์„  ์˜ˆ๋น„ ์š”์ฒญ(Preflight) ํ•˜๊ณ  ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์š”์ฒญ์„ ์Šน์ธํ•œ ๊ฒฝ์šฐ์—๋งŒ, ๊ณต๊ณต ์›น์‚ฌ์ดํŠธ์—์„œ ์‚ฌ์„ค ๋„คํŠธ์›Œํฌ ์„œ๋ฒ„์˜ ๋ฆฌ์†Œ์Šค์— ์—‘์„ธ์Šค๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด CORS ์—๋Ÿฌ๊ฐ€ ๋œจ๊ฒŒ ๋œ๋‹ค.

 

๐ŸŒ ์•…๋ช… ๋†’์€ CORS ๊ฐœ๋… & ํ•ด๊ฒฐ๋ฒ• - ์ •๋ฆฌ ๋ํŒ์™• ๐Ÿ‘

์•…๋ช… ๋†’์€ CORS ์—๋Ÿฌ ๋ฉ”์„ธ์ง€ ์›น ๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๋ณด๋ฉด ๋ฐ˜๋“œ์‹œ ๋งˆ์ฃผ์น˜๋Š” ๋ฉ๋ฉ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐ”๋กœ CORS ์ด๋‹ค. ์›น ๊ฐœ๋ฐœ์˜ ์‹ ์ž… ์‹ ๊ณ ์‹์ด๋ผ๊ณ  ํ•  ์ •๋„๋กœ, CORS๋Š” ๋ˆ„๊ตฌ๋‚˜ ํ•œ ๋ฒˆ ์ •๋„๋Š” ๊ฒช๊ฒŒ ๋œ๋‹ค๊ณ  ํ•ด๋„ ๊ณผ์–ธ์ด

inpa.tistory.com

์ฆ‰, ์•ž์œผ๋กœ ๊ณต๊ณต ์ธํ„ฐ๋„ท ์›น์‚ฌ์ดํŠธ์—์„œ ๋‚ด๋ถ€ ๋„คํŠธ์›Œํฌ ์ž์›์— ์ ‘๊ทผํ•˜๋ ค๋ฉด ๋ธŒ๋ผ์šฐ์ €์˜ ํ—ˆ๋ฝ์„ ๋ฐ›์•„์•ผ๋งŒ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

chrome-pna


PNA ํƒ„์ƒ ๋ฐฐ๊ฒฝ

 

๋ธŒ๋ผ์šฐ์ €๋ฅผ ํ†ตํ•œ ๋„คํŠธ์›Œํฌ ์นจ์ž…

์ด ์‚ฌ์–‘์€ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ํ†ตํ•ด ์นจํˆฌํ•˜๋Š” ๋ฐฉ์‹์˜ ํ•ดํ‚น ๊ณต๊ฒฉ์„ ๋ณด๋‹ค ์–ด๋ ต๊ฒŒ ๋งŒ๋“ค๊ฒ ๋‹ค๋Š” ์ทจ์ง€๋กœ ํƒ„์ƒ ๋˜์—ˆ๋‹ค. ๋ธŒ๋ผ์šฐ์ €๋Š” ๋งŽ์€ ์„œ๋น„์Šค์™€ ์ƒํ˜ธ ์ž‘์šฉํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๊ธฐ๋ณธ์ ์œผ๋กœ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ๋‚ด๋ถ€์˜ ๊ฑฐ์˜ ๋ชจ๋“  ๋ฆฌ์†Œ์Šค์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ํŠน์ง•์„ ์•…์šฉํ•˜์—ฌ, ๋ธŒ๋ผ์šฐ์ €๋Š” ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ์— ๋Œ€ํ•œ ๊ณต๊ฒฉ์„ ์œ„ํ•œ ๊ต๋‘๋ณด๋กœ ํ”„๋ก์‹œ๋กœ์„œ ์ด์šฉ๋˜์™”์—ˆ๋‹ค.

์˜ˆ๋ฅผ๋“ค์–ด ์•…์„ฑ ์›น์‚ฌ์ดํŠธ๋ฅผ ๊ฐœ์„คํ•ด ๋‘๊ณ  ํ”ผํ•ด์ž๋ฅผ ์‚ฌ์ดํŠธ ์ ‘์†์„ ์œ ๋„ํ•จ์œผ๋กœ์จ ํ”ผํ•ด์ž์˜ ๋„คํŠธ์›Œํฌ์— ๋“ค์–ด๊ฐ€ ์—”๋“œํฌ์ธํŠธ๋ฅผ ๊ฐ์—ผ์‹œํ‚ค๋Š” ๊ฒŒ ๊ฐ€๋Šฅํ•˜๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์•…์„ฑ ์›น์‚ฌ์ดํŠธ์— ์•ก์„ธ์Šคํ•˜๋ฉด ๋ธŒ๋ผ์šฐ์ €๋Š” ์‚ฌ์šฉ์ž ๋ชจ๋ฅด๊ฒŒ ๋ผ์šฐํ„ฐ์— ์ž๋™ ์š”์ฒญ์„ ๋ณด๋‚ด ๋ผ์šฐํ„ฐ์˜ ์ธ์ฆ์„ ์šฐํšŒํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ์•…์˜์ ์ธ ์›น์‚ฌ์ดํŠธ์—์„œ ๋ผ์šฐํ„ฐ ์„ค์ •์„ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ์•…์„ฑ ์ฝ”๋“œ๋ฅผ ๋ณด๋‚ด ๋ผ์šฐํ„ฐ๋ฅผ ์กฐ์ž‘ํ•˜๋Š” ์‹์œผ๋กœ ๊ฐ์—ผ์‹œํ‚จ๋‹ค.

์‹ค์ œ๋กœ ํ•ด์ปค๊ฐ€ CSRF ๊ณต๊ฒฉ์„ ํ†ตํ•ด 300,000๊ฐœ ์ด์ƒ์˜ ๋ฌด์„  ๋ผ์šฐํ„ฐ์— ๋Œ€ํ•œ DNS ์„œ๋ฒ„ ์„ค์ •์„ ๋ณ€๊ฒฝํ•˜์—ฌ ์ •๋ณด๋ฅผ ํƒˆ์ทจํ•œ ์‚ฌ๋ก€๋„ ์žˆ๋‹ค.

chrome-pna
ํฌ๋กœ์Šค ์‚ฌ์ดํŠธ ์š”์ฒญ ์ทจ์•ฝ์ ์„ ์•…์šฉํ•˜์—ฌ ๋ผ์šฐํ„ฐ์˜ DNS ์„ค์ •์„ ๋ณ€๊ฒฝํ•˜๋Š” ๊ณต๊ฒฉ์˜ 3๋‹จ๊ณ„

  1. ์‚ฌ์„ค ๋‚ด๋ถ€๋ง์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์•…์˜์ ์ธ ์‚ฌ์ดํŠธ์— ์ ‘์†ํ•œ๋‹ค.
  2. ์•…์„ฑ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๊ฐ€ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ๋‚ด๋ถ€์˜ ์ปดํ“จํ„ฐ์—์„œ ๋กœ๋“œ๋˜์–ด ๋กœ์ปฌ ์ปดํ“จํ„ฐ๊ฐ€ ๋ผ์šฐํ„ฐ์˜ DNS ์„ค์ •์„ ์ž๋™์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋„๋ก ํ•œ๋‹ค.
  3. ๋ผ์šฐํ„ฐ๋Š” ๋„คํŠธ์›Œํฌ์˜ ๋ชจ๋“  ๋””๋ฐ”์ด์Šค์— ๋Œ€ํ•ด ์•…์„ฑ ๋„ค์ž„์„œ๋ฒ„(DNS)๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ์„ค์ •๋จ์— ๋”ฐ๋ผ, ํ•ด๋‹น ๋ง์— ์—ฐ๊ฒฐ๋œ ๋ชจ๋“  ์‚ฌ์šฉ์ž๋“ค์˜ ๋ผ์šฐํŒ… ์š”์ฒญ์„ ์˜ค์—ผ์‹œํ‚จ๋‹ค.
  4. ๊ธˆ์œต(๋˜๋Š” ๊ธฐํƒ€) ์‚ฌ์ดํŠธ์— ์—ฐ๊ฒฐ์„ ์‹œ๋„ํ•˜๋Š” ๋””๋ฐ”์ด์Šค๋Š” ์ด์ œ ๋กœ๊ทธ์ธ ์ž๊ฒฉ ์ฆ๋ช…์„ ์บก์ฒ˜ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ€์งœ ์›น์‚ฌ์ดํŠธ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰์…˜ ๋  ์ˆ˜ ์žˆ๋‹ค.

์ด๋Ÿฌํ•œ ๋ณด์•ˆ์ ์ธ ์ทจ์•ฝ์  ๋•Œ๋ฌธ์— ๋ธŒ๋ผ์šฐ์ €๋Š” ์ด์ œ ์‚ฌ์„ค๋ง์— ๋Œ€ํ•ด์„œ ๊ฒ€์‚ฌ๋ฅผ ์ฒ ์ €ํžˆ ํ•œ๋‹ค๋Š” ๊ฐœ๋…์œผ๋กœ PNA ์‚ฌ์–‘์ด ํƒ„์ƒํ•˜๊ฒŒ ๋œ ๊ฒƒ์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ๊ฐ์ข… ์—”๋“œํฌ์ธํŠธ ์žฅ๋น„๋“ค์„ ๋…ธ๋ฆฌ๋Š” CSRF(๊ต์ฐจ ์‚ฌ์ดํŠธ ์š”์ฒญ ์กฐ์ž‘) ๊ณต๊ฒฉ์œผ๋กœ๋ถ€ํ„ฐ ๋น„๊ต์  ์•ˆ์ „ํ•ด์ง€๊ฒŒ ๋œ๋‹ค.


Chrome PNA ์ •์ฑ… ์ ์šฉ ์‹œ๊ธฐ

Google์— ๋”ฐ๋ฅด๋ฉด Chrome 94 ๋ฒ„์ „๋ถ€ํ„ฐ PNA๊ฐ€ ๋“ฑ์žฅํ–ˆ์œผ๋ฉฐ ํ˜„์žฌ๊นŒ์ง€ ์‹œ๋ฒ”์ ์œผ๋กœ ์šด์šฉ๋˜๋‹ค๊ฐ€, 2023๋…„ 5์›”์— ์ถœ์‹œ๋  Chrome 113 ๋ฒ„์ „์—์„œ ์ •์‹์œผ๋กœ ๋ฆด๋ฆฌ์ฆˆ ๋  ์˜ˆ์ •์ด๋ผ๊ณ  ํ•œ๋‹ค. ๊ฐ™์€ ํฌ๋กœ๋ฏธ์›€ ๊ณ„์—ด์ธ Edge ๋ธŒ๋ผ์šฐ์ € ์—ญ์‹œ ๋ฒ ํƒ€ ์ฑ„๋„์— ๋„์ž…๋œ ์ƒํƒœ์ด๋‹ค. ๋”ฐ๋ผ์„œ ๋ธŒ๋ผ์šฐ์ € ์ž์ฒด์—์„œ ๋น„๊ณต๊ฐœ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์žˆ๋‹ค๋ฉด ์ด์— ๋งž๊ฒŒ ๋Œ€์ฒ˜๋ฅผ ํ•ด์•ผ ํ•  ๊ฒƒ์ด๋‹ค.

 

Private Network Access update: Introducing a deprecation trial - Chrome Developers

Chrome is deprecating access to private network endpoints from non-secure public websites in Chrome 94 as part of the Private Network Access specification. Read on for recommended actions.

developer.chrome.com


PNA CORS ์—๋Ÿฌ ํ˜„์ƒ

 

CORS ์˜ ๋ฉ”์„ธ์ง€ ์ข…๋ฅ˜

 

์ผ๋ฐ˜์ ์ธ CORS ๋ฉ”์„ธ์ง€

๋จผ์ € ์ผ๋ฐ˜์ ์œผ๋กœ ๋ฐœ์ƒํ•˜๋Š” CORS ์—๋Ÿฌ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. ์—๋Ÿฌ ๋ฉ”์„ธ์ง€์—์„œ ์•ˆ๋‚ดํ•˜๋“ฏ์ด ์ด ๋ถ€๋ถ„์€ ๋ฐฑ์—”๋“œ์ชฝ์—์„œ CORS ๊ด€๋ จ ํ—ค๋”์ธ Access-Control-Allow-* ์‘๋‹ต๋งŒ ์ž˜ ํ•ด์ฃผ๋ฉด ๋ณ„๋‹ค๋ฅธ ๋ฌธ์ œ์—†์ด ํ•ด๊ฒฐ์ด ๋œ๋‹ค.

PNA-CORS

Access to XMLHttpRequest at 'http://xxxx' from origin 'http://xxxxx' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

 

PNA CORS ๋ฉ”์„ธ์ง€

๊ทธ๋Ÿฐ๋ฐ ์„œ๋ฒ„์—์„œ CORS ๊ด€๋ จ ํ—ค๋” ์š”์ฒญ ์‘๋‹ต์„ ๋ชจ๋‘ ์ฒ˜๋ฆฌํ•ด์คฌ๋Š”๋ฐ, ์ด๋ฒˆ์—” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋˜๋‹ค๋ฅธ CORS ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ด์„œ ๋‹นํ™ฉํ•œ ๊ฒฝํ—˜์ด ์žˆ์„ ๊ฒƒ์ด๋‹ค.

PNA-CORS

Access to XMLHttpRequest at 'http://10.x.x.x/xxxx' from origin 'http://xxxx.xxx.com' has been blocked by CORS policy:  The request client is not a secure context and the resource is in more-private address space `private`

์œ„ ์—๋Ÿฌ ๋ฉ”์„ธ์ง€ ๋‚ด์šฉ ๋ถ€๋ถ„์„ ํ•ด์„ํ•˜์ž๋ฉด, ์š”์ฒญ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ณด์•ˆ ์ปจํ…์ŠคํŠธ๊ฐ€ ์•„๋‹ˆ๋ฉฐ ๋ฆฌ์†Œ์Šค๊ฐ€ ๋น„๊ณต๊ฐœ ์ฃผ์†Œ ๊ณต๊ฐ„ ๋กœ์ปฌ์— ์žˆ๋‹ค๋Š” ๋ง์ด๋‹ค. ์ฆ‰, ์œ„์—์„œ ๋‹ค๋ฃจ์—ˆ๋˜ PNA(Priavte Network Address) ๊ด€๋ จ ์‚ฌ์–‘์ด๋‹ค.


PNA CORS ๋ฐœ์ƒ ์ƒํ™ฉ

 

์š”์ฒญ ๋‹จ๊ณ„ ๋ฐฉํ–ฅ

ํฌ์ŠคํŒ… ์ดˆ๋ฐ˜์— ์ž ๊น ์†Œ๊ฐœํ–ˆ๋“ฏ์ด, PNA CORS ๋ฐœ์ƒ ์ƒํ™ฉ์€ ๊ณต์ธ IP์—์„œ ์‚ฌ์„ค/๋กœ์ปฌ IP๋กœ์˜ ๋‚ฎ์€ ์ˆ˜์ค€์œผ๋กœ ๊ฐ€๋Š” ์š”์ฒญ์„ ํ• ๋•Œ ๋ฐœ์ƒ๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์•„๋ž˜ ๊ทธ๋ฆผ์—์„œ Public ๋„คํŠธ์›Œํฌ(http://example.com)์—์„œ Private ๋„คํŠธ์›Œํฌ(http://router.local) ๋กœ์˜ ์š”์ฒญ์„ ํ•˜๊ฑฐ๋‚˜, ๋˜๋Š” Private ๋„คํŠธ์›Œํฌ์—์„œ Local ํ˜ธ์ŠคํŠธ์˜ ์š”์ฒญ์ด ์ด์— ํ•ด๋‹น๋œ๋‹ค.

  1. public ๋„คํŠธ์›Œํฌ ์‚ฌ์ดํŠธ → private ๋„คํŠธ์›Œํฌ ์‚ฌ์ดํŠธ (CORS !!)
  2. public ๋„คํŠธ์›Œํฌ ์‚ฌ์ดํŠธ → ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ (CORS !!)
  3. private ๋„คํŠธ์›Œํฌ ์‚ฌ์ดํŠธ → ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ (CORS !!)

pna-cors

 

insecure public website

๋‹ค๋งŒ ๋ฌด์กฐ๊ฑด ๊ณต์ธ ์›น์‚ฌ์ดํŠธ์—์„œ ์š”์ฒญํ•˜๋ฉด PNA CORS์— ๊ฑธ๋ฆฌ๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ, ์ •ํ™•ํžˆ ๋งํ•˜์ž๋ฉด ๋น„์ธ์ฆ๋œ* ๊ณต์ธ ์›น์‚ฌ์ดํŠธ์—์„œ ์š”์ฒญํ•˜๋ฉด ๊ฑธ๋ฆฌ๋Š” ๊ฒƒ์ด๋‹ค. ์ฆ‰, https ๋‚˜ wss ์™€ ๊ฐ™์€ ssl์„ ๋จน์ธ ์‚ฌ์ดํŠธ๋ผ๋ฉด PNA CORS๋Š” ๋ฐœ์ƒํ•˜์ง€ ์•Š๊ฒŒ ๋œ๋‹ค.

pna-cors

 

๋„๋ฉ”์ธ ์—ฌ๋ถ€

๋งˆ์ง€๋ง‰์œผ๋กœ ์š”์ฒญ์„ ๋ณด๋‚ธ ๊ณต์ธ ์›น์‚ฌ์ดํŠธ๊ฐ€ ์•„์ดํ”ผ ํ˜•ํƒœ๊ฐ€ ์•„๋‹Œ ๋„๋ฉ”์ธ์ด ์”Œ์›Œ์ ธ ์žˆ์„ ๊ฒฝ์šฐ์—๋งŒ ๋ฐœ์ƒํ•œ๋‹ค. ์•„๋ฌด๋ฆฌ insecure public website ์ด๋ผ๋„ ๋„๋ฉ”์ธ ํ˜•ํƒœ๊ฐ€ ์•„๋‹๊ฒฝ์šฐ PNA CORS ์—๋Ÿฌ๋Š” ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค.

pna-cors


PNA CORS ๊ด€๋ จ ํ—ค๋”

์ผ๋ฐ˜์ ์ธ CORS ํ˜„์ƒ์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด Access-Control-Allow-Origin ํ—ค๋”๋ฅผ ์„ค์ •ํ•˜์—ฌ ํ•ด๊ฒฐ ํ•˜์˜€ ๋“ฏ์ด, PNA CORS ์—ญ์‹œ ๊ด€๋ จ ํ—ค๋”์ธ Access-Control-Allow-Private-Network ํ—ค๋”๋ฅผ ์„ค์ • ํ•˜๋ฉด ๋œ๋‹ค. ์ด๋ฅผ ๋„์‹์œผ๋กœ ํ‘œํ˜„ํ•˜์ž๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ๋œ๋‹ค.

  1. ํ•˜์œ„ ์ž์›์— ๋Œ€ํ•œ ์š”์ฒญ์„ ์‚ฌ์„ค๋ง์— ๋ณด๋‚ด๊ธฐ ์ „์—, ์•ž์„œ ์˜ˆ๋น„ ์š”์ฒญ(Preflight)์„ ๋ณด๋‚ธ๋‹ค.
  2. ์ด๋•Œ ์š”์ฒญ ํ—ค๋”์— Access-Control-Request-Private-Network: true ๋ฅผ ์‹ค์–ด ์„œ๋ฒ„์— ๋ณด๋‚ธ๋‹ค
  3. ์š”์ฒญ ์ „๋‹ฌ์„ ๋ฐ›์€ ์„œ๋ฒ„์—์„œ Access-Control-Allow-Private-Network: true ๋ฅผ ํ†ตํ•ด ํ—ˆ๋ฝ์ด๋‚˜ ๋ถˆํ—ˆ๋ฅผ ์‘๋‹ตํ•œ๋‹ค.
  4. ์—‘์„ธ์Šค ํ—ˆ๋ฝ์ด ๋˜๋ฉด ๋ณธ์š”์ฒญ ํ†ต์‹ ์ด ์ด๋ฃจ์–ด์ง€๊ฒŒ ๋œ๋‹ค.

pna-cors


PNA CORS ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

 

1. ์š”์ฒญ ์ฃผ์ฒด๋ฅผ ๋ณ€๊ฒฝ

์•ž์„œ ๋งํ–ˆ๋“ฏ์ด ๊ณต์ธ IP๋ผ๊ณ  ํ•ด๋„ insecure์ผ ๊ฒฝ์šฐ์—๋งŒ PNA CORS๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๊ณ  ํ•˜์˜€์œผ๋‹ˆ, ํ˜ธ์ถœํ•˜๋Š” ์ฃผ์ฒด์˜ scheme๋ฅผ HTTPS๋กœ ์„ค์ •ํ•˜๋ฉด ๊ฐ€์ ธ์˜ค๋ ค๋Š” ๋ฆฌ์†Œ์Šค๊ฐ€ HTTP์—ฌ๋„ ๋ฌธ์ œ์—†์ด ํ˜ธ์ถœ์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.

ํ˜น์€ ์š”์ฒญํ•˜๋ ค๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์„ค/๋กœ์ปฌ ๋„คํŠธ์›Œํฌ๊ฐ€ ์•„๋‹Œ ๊ณต์ธ ๋„คํŠธ์›Œํฌ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

2. ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ € ์˜ต์…˜ ๋ณ€๊ฒฝ

ํฌ๋กฌ ํ˜น์€ ์—ฃ์ง€ ๋ธŒ๋ผ์šฐ์ € ๊ฒ€์ƒ‰์ฐฝ์— ๋‹ค์Œ URL๋กœ ์ด๋™ํ•œ๋‹ค.

  • chrome://flags
  • edge://flags

๊ทธ๋ฆฌ๊ณ  Block insecure private network requests ํ•ญ๋ชฉ๊ณผ Send Private Network Access preflights ํ•ญ๋ชฉ์˜ ์„ค์ •๊ฐ’์„ Disabled๋กœ ์„ค์ • ํ•˜๋ฉด ๋œ๋‹ค.

pna-cors

 

3. Chrome Origin Trials ์ด์šฉ

๊ฐœ๋ฐœ์ž ์ง€์› ๊ธฐ๋Šฅ์„ ์ด์šฉํ•˜์—ฌ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ ์ ‘๊ทผ์„ ํ—ˆ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

https://developer.chrome.com/origintrials/#/trials/active ๋กœ ์ ‘์†ํ•ด์„œ, Private Network Access from non-secure contexts ํ•ญ๋ชฉ์˜ REGISTER ๋ฅผ ํด๋ฆญํ•œ๋‹ค. ๋‹จ, ์ด ๋ฐฉ๋ฒ•์€ PNA๋ฅผ ํ—ˆ์šฉํ•  ์›น์‚ฌ์ดํŠธ์˜ API ํ‚ค๋ฅผ ๋ฐœ๊ธ‰๋ฐ›์•„ ์‚ฌ์šฉํ•˜๋Š” ํ˜•ํƒœ์ด๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๊ฐ„์ด ์ •ํ•ด์ ธ ์žˆ๋‹ค.

pna-cors

 

4. Access-Control-Allow-Private-Network ํ—ค๋” ์„ค์ •

์ง€๊ธˆ๊นŒ์ง€ ์†Œ๊ฐœํ•œ ์œ„์˜ ๋ฐฉ๋ฒ•์€ ๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค์ •๋งŒ์œผ๋กœ ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•˜๊ฒ ์ง€๋งŒ, ์ด๋Š” ๋ณด์•ˆ์ ์œผ๋กœ ์•ˆ์ „ํ•˜์ง€ ์•Š์œผ๋ฉฐ, CORS๋Š” ์„œ๋ฒ„๊ฐ€ ์•„๋‹Œ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ฐจ๋‹จํ•˜๋Š” ๋ฉ”์ปค๋‹ˆ์ฆ˜ ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์„œ๋น„์Šค ์ด์šฉ์ž๋“ค์ด ์ง์ ‘ ์ž๊ธฐ๊ฐ€ ์“ฐ๋Š” ์ปดํ“จํ„ฐ์˜ ๋ธŒ๋ผ์šฐ์ € ์„ค์ •์„ ์ผ์ผํžˆ ์กฐ์ž‘ํ•ด์•ผ ํ•œ๋‹ค๋Š” ๋ฒˆ๊ฑฐ๋กญ๋‹ค๋Š” ์น˜๋ช…์ ์ธ ๋‹จ์ ์ด ์กด์žฌํ•œ๋‹ค.

๋”ฐ๋ผ์„œ ๊ฐ€์žฅ ์ด์ƒ์ ์ธ ํ•ด๊ฒฐ์ฑ…์€ ๋ฐฑ์—”๋“œ์ชฝ์—์„œ Access-Control-Allow-Private-Network ํ—ค๋” ์„ค์ •์„ ํ•˜๋ฉด ๋˜๋Š” ๊ฒƒ์ด๋‹ค.

HTTP/1.1 OPTIONS localhost:8080/cat.gif
Origin: https://foo.example
Access-Control-Request-Private-Network: true
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://foo.example
Access-Control-Allow-Private-Network: true

# ์ฐธ๊ณ ์ž๋ฃŒ

https://www.boannews.com/media/view.asp?idx=104187

https://developer.chrome.com/blog/private-network-access-update/

https://arstechnica.com/information-technology/2022/01/new-chrome-security-measure-aims-to-curtail-an-entire-class-of-web-attack/