Repository navigation
fix(gateway): HTTPS 服务默认注入 X-Frame-Options: SAMEORIGIN - #43
Merged
Merged
Conversation
X-Frame-Options: DENY 会连同源 iframe 一起禁止,把依赖「父窗口驱动同源预览」 的应用直接打断:预览空白,且浏览器拿到跨源空 frame 后持续抛 SecurityError。 - 安全头改为「仅补齐、不覆盖」;上游已声明 X-Frame-Options 或 CSP frame-ancestors 时网关不再注入,避免反向代理改写源站策略 - 新增服务级 FrameOptions 配置(SAMEORIGIN / DENY / NONE),默认 SAMEORIGIN; 旧 gateway.config 缺字段时同样取默认值,非法值回退以规避响应头注入 - 管理界面「服务 → 功能设置」增加 iframe 嵌套策略选项 - 新增 FrameOptionsTests,覆盖默认值、大小写、非法值回退、禁用与上游策略优先
There was a problem hiding this comment.
🟡 Changes recommended
The CSP substring check can mistake a reporting URL containing frame-ancestors for a framing directive, suppressing configured X-Frame-Options protection and leaving responses vulnerable to clickjacking.
1 open issue
What changed in this PR
This PR restores same-origin iframe support for HTTPS gateways by defaulting to X-Frame-Options: SAMEORIGIN, while preserving upstream security policies.
Changes:
- Makes security-header injection additive rather than overwriting upstream values.
- Adds per-service framing configuration and dashboard controls.
- Adds policy-resolution tests and documents the behavior change.
| File | Description |
|---|---|
web/src/types/index.ts |
Defines framing options and the server configuration field. |
web/src/pages/server/features/UpdateServer.tsx |
Adds framing-policy selection when editing services. |
web/src/pages/server/features/CreateServer.tsx |
Adds framing-policy selection when creating services. |
tests/FastGateway.Tests/FrameOptionsTests.cs |
Tests defaults, normalization, disabling, and upstream-policy precedence. |
src/FastGateway/Services/ServerService.cs |
Includes framing configuration in server-list responses. |
src/FastGateway/Gateway/Gateway.cs |
Updates security-header injection and resolves configured framing policies. |
src/FastGateway/Dto/ServerDto.cs |
Exposes framing configuration in the server DTO. |
src/Core/Entities/Server.cs |
Adds the persisted service-level framing setting. |
CHANGELOG.md |
Documents the new behavior, configuration, and tests. |
Review effort: Balanced
Comment on lines
+645
to
+646
| csp.ToString().Contains("frame-ancestors", | ||
| StringComparison.OrdinalIgnoreCase); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

X-Frame-Options: DENY 会连同源 iframe 一起禁止,把依赖「父窗口驱动同源预览」 的应用直接打断:预览空白,且浏览器拿到跨源空 frame 后持续抛 SecurityError。
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context