Merge pull request 'Security: frame-src van het StrictSite-beleid zonder 'self'' (#33) from fix/asf-csp-frame-src into master
Continuous Integration / config-sls (push) Successful in 5s
Continuous Integration / config-asf (push) Successful in 7s
Continuous Integration / changes (push) Successful in 38s
Continuous Integration / frontend-prepare (push) Skipped
Continuous Integration / frontend-build (push) Skipped
Continuous Integration / frontend-test (push) Skipped
Continuous Integration / frontend-lint (push) Skipped
Continuous Integration / backend-build (push) Successful in 1m42s
Continuous Integration / compile-sites (push) Successful in 1m38s
Continuous Integration / backend-test (push) Successful in 3m51s
Continuous Integration / vulnerability-scan (push) Successful in 10m27s
Continuous Integration / publish-sls-production (push) Skipped
Continuous Integration / deploy-sls-production (push) Skipped
Continuous Integration / publish-asf-test (push) Successful in 2m25s
Continuous Integration / publish-sls-test (push) Successful in 2m29s
Continuous Integration / deploy-sls-test (push) Successful in 1m20s
Continuous Integration / deploy-asf-test (push) Successful in 1m23s
Continuous Integration / smoke-sls-test (push) Successful in 13s
Continuous Integration / smoke-asf-test (push) Successful in 13s
Deploy (SCP) / deploy (push) Successful in 1m13s

This commit was merged in pull request #33.
This commit is contained in:
2026-11-18 19:58:11 +01:00
3 changed files with 6 additions and 5 deletions
@@ -154,11 +154,11 @@ public class StrictSiteFrameSourceTests
}
[Fact]
public void WithFrameOrigins_FrameSrcListsSelfAndThemOnly_BeforeObjectSrc()
public void WithFrameOrigins_FrameSrcListsThemOnly_WithoutSelf_BeforeObjectSrc()
{
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.FrameOptions.Should().Be("DENY");
}
@@ -201,6 +201,6 @@ public class StrictSiteFrameSourceTests
using var provider = services.BuildServiceProvider();
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();
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(
@@ -74,7 +74,7 @@ public sealed class SecurityHeadersOptions
/// <summary>
/// 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>).
/// 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>
public IList<string> AllowedSiteFrameOrigins { get; set; } = [];
}