๋ณธ๋ฌธ์œผ๋กœ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์˜ค๋ฅ˜1. ์นด์นด์˜ค SDK ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ import ์‹คํŒจ

์˜ค๋ฅ˜2. ๊ตฌ๊ธ€ ์• ๋“œ์„ผ์Šค ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ import ์‹คํŒจ

 

Refused to load the script 'https://developers.kakao.com/sdk/js/kakao.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. result:1 Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. 

 

์ด์œ : XSS๊ณต๊ฒฉ์„ ๋ง‰๊ธฐ ์œ„ํ•ด ์™ธ๋ถ€ javascriptํŒŒ์ผ import๋ฅผ ๋ง‰์•„๋†“์€ ๋ณด์•ˆ ๊ธฐ๋Šฅ

 

ํ•ด๊ฒฐ ๊ณผ์ •

 

1. HTML์— ์™ธ๋ถ€ ์Šคํฌ๋ฆฝํŠธ ํ—ˆ์šฉ ๋ฉ”ํƒ€ํƒœ๊ทธ ์ถ”๊ฐ€

2. ์›นํŒฉ ๋ชจ๋“ˆ external ์ถ”๊ฐ€

3. ์›น ํŒฉ ์—”ํŠธ๋ฆฌ์— ์™ธ๋ถ€ ์Šคํฌ๋ฆฝํŠธ ์ฃผ์†Œ ์ž…๋ ฅ

4. sdk๋ฅผ ์ง์ ‘ ๋‹ค์šด ๋ฐ›์•„, ๋กœ์ปฌํ™˜๊ฒฝ์—์„œ ์›นํŒฉ์œผ๋กœ ๋ฒˆ๋“ค๋ง --> ์• ๋“œ์„ผ์Šค ์Šคํฌ๋ฆฝํŠธ๋Š” ๋ถˆ๊ฐ€

5. helmet CSP์„ค์ • ์ˆ˜์ •

css, image๋“ค์€ ๋ฌธ์ œ์—†์ด import๋˜์—ˆ๋–ค ์ด์œ ๋Š” helmetCSP์— JS๋งŒ ๋ง‰์•„๋†“์•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. 

์ด๋•Œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ง€์› ๋‹ค ์—†์• ๊ณ  ๋‹ค์‹œ ์ถ”๊ฐ€ํ•ด์•ผ ์ปจ์†”์— ์˜ค๋ฅ˜๊ฐ€ ์‚ฌ๋ผ์ง„๋‹ค.

 

 

app.use(
  helmet({
    contentSecurityPolicy: false,
  })
);

const contentSecurityPolicy = require("helmet-csp");

app.use(
  contentSecurityPolicy({
    directives: {
      defaultSrc: ["'self'", "default.example"],
      scriptSrc: ["'self'", "'unsafe-inline'"],
      objectSrc: ["'none'"],
      upgradeInsecureRequests: [],
    },
    reportOnly: false,
  })
);

 

 

 

github.com/helmetjs/helmet/tree/main/middlewares/content-security-policy

 

helmetjs/helmet

Help secure Express apps with various HTTP headers - helmetjs/helmet

github.com

blog.uniony.me/nodejs/helmet/

 

Express ์›น์‚ฌ์ดํŠธ ๋ณด์•ˆ ๊ฐ•ํ™”ํ•˜๊ธฐ [Helmet, CSP]

Express๋กœ ๋งŒ๋“ค์–ด์ง„ ์›น ์‚ฌ์ดํŠธ์˜ ๋ณด์•ˆ์„ ๊ฐ•ํ™”ํ•˜๊ธฐ ์œ„ํ•ด Helmet ๋ฏธ๋“ค์›จ์–ด๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

blog.uniony.me

crispypotato.tistory.com/72

 

helmet, helmet-csp์‚ฌ์šฉ๋ฐฉ๋ฒ•, ์˜ค๋ฅ˜ Refused to load the

ํ™˜๊ฒฝ: express VUE์—์„œ cdn์œผ๋กœ ๋ฐ›์•„์˜ค๋Š” ํฐํŠธ๋‚˜, ์ด๋ฏธ์ง€, cssํ˜•์‹ํŒŒ์ผ์€ helmet์€ ์œ„ํ—˜ํ•œ ํŒŒ์ผ์ด๋ผ๊ณ  ์ธ์‹์„ ํ•˜์—ฌ ๋ง‰๋Š”๋‹ค ๊ทธ๋ž˜์„œ ๋นŒ๋“œ ํ•œ ํŒŒ์ผ์„ Express์—์„œ ์‹คํ–‰ ์‹œํ‚ค๋ฉด์„œ ํ•˜๋‚˜์˜ ์„œ๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด์„œ he

crispypotato.tistory.com

 

๋ฐ˜์‘ํ˜•