Skip to content

Buffer progress bar "ball" is blocked by CSP due to data url svg #8876

Closed

Description

@zakhenry

Bug, feature request, or proposal:

Currently the buffer bar has inlined SVG's loaded with a data-url, however this is blocked when content security policy are set with the directive "img-src 'self'".

Refused to load the image 'data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D[...]' because it violates the following Content Security Policy directive: "img-src 'self'".

What is the expected behavior?

All assets should be able to load with tight CSP configuration

What is the current behavior?

Assets loaded via data url are blocked by CSP

What are the steps to reproduce?

(this cannot be reproduced in Stackblitz etc due to CSP being set by webserver or within <head>)

  1. Set the CSP to contain img-src 'self'
    e.g.
    content-security-policy:default-src 'none';object-src 'self';manifest-src 'self';script-src 'self';img-src 'self';style-src 'self' 'unsafe-inline';frame-src 'self';worker-src 'self' blob:
  2. Insert a <mat-progress-bar mode="buffer"></mat-progress-bar>
  3. See the inlined svg is blocked by the policy

What is the use-case or motivation for changing an existing behavior?

MDN states that allowing data: urls is insecure:

A schema such as 'http:' or 'https:'. The colon is required, single quotes shouldn't be used. You can also specify data schemas (not recommended). data: Allows data: URIs to be used as a content source. This is insecure; an attacker can also inject arbitrary data: URIs. Use this sparingly and definitely not for scripts.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Since at least Material 5.0.0

Is there anything else we should know?

This is already marked with a TODO, but it is good to have an issue to track the reason why the TODO should be actioned.

Given the content of the svg is simply a circle, it is probable that the same effect can be achieved with a rounded block element without causing any kind of breaking change.

Activity

  1. jelbourn commented on Dec 8, 2017

    @jelbourn
    Contributor

    @josephperrott why does the progress-bar have an SVG? Only the spinner needs one AFAIK

    The spinner does need an SVG because we animate it via stroke-dashoffset

  2. self-assigned this
    on Dec 8, 2017
  3. added
    animation
    P2
    on Dec 8, 2017
  4. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2animation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions