Skip to content

internal: add CSP header to files in /media#12092

Merged
gergosimonyi merged 1 commit intomainfrom
internal/add-csp-header-to-admin-uploaded-content
Nov 21, 2024
Merged

internal: add CSP header to files in /media#12092
gergosimonyi merged 1 commit intomainfrom
internal/add-csp-header-to-admin-uploaded-content

Conversation

@gergosimonyi
Copy link
Collaborator

This fixes a security issue of stored cross-site scripting via embedding JavaScript in SVG files by a malicious user with can_save_media capability.

This can be exploited if:

  • the uploaded file is served from the same origin as authentik, and
  • the user opens the uploaded file directly in their browser

This fixes a security issue of stored cross-site scripting via embedding
JavaScript in SVG files by a malicious user with `can_save_media`
capability.

This can be exploited if:
- the uploaded file is served from the same origin as authentik, and
- the user opens the uploaded file directly in their browser

Co-authored-by: Jens L. <jens@goauthentik.io>
@netlify
Copy link

netlify bot commented Nov 20, 2024

Deploy Preview for authentik-docs canceled.

Name Link
🔨 Latest commit 1d275a8
🔍 Latest deploy log https://app.netlify.com/sites/authentik-docs/deploys/673df7b9a362a60008dc9fc3

@netlify
Copy link

netlify bot commented Nov 20, 2024

Deploy Preview for authentik-storybook canceled.

Name Link
🔨 Latest commit 1d275a8
🔍 Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/673df7b999f98b00080c84ba

@codecov
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.89%. Comparing base (dc9de43) to head (1d275a8).

✅ All tests successful. No failed tests found.

❗ There is a different number of reports uploaded between BASE (dc9de43) and HEAD (1d275a8). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (dc9de43) HEAD (1d275a8)
e2e 8 2
unit 2 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #12092       +/-   ##
===========================================
- Coverage   92.60%   44.89%   -47.71%     
===========================================
  Files         761      759        -2     
  Lines       37929    37666      -263     
===========================================
- Hits        35124    16911    -18213     
- Misses       2805    20755    +17950     
Flag Coverage Δ
e2e 43.59% <ø> (-5.50%) ⬇️
integration 24.85% <ø> (ø)
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@github-actions
Copy link
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-1d275a8eef80995c094a3607f9dc01cb46b6ea8e
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

For arm64, use these values:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-1d275a8eef80995c094a3607f9dc01cb46b6ea8e-arm64
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-1d275a8eef80995c094a3607f9dc01cb46b6ea8e

For arm64, use these values:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-1d275a8eef80995c094a3607f9dc01cb46b6ea8e-arm64

Afterwards, run the upgrade commands from the latest release notes.

@gergosimonyi gergosimonyi marked this pull request as ready for review November 20, 2024 15:32
@gergosimonyi gergosimonyi requested a review from a team as a code owner November 20, 2024 15:32
@gergosimonyi gergosimonyi requested a review from BeryJu November 20, 2024 15:32
@BeryJu
Copy link
Member

BeryJu commented Nov 20, 2024

/cherry-pick version-2024.10

@gergosimonyi gergosimonyi merged commit 4189981 into main Nov 21, 2024
@gergosimonyi gergosimonyi deleted the internal/add-csp-header-to-admin-uploaded-content branch November 21, 2024 08:16
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Nov 21, 2024
add CSP header to files in `/media`

This fixes a security issue of stored cross-site scripting via embedding
JavaScript in SVG files by a malicious user with `can_save_media`
capability.

This can be exploited if:
- the uploaded file is served from the same origin as authentik, and
- the user opens the uploaded file directly in their browser

Co-authored-by: Jens L. <jens@goauthentik.io>
gergosimonyi added a commit that referenced this pull request Nov 21, 2024
…12108)

internal: add CSP header to files in `/media` (#12092)

add CSP header to files in `/media`

This fixes a security issue of stored cross-site scripting via embedding
JavaScript in SVG files by a malicious user with `can_save_media`
capability.

This can be exploited if:
- the uploaded file is served from the same origin as authentik, and
- the user opens the uploaded file directly in their browser

Co-authored-by: Simonyi Gergő <28359278+gergosimonyi@users.noreply.github.com>
Co-authored-by: Jens L. <jens@goauthentik.io>
kensternberg-authentik added a commit that referenced this pull request Nov 21, 2024
* main: (23 commits)
  website/docs: update info about footer links to match new UI (#12120)
  website/docs: prepare release notes (#12142)
  providers/oauth2: fix migration (#12138)
  providers/oauth2: fix migration dependencies (#12123)
  web: bump API Client version (#12129)
  providers/oauth2: fix redirect uri input (#12122)
  providers/proxy: fix redirect_uri (#12121)
  website/docs: prepare release notes (#12119)
  web: bump API Client version (#12118)
  security: fix CVE 2024 52289 (#12113)
  security: fix CVE 2024 52307 (#12115)
  security: fix CVE 2024 52287 (#12114)
  website/docs: add CSP to hardening (#11970)
  core: bump uvicorn from 0.32.0 to 0.32.1 (#12103)
  core: bump google-api-python-client from 2.153.0 to 2.154.0 (#12104)
  core: bump pydantic from 2.9.2 to 2.10.0 (#12105)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in it (#12110)
  internal: add CSP header to files in `/media` (#12092)
  core, web: update translations (#12101)
  web: fix bug that prevented error reporting in current wizard. (#12033)
  ...
kensternberg-authentik added a commit that referenced this pull request Nov 21, 2024
* main: (23 commits)
  website/docs: update info about footer links to match new UI (#12120)
  website/docs: prepare release notes (#12142)
  providers/oauth2: fix migration (#12138)
  providers/oauth2: fix migration dependencies (#12123)
  web: bump API Client version (#12129)
  providers/oauth2: fix redirect uri input (#12122)
  providers/proxy: fix redirect_uri (#12121)
  website/docs: prepare release notes (#12119)
  web: bump API Client version (#12118)
  security: fix CVE 2024 52289 (#12113)
  security: fix CVE 2024 52307 (#12115)
  security: fix CVE 2024 52287 (#12114)
  website/docs: add CSP to hardening (#11970)
  core: bump uvicorn from 0.32.0 to 0.32.1 (#12103)
  core: bump google-api-python-client from 2.153.0 to 2.154.0 (#12104)
  core: bump pydantic from 2.9.2 to 2.10.0 (#12105)
  translate: Updates for file locale/en/LC_MESSAGES/django.po in it (#12110)
  internal: add CSP header to files in `/media` (#12092)
  core, web: update translations (#12101)
  web: fix bug that prevented error reporting in current wizard. (#12033)
  ...
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.

2 participants