CORS middleware reflects Origin with Allow-Credentials, enabling cross-origin attacks (CWE-346)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
調査の方向性
まず、参照されている65-69行目、88行目、91行目の st2common/st2common/middleware/cors.py を読み、設定されたoriginがどのようにレスポンスヘッダーになるかを追跡します。ワイルドカードoriginにはcredentialsが付与されず、明示的にallowlistに登録されたoriginではcredentialsが維持され、ハードコードされたlocalhost originが本番のデフォルト値に含まれていないことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Summary
The CORS middleware reflects the request's Origin header back as Access-Control-Allow-Origin when the configured allow_origin contains *, while simultaneously setting Access-Control-Allow-Credentials: true. This is a well-known CORS misconfiguration that allows any website to make authenticated cross-origin requests to the StackStorm API.
Affected File
st2common/st2common/middleware/cors.py (lines 65-69, 88, 91)
if origin:
if "*" in origins:
origin_allowed = origin # reflects whatever the browser sends
else:
origin_allowed = origin if origin in origins else list(origins)[0]
# ...
headers["Access-Control-Allow-Origin"] = origin_allowed
# ...
headers["Access-Control-Allow-Credentials"] = "true" # always set
Additionally, the middleware hardcodes localhost development origins that are always allowed:
# Default gulp development server WebUI URL
origins.add("http://127.0.0.1:3000")
# By default WebUI simple http server listens on 8080
origins.add("http://localhost:8080")
origins.add("http://127.0.0.1:8080")
Impact
When allow_origin contains *:
Any website can make authenticated, credential-bearing requests to the StackStorm API from a user's browser. If a StackStorm user visits a malicious page while logged in, the attacker can:
- Read API responses (execution results, datastore values, pack configurations)
- Trigger action executions
- Modify rules and workflows
- Exfiltrate API keys and tokens
This is because the combination of a reflected Access-Control-Allow-Origin and Access-Control-Allow-Credentials: true tells the browser to include cookies/auth headers and allow the response to be read by the requesting page.
Hardcoded localhost origins:
If an attacker can run a web server on localhost:3000 or localhost:8080 on a machine where a StackStorm user has an active session, they can exploit these hardcoded origins. These should not be present in production builds.
Recommended Fix
-
Never reflect the
Originheader whenAccess-Control-Allow-Credentialsistrue. If wildcard origin is configured, either:- Set
Access-Control-Allow-Origin: *and removeAccess-Control-Allow-Credentials(allows unauthenticated CORS only) - Or reject the configuration and log a warning
- Set
-
Remove hardcoded localhost origins from the default allowed list. These should only be present in development configurations.
-
Only set
Access-Control-Allow-Credentials: truewhen the origin is explicitly whitelisted (not wildcarded).
if origin and origin in origins:
headers["Access-Control-Allow-Origin"] = origin
headers["Access-Control-Allow-Credentials"] = "true"
elif "*" in origins:
headers["Access-Control-Allow-Origin"] = "*"
# Do NOT set Allow-Credentials with wildcard origin
References
- CWE-346: Origin Validation Error
- PortSwigger: Exploiting CORS Misconfigurations
- Discovered via manual code review
- 主要言語
- Python
- スター
- 6.5k
- フォーク
- 793
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
StackStorm/st2 のほかの issue
-
yaml.FullLoader used instead of SafeLoader in pack metadata parsing (CWE-502)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
StackStorm/st2#6393 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Git worktree directories created with chmod 777 (CWE-732)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
StackStorm/st2#6392 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
StackStorm/st2#6389 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
StackStorm/st2#6387 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
StackStorm/st2#6391 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
Deferred from #1869: Complete the companion pytest guardrail update noted in the PR description...オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#140958 ·
メンテナーはふだん 1 日以内に返信
-
Bug triage/confirmed
難易度 2/5 半日 初心者へのやさしさ 85/100
agentscope-ai/agentscope#3355 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
ethereum/execution-specs#3859 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信