CSP: frame-src van de site-policy zonder 'self' (alleen de ingestelde derde partijen)
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 7s
Continuous Integration / changes (pull_request) Successful in 30s
Continuous Integration / frontend-prepare (pull_request) Skipped
Continuous Integration / frontend-build (pull_request) Skipped
Continuous Integration / frontend-test (pull_request) Skipped
Continuous Integration / frontend-lint (pull_request) Skipped
Continuous Integration / backend-build (pull_request) Successful in 1m0s
Continuous Integration / compile-sites (pull_request) Successful in 1m14s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m17s
Continuous Integration / backend-test (pull_request) Successful in 3m8s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 19:38:46 +01:00
co-authored by Claude Sonnet 5.5
parent a7ceba4c15
commit 4666c9eb52
3 changed files with 6 additions and 5 deletions
@@ -154,11 +154,11 @@ public class StrictSiteFrameSourceTests
} }
[Fact] [Fact]
public void WithFrameOrigins_FrameSrcListsSelfAndThemOnly_BeforeObjectSrc() public void WithFrameOrigins_FrameSrcListsThemOnly_WithoutSelf_BeforeObjectSrc()
{ {
var set = CspPolicyCatalog.Build(CspPolicyCatalog.StrictSite, [], [], null, null, [Global, Eu + "/"]); var set = CspPolicyCatalog.Build(CspPolicyCatalog.StrictSite, [], [], null, null, [Global, Eu + "/"]);
set.ContentSecurityPolicy.Should().Contain($"frame-src 'self' {Global} {Eu}; object-src 'none'"); set.ContentSecurityPolicy.Should().Contain($"frame-src {Global} {Eu}; object-src 'none'");
set.ContentSecurityPolicy.Should().Contain("frame-ancestors 'none'"); set.ContentSecurityPolicy.Should().Contain("frame-ancestors 'none'");
set.FrameOptions.Should().Be("DENY"); set.FrameOptions.Should().Be("DENY");
} }
@@ -201,6 +201,6 @@ public class StrictSiteFrameSourceTests
using var provider = services.BuildServiceProvider(); using var provider = services.BuildServiceProvider();
provider.GetRequiredService<ICspPolicyProvider>().Get(CspPolicyCatalog.StrictSite) provider.GetRequiredService<ICspPolicyProvider>().Get(CspPolicyCatalog.StrictSite)
.ContentSecurityPolicy.Should().Contain($"frame-src 'self' {Global};"); .ContentSecurityPolicy.Should().Contain($"frame-src {Global};");
} }
} }
@@ -71,7 +71,8 @@ public static class CspPolicyCatalog
.Where(origin => !string.IsNullOrWhiteSpace(origin)).ToArray(); .Where(origin => !string.IsNullOrWhiteSpace(origin)).ToArray();
if (frames.Length > 0) if (frames.Length > 0)
{ {
directives.Add($"frame-src {Join("'self'", frames)}"); // No 'self': a website that embeds only a third party (the captcha widget) frames nothing of its own.
directives.Add($"frame-src {Join(string.Empty, frames).Trim()}");
} }
directives.AddRange( directives.AddRange(
@@ -74,7 +74,7 @@ public sealed class SecurityHeadersOptions
/// <summary> /// <summary>
/// Origins added as a <c>frame-src</c> directive under the <c>StrictSite</c> policy only (for example the Friendly /// Origins added as a <c>frame-src</c> directive under the <c>StrictSite</c> policy only (for example the Friendly
/// Captcha widget, which renders in an iframe: <c>https://global.frcapi.com</c>, <c>https://eu.frcapi.com</c>). /// Captcha widget, which renders in an iframe: <c>https://global.frcapi.com</c>, <c>https://eu.frcapi.com</c>).
/// Empty (the default) adds no <c>frame-src</c> at all, so existing headers are unchanged. /// Empty (the default) adds no <c>frame-src</c> at all, so existing headers are unchanged. The directive lists exactly these origins, without <c>'self'</c>.
/// </summary> /// </summary>
public IList<string> AllowedSiteFrameOrigins { get; set; } = []; public IList<string> AllowedSiteFrameOrigins { get; set; } = [];
} }