fix(security): configure Express trust proxy and add Content-Security-Policy headers
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Start with apps/api/src/main.ts and apps/web/next.config.ts, then check the deployment proxy setup and the web app’s external script, analytics, and embed origins. Configure proxy trust and API Helmet CSP, and add a report-only web CSP that covers the required origins. Done means client IP handling works for deployed and local setups, API responses have the stated restrictive CSP, and browser reports can be reviewed before web enforcement.
索引モデルが issue の本文から書いたものです。
説明
Problem Description
- Missing
trust proxyinapps/api/src/main.ts:
NestFactory.create(AppModule, { rawBody: true })does not configure Expresstrust proxy. Behind a reverse proxy or load balancer (Cloudflare, Nginx, etc.),req.ipresolves to the proxy's IP rather than the real client IP, causing users across workspaces to share a single rate-limit bucket or breaking IP-based throttling. - Missing Content-Security-Policy (CSP):
apps/api/src/main.tsexplicitly disables Helmet's CSP (contentSecurityPolicy: false).apps/web/next.config.ts(headers()for/:path*) setsX-Frame-Options,X-Content-Type-Options,Referrer-Policy, andPermissions-Policy, but sets noContent-Security-Policyheader.
Expected Behavior
apps/api/src/main.tsconfigures Expresstrust proxyvia an environment variable (e.g.,TRUST_PROXY, defaulting to1in production andfalselocally, or2when behind Cloudflare + Nginx) soreq.ipreflects the real client IP without breaking local/direct setups.apps/api/src/main.tsenables a restrictive Helmet CSP appropriate for API responses (defaultSrc: ["'none'"],frameAncestors: ["'none'"]).apps/web/next.config.tsrolls out aContent-Security-Policy-Report-Onlyheader first so existing scripts, pixels, and embeds are never accidentally blocked for users, and promotes it toContent-Security-Policyonce verified.
Where to Look
apps/api/src/main.tsapps/web/next.config.ts
Solution / Implementation Guide
- API
trust proxy& Helmet CSP (apps/api/src/main.ts):- Configure Express
trust proxyfromprocess.env.TRUST_PROXY(e.g.app.getHttpAdapter().getInstance().set('trust proxy', ...)), matching the deployment hop count (1behind a single proxy,2behind CDN + proxy,falsewhen no proxy is used). - Enable a strict
contentSecurityPolicyinhelmet(...)instead offalse.
- Configure Express
- Next.js CSP (
apps/web/next.config.ts):- Add a
Content-Security-Policy-Report-Onlyheader undersource: "/:path*"listing the app's required origins (API URL, analytics/pixel domains, YouTube/Spotify/Instagram embed & CDN hosts,frame-ancestors 'none'). - Monitor browser violation reports in staging/production before switching the header to enforcing
Content-Security-Policy.
- Add a
- 主要言語
- TypeScript
- スター
- 2
- フォーク
- 1
- 平均マージ
- 6分
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sumamakhan761/tryinstance のほかの issue
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#65 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sumamakhan761/tryinstance#64 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
sumamakhan761/tryinstance#63 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#62 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sumamakhan761/tryinstance#60 ·
メンテナーはふだん 1 日以内に返信
sumamakhan761/tryinstance の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
makecindy/cindy#15342 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
kwitsch/claude-code-plugin-tooling#219 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
no-repo-link tool-submission
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100