Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default policies #183

Merged
merged 2 commits into from
Sep 15, 2024
Merged

Update default policies #183

merged 2 commits into from
Sep 15, 2024

Conversation

andrewlock
Copy link
Owner

@andrewlock andrewlock commented Sep 15, 2024

  • Adds a "default secure" permissions policy option, based on the suggestion from OWASP
    • Only includes directives that are supported by the library (i.e. not experimental/unsupported) directives etc
  • Updates the default CSP to add default-src: none instead of obj-src:none (the latter falls back to default-src.
  • Add an "API" default secure set of headers, based on the suggestion from OWASP for non-HTML endpoints. You can add this by calling AddDefaultApiSecurityHeaders()

For the permissions-policy secure default, you can do

app.UseSecurityHeaders(p => p.AddPermissionsPolicyWithRecommendedDirectives());

This is equivalent to calling

app.UseSecurityHeaders(p => p.AddPermissionsPolicy(builder => 
{
    builder.AddAccelerometer().None();
    builder.AddAmbientLightSensor().None();
    builder.AddAutoplay().None();
    builder.AddCamera().None();
    builder.AddDisplayCapture().None();
    builder.AddEncryptedMedia().None();
    builder.AddFullscreen().None();
    builder.AddGeolocation().None();
    builder.AddGyroscope().None();
    builder.AddMagnetometer().None();
    builder.AddMicrophone().None();
    builder.AddMidi().None();
    builder.AddPayment().None();
    builder.AddPictureInPicture().None();
    builder.AddPublickeyCredentialsGet().None();
    builder.AddScreenWakeLock().None();
    builder.AddSyncXHR().None();
    builder.AddUsb().None();
    builder.AddWebShare().None();
    builder.AddXrSpatialTracking().None();
}));

Related to #133

@andrewlock andrewlock merged commit 80a2080 into major_v_bump Sep 15, 2024
3 checks passed
@andrewlock andrewlock deleted the update-default-policies branch September 15, 2024 17:09
@andrewlock andrewlock mentioned this pull request Sep 15, 2024
andrewlock added a commit that referenced this pull request Sep 25, 2024
* Add a "default secure" permissions policy, as suggested by OWASP

* Update default header policies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant